Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
eb4035c8
Commit
eb4035c8
authored
Apr 15, 2023
by
pythongosssss
Browse files
Adds jsdoc for better dev experience
parent
a4049989
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1614 additions
and
4 deletions
+1614
-4
web/scripts/app.js
web/scripts/app.js
+30
-4
web/types/comfy.d.ts
web/types/comfy.d.ts
+78
-0
web/types/litegraph.d.ts
web/types/litegraph.d.ts
+1506
-0
No files found.
web/scripts/app.js
View file @
eb4035c8
...
...
@@ -4,27 +4,49 @@ import { api } from "./api.js";
import
{
defaultGraph
}
from
"
./defaultGraph.js
"
;
import
{
getPngMetadata
,
importA1111
}
from
"
./pnginfo.js
"
;
class
ComfyApp
{
/**
* List of {number, batchCount} entries to queue
* @typedef {import("types/comfy").ComfyExtension} ComfyExtension
*/
export
class
ComfyApp
{
/**
* List of entries to queue
* @type {{number: number, batchCount: number}[]}
*/
#
queueItems
=
[];
/**
* If the queue is currently being processed
* @type {boolean}
*/
#
processingQueue
=
false
;
constructor
()
{
this
.
ui
=
new
ComfyUI
(
this
);
/**
* List of extensions that are registered with the app
* @type {ComfyExtension[]}
*/
this
.
extensions
=
[];
/**
* Stores the execution output data for each node
* @type {Record<string, any>}
*/
this
.
nodeOutputs
=
{};
/**
* If the shift key on the keyboard is pressed
* @type {boolean}
*/
this
.
shiftDown
=
false
;
}
/**
* Invoke an extension callback
* @param {
string
} method The extension callback to execute
* @param {
...
any} args Any arguments to pass to the callback
* @param {
keyof ComfyExtension
} method The extension callback to execute
* @param {any
[]
} args Any arguments to pass to the callback
* @returns
*/
#
invokeExtensions
(
method
,
...
args
)
{
...
...
@@ -1120,6 +1142,10 @@ class ComfyApp {
}
}
/**
* Registers a Comfy web extension with the app
* @param {ComfyExtension} extension
*/
registerExtension
(
extension
)
{
if
(
!
extension
.
name
)
{
throw
new
Error
(
"
Extensions must have a 'name' property.
"
);
...
...
web/types/comfy.d.ts
0 → 100644
View file @
eb4035c8
import
{
LGraphNode
,
IWidget
}
from
"
./litegraph
"
;
import
{
ComfyApp
}
from
"
/scripts/app
"
;
export
interface
ComfyExtension
{
/**
* The name of the extension
*/
name
:
string
;
/**
* Allows any initialisation, e.g. loading resources. Called after the canvas is created but before nodes are added
* @param app The ComfyUI app instance
*/
init
(
app
:
ComfyApp
):
Promise
<
void
>
;
/**
* Allows any additonal setup, called after the application is fully set up and running
* @param app The ComfyUI app instance
*/
setup
(
app
:
ComfyApp
):
Promise
<
void
>
;
/**
* Called before nodes are registered with the graph
* @param defs The collection of node definitions, add custom ones or edit existing ones
* @param app The ComfyUI app instance
*/
addCustomNodeDefs
(
defs
:
Record
<
string
,
ComfyObjectInfo
>
,
app
:
ComfyApp
):
Promise
<
void
>
;
/**
* Allows the extension to add custom widgets
* @param app The ComfyUI app instance
* @returns An array of {[widget name]: widget data}
*/
getCustomWidgets
(
app
:
ComfyApp
):
Promise
<
Array
<
Record
<
string
,
(
node
,
inputName
,
inputData
,
app
)
=>
{
widget
?:
IWidget
;
minWidth
?:
number
;
minHeight
?:
number
}
>
>
>
;
/**
* Allows the extension to add additional handling to the node before it is registered with LGraph
* @param nodeType The node class (not an instance)
* @param nodeData The original node object info config object
* @param app The ComfyUI app instance
*/
beforeRegisterNodeDef
(
nodeType
:
typeof
LGraphNode
,
nodeData
:
ComfyObjectInfo
,
app
:
ComfyApp
):
Promise
<
void
>
;
/**
* Allows the extension to register additional nodes with LGraph after standard nodes are added
* @param app The ComfyUI app instance
*/
registerCustomNodes
(
app
:
ComfyApp
):
Promise
<
void
>
;
/**
* Allows the extension to modify a node that has been reloaded onto the graph.
* If you break something in the backend and want to patch workflows in the frontend
* This is the place to do this
* @param node The node that has been loaded
* @param app The ComfyUI app instance
*/
loadedGraphNode
(
node
:
LGraphNode
,
app
:
ComfyApp
);
/**
* Allows the extension to run code after the constructor of the node
* @param node The node that has been created
* @param app The ComfyUI app instance
*/
nodeCreated
(
node
:
LGraphNode
,
app
:
ComfyApp
);
}
export
type
ComfyObjectInfo
=
{
name
:
string
;
display_name
?:
string
;
description
?:
string
;
category
:
string
;
input
?:
{
required
?:
Record
<
string
,
ComfyObjectInfoConfig
>
;
optional
?:
Record
<
string
,
ComfyObjectInfoConfig
>
;
};
output
?:
string
[];
output_name
:
string
[];
};
export
type
ComfyObjectInfoConfig
=
[
string
|
any
[]]
|
[
string
|
any
[],
any
];
web/types/litegraph.d.ts
0 → 100644
View file @
eb4035c8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment