Add subgraph skeleton classes (#997)

Allows downstream consumers to use subgraph types ahead of impl.
This commit is contained in:
filtered
2025-05-02 09:16:19 +10:00
committed by GitHub
parent ee89fc575f
commit 199eeae269
11 changed files with 330 additions and 7 deletions

View File

@@ -48,13 +48,17 @@ export interface LGraphConfig {
links_ontop?: any
}
export interface BaseLGraph {
readonly rootGraph: LGraph
}
/**
* LGraph is the class that contain a full graph. We instantiate one and add nodes to it, and then we can run the execution loop.
* supported callbacks:
* + onNodeAdded: when a new node is added to the graph
* + onNodeRemoved: when a node inside this graph is removed
*/
export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
export class LGraph implements LinkNetwork, BaseLGraph, Serialisable<SerialisableGraph> {
static serialisedSchemaVersion = 1 as const
static STATUS_STOPPED = 1
@@ -147,6 +151,14 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
return this.#reroutes
}
get rootGraph(): LGraph {
return this
}
get isRootGraph(): boolean {
return this.rootGraph === this
}
/** @deprecated See {@link state}.{@link LGraphState.lastNodeId lastNodeId} */
get last_node_id() {
return this.state.lastNodeId