node-editor/app.js

31 lines
761 B
JavaScript

import { NodeEditor } from './NodeEditor.js'
// 1. Initialize the UI Engine
const container = document.getElementById('editor-container')
const editor = new NodeEditor(container)
// 2. Extract the State Manager
const graph = editor.getGraphManager()
// 3. Spawning Nodes
const nodeA = graph.addNode({
type: 'source_node',
title: 'Data Stream',
x: 100,
y: 150,
inputs: [],
outputs: [{ id: 'out_raw', name: 'Raw Buffer' }]
})
const nodeB = graph.addNode({
type: 'processing_node',
title: 'Transform Matrix',
x: 450,
y: 250,
inputs: [{ id: 'in_data', name: 'Payload' }],
outputs: [{ id: 'out_success', name: 'Success' }]
})
// 4. Create a programmatically driven wire connection
graph.connect(nodeA.id, 'out_raw', nodeB.id, 'in_data')