@selenite/graph-editor
Version:
A graph editor for visual programming, based on rete and svelte.
56 lines (55 loc) • 2.25 kB
TypeScript
import type { DataType, SocketType } from '../../plugins/typed-sockets';
import { type ControlOfSocket, type InputControl, type InputControlType, type InputControlValueType, type Socket, type SocketDatastructure, type SocketValueType, type SocketValueWithDatastructure as WithDatastructure } from '../../socket';
import type { HTMLInputAttributes } from 'svelte/elements';
import { Node, type NodeParams, type SocketsValues } from '../Node.svelte';
export type InputControlNodeParams<S extends SocketType, T extends InputControlType, D extends SocketDatastructure = SocketDatastructure> = NodeParams & {
controlType: T;
datastructure?: D;
initial?: InputControlValueType<T>;
socketType?: S;
props?: HTMLInputAttributes;
};
export declare class InputControlNode<S extends SocketType = SocketType, D extends SocketDatastructure = SocketDatastructure> extends Node<{}, {
value: Socket<S>;
}, {
value: InputControl<ControlOfSocket<S>>;
}, {
type: SocketType;
controlType: InputControlType;
}> {
inputControl: InputControl<ControlOfSocket<S>>;
outSocket: Socket<S, D>;
constructor(params: InputControlNodeParams<S, ControlOfSocket<S>>);
changeType(type: S): void;
data(inputs?: {} | undefined): {
[K in 'value']: SocketValueType<{
value: Socket<S>;
}[K]['type']>;
};
}
type SocketConverter<S extends SocketType, T extends SocketType, D extends SocketDatastructure> = (v: WithDatastructure<SocketValueType<S>, D>) => WithDatastructure<SocketValueType<T>, D>;
/**
* Base class for converter nodes.
*
* Converter nodes are used to convert data from one type to another type.
* @template S Source type.
* @template T Target type.
*/
export declare class ConverterNode<S extends DataType = DataType, T extends DataType = DataType, D extends SocketDatastructure = 'scalar'> extends Node<{
value: Socket<S, D>;
}, {
value: Socket<T, D>;
}> {
convert?: SocketConverter<S, T, D>;
constructor(params?: NodeParams & {
source?: S;
target?: T;
convert?: SocketConverter<S, T, D>;
});
data(inputs?: SocketsValues<{
value: Socket<S, D>;
}> | undefined): SocketsValues<{
value: Socket<T, D>;
}>;
}
export {};