Skip to content

Commit a67ea64

Browse files
authored
Add existing specifications for custom nodes. (#35)
* Add specifications. * Add README. * Update.
1 parent 58c4411 commit a67ea64

File tree

6 files changed

+798
-0
lines changed

6 files changed

+798
-0
lines changed

specifications/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ComfyUI Current Manifest
2+
3+
This directory contains the current version of ComfyUI's manifest files and API definitions.
4+
5+
## Files
6+
7+
- `api.py` - Python interface for ComfyUI's backend API
8+
- `api.ts` - TypeScript interface for ComfyUI's frontend API
9+
- `node_def.py` - How to define a custom node in Python
10+
- `node_def.json` - How a custom node is saved in a workflow json.
11+
- `pyproject.toml` - Manifest file for custom node pack.

specifications/api.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* The main app instance that you'll use to register tabs and access functionality
3+
*/
4+
export interface AppInstance {
5+
/** Use this to register new sidebar tabs */
6+
extensionManager: ExtensionManager;
7+
/** Access the current workflow graph */
8+
graph: Graph;
9+
/** Access the API for events and other functionality */
10+
api: API;
11+
}
12+
13+
/**
14+
* Configuration for a sidebar tab - use this with app.extensionManager.registerSidebarTab()
15+
*/
16+
export interface SidebarTabConfig {
17+
/** Unique identifier for the tab */
18+
id: string;
19+
/** Icon class for the tab button (e.g., 'pi pi-compass', 'mdi mdi-robot', 'fa-solid fa-star') */
20+
icon: string;
21+
/** Title text for the tab */
22+
title: string;
23+
/** Optional tooltip text shown on hover */
24+
tooltip?: string;
25+
/** Tab type (usually "custom") */
26+
type: string;
27+
/** Function that populates the tab content. Can return a cleanup function. */
28+
render: (element: HTMLElement) => void | (() => void);
29+
}
30+
31+
/**
32+
* Example usage:
33+
*
34+
* ```typescript
35+
* // Basic tab registration
36+
* app.extensionManager.registerSidebarTab({
37+
* id: "customSidebar",
38+
* icon: "pi pi-compass",
39+
* title: "Custom Tab",
40+
* tooltip: "My Custom Sidebar Tab",
41+
* type: "custom",
42+
* render: (el) => {
43+
* el.innerHTML = '<div>This is my custom sidebar content</div>';
44+
* }
45+
* });
46+
*
47+
* // React component example
48+
* app.extensionManager.registerSidebarTab({
49+
* id: "reactSidebar",
50+
* icon: "mdi mdi-react",
51+
* title: "React Tab",
52+
* type: "custom",
53+
* render: (el) => {
54+
* const container = document.createElement("div");
55+
* el.appendChild(container);
56+
* ReactDOM.createRoot(container).render(<YourComponent />);
57+
* }
58+
* });
59+
* ```
60+
*/
61+
62+
// Additional interfaces for internal use
63+
export interface ExtensionManager {
64+
registerSidebarTab(config: SidebarTabConfig): void;
65+
}
66+
67+
export interface Graph {
68+
_nodes: any[];
69+
links: Record<string, any>;
70+
}
71+
72+
export interface API {
73+
addEventListener(event: string, callback: () => void): void;
74+
removeEventListener(event: string, callback: () => void): void;
75+
}

specifications/api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from abc import ABC, abstractmethod
2+
3+
'''
4+
ComfyUI API available to custom nodes.
5+
'''
6+
class ComfyUI(ABC):
7+
@abstractmethod
8+
def some_method(self):
9+
pass

0 commit comments

Comments
 (0)