UNPKG

@selenite/graph-editor

Version:

A graph editor for visual programming, based on rete and svelte.

49 lines (48 loc) 1.97 kB
import type { Schemes } from '../schemes'; import { type GetSchemes, NodeEditor, type NodeId, type Root, Scope } from 'rete'; import { type Cancellable, Dataflow } from 'rete-engine'; import { Cache } from './utils/Cache'; export type PythonDataflowEngineScheme = GetSchemes<Schemes['Node'], Schemes['Connection']>; type Configure<Schemes extends PythonDataflowEngineScheme> = (node: Schemes['Node']) => { inputs: () => string[]; outputs: () => string[]; }; /** * DataflowEngine is a plugin that integrates Dataflow with NodeEditor making it easy to use. * Additionally, it provides a cache for the data of each node in order to avoid recurring calculations. * @priority 10 * @listens nodecreated * @listens noderemoved * */ export declare class PythonDataflowEngine<Schemes extends PythonDataflowEngineScheme> extends Scope<never, [ Root<Schemes> ]> { private configure?; editor: NodeEditor<Schemes>; dataflow?: Dataflow<Schemes>; cache: Cache<string, Cancellable<Record<string, unknown>>>; constructor(configure?: Configure<Schemes> | undefined); setParent(scope: Scope<Root<Schemes>>): void; private getDataflow; private add; private remove; /** * Resets the cache of the node and all its predecessors. * @param nodeId Node id to reset. If not specified, all nodes will be reset. */ reset(nodeId?: NodeId, alreadyResetNodes?: Set<NodeId>): void; /** * Fetches input data for the node by fetching data for all its predecessors recursively. * @param nodeId Node id to fetch input data for * @throws `Cancelled when `reset` is called while fetching data */ fetchInputs(nodeId: NodeId): Promise<Record<string, any>>; /** * Fetches output data of the node * @param nodeId Node id to fetch data from * @throws `Cancelled` when `reset` is called while fetching data */ fetch(nodeId: NodeId): Promise<Record<string, any>>; } export {};