@selenite/graph-editor
Version:
A graph editor for visual programming, based on rete and svelte.
51 lines (50 loc) • 2.09 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { description, Node, path, registerNode } from '../Node.svelte';
import { InputControl } from '../../socket';
import { XMLData } from '../XML';
/**
* This node displays the value of an input.
*/
let DisplayNode = class DisplayNode extends Node {
constructor(params = {}) {
super({
label: 'Display',
...params
});
this.addInData('input', { type: 'any', initial: params.initial });
// Value display
this.addInputControl('display', {
type: 'textarea',
readonly: true,
socketType: 'string',
datastructure: 'scalar'
});
}
async data(inputs) {
const inputValue = this.getData('input', inputs);
this.controls.display.value =
typeof inputValue === 'string'
? inputValue
: inputValue instanceof XMLData
? inputValue.toXml()
: JSON.stringify(inputValue);
// console.debug('Displaying input', inputValue);
this.updateElement('control', this.controls.display.id);
return {};
}
};
DisplayNode = __decorate([
path('I/O'),
description('Displays an input.'),
registerNode('io.DisplayNode'),
__metadata("design:paramtypes", [Object])
], DisplayNode);
export { DisplayNode };