UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

69 lines 2 kB
import { AnySchema } from '../schemas/index.js'; import { action, computed, makeObservable, observable } from 'mobx'; export class Port { /** * Name to show in the side panel.Optional * */ name; visible = false; node; //Note that we need null values for the observable to work _dynamicType = null; _type = AnySchema; _value; // Used to store arbitrary meta data. Most commonly used in the UI annotations = {}; /** * Unless the port is variadic this will always be a single edge on an input port, however on an output port it can be multiple edges */ _edges = []; constructor(props) { this.name = props.name; this.visible = props.visible == false ? false : true; this.node = props.node; this._type = props.type; this._value = props.value; this.annotations = props.annotations || {}; makeObservable(this, { //@ts-ignore _type: observable.ref, _dynamicType: observable.ref, _value: observable.ref, _edges: observable.shallow, visible: observable.ref, annotations: observable.shallow, type: computed, value: computed, isConnected: computed, dynamicType: computed, setVisible: action, setType: action }); } get isConnected() { return this._edges.length > 0; } get dynamicType() { return this._dynamicType; } get value() { return this._value; } /** * Gets the current type . This might be different from the static type if the value is dynamic * @returns */ get type() { return this._dynamicType || this._type; } setVisible(visible) { this.visible = visible; } setNode(node) { this.node = node; } setType(type) { this._dynamicType = type; } } //# sourceMappingURL=port.js.map