@selenite/graph-editor
Version:
A graph editor for visual programming, based on rete and svelte.
51 lines (50 loc) • 2 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 { Node, path, registerNode } from '../Node.svelte';
let LogNode = class LogNode extends Node {
constructor(params = {}) {
super({ label: 'Log', ...params });
this.pythonComponent.addCode('print($(message))');
this.pythonComponent.setCodeTemplateGetter(() => `
if (rank == 0):
{{this}}
{{exec}}
`);
this.addInExec();
this.addOutExec();
this.addInData('message', {
label: 'Message',
type: 'string'
});
this.addInData('time', {
label: 'Time',
alwaysShowLabel: true,
type: 'number',
initial: 3
});
}
async execute(input, forward, forwardExec) {
const msg = await this.getDataWithInputs('message');
const time = await this.getDataWithInputs('time');
console.log(`Log: ${msg}`);
this.factory?.notifications.show({
title: 'Log',
message: typeof msg === 'string' ? msg : JSON.stringify(msg),
autoClose: time * 1000
});
super.execute(input, forward);
}
};
LogNode = __decorate([
registerNode('io.Log'),
path('I/O'),
__metadata("design:paramtypes", [Object])
], LogNode);
export { LogNode };