mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-25 09:14:25 +00:00
custom_node provided blueprints (#6172)
Frontend implementation for a system to allow custom_nodes to provide a set of subgraph blueprints. Requires comfyanonymous/ComfyUI#10438, but handles gracefully in unavailable. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6172-Early-POC-custom_node-provided-blueprints-2926d73d3650814982ecd43f12abd873) by [Unito](https://www.unito.io) --------- Co-authored-by: Christian Byrne <cbyrne@comfy.org>
This commit is contained in:
@@ -204,6 +204,12 @@ type SimpleApiEvents = keyof PickNevers<ApiEventTypes>
|
||||
/** Keys (names) of API events that pass a {@link CustomEvent} `detail` object. */
|
||||
type ComplexApiEvents = keyof NeverNever<ApiEventTypes>
|
||||
|
||||
export type GlobalSubgraphData = {
|
||||
name: string
|
||||
info: { node_pack: string }
|
||||
data: string | Promise<string>
|
||||
}
|
||||
|
||||
function addHeaderEntry(headers: HeadersInit, key: string, value: string) {
|
||||
if (Array.isArray(headers)) {
|
||||
headers.push([key, value])
|
||||
@@ -1118,6 +1124,22 @@ export class ComfyApi extends EventTarget {
|
||||
return resp.json()
|
||||
}
|
||||
|
||||
async getGlobalSubgraphData(id: string): Promise<string> {
|
||||
const resp = await api.fetchApi('/global_subgraphs/' + id)
|
||||
if (resp.status !== 200) return ''
|
||||
const subgraph: GlobalSubgraphData = await resp.json()
|
||||
return subgraph?.data ?? ''
|
||||
}
|
||||
async getGlobalSubgraphs(): Promise<Record<string, GlobalSubgraphData>> {
|
||||
const resp = await api.fetchApi('/global_subgraphs')
|
||||
if (resp.status !== 200) return {}
|
||||
const subgraphs: Record<string, GlobalSubgraphData> = await resp.json()
|
||||
for (const [k, v] of Object.entries(subgraphs)) {
|
||||
if (!v.data) v.data = this.getGlobalSubgraphData(k)
|
||||
}
|
||||
return subgraphs
|
||||
}
|
||||
|
||||
async getLogs(): Promise<string> {
|
||||
return (await axios.get(this.internalURL('/logs'))).data
|
||||
}
|
||||
|
||||
@@ -775,7 +775,8 @@ export class ComfyApp {
|
||||
this.canvasElRef.value = canvasEl
|
||||
|
||||
await useWorkspaceStore().workflow.syncWorkflows()
|
||||
await useSubgraphStore().fetchSubgraphs()
|
||||
//Doesn't need to block. Blueprints will load async
|
||||
void useSubgraphStore().fetchSubgraphs()
|
||||
await useExtensionService().loadExtensions()
|
||||
|
||||
this.addProcessKeyHandler()
|
||||
|
||||
Reference in New Issue
Block a user