import { Component, Graph, Renderer, Router, mount } from './el-ui.js'; class Counter extends Component { constructor(props = {}) { super(); this.props = props; this._graph = new Graph(); this._stateNodes = {}; this._state = {}; // State nodes (Engram graph seeds) this._stateNodes['count'] = this._graph.seed({ type: 'state', name: 'count', content: 0 }); this._state['count'] = 0; // Subscribe to graph activation events for (const [key, nodeId] of Object.entries(this._stateNodes)) { this._graph.subscribe(nodeId, (node) => { this._state[key] = node.content; if (this._renderer) this._renderer.patch(); }); } } setState(name, value) { if (this._stateNodes[name] !== undefined) { this._graph.update(this._stateNodes[name], value); } } render() { const __self = this; const count = this._state['count']; return `

${count }

`; } } class App extends Component { constructor(props = {}) { super(); this.props = props; this._graph = new Graph(); this._stateNodes = {}; this._state = {}; } setState(name, value) { if (this._stateNodes[name] !== undefined) { this._graph.update(this._stateNodes[name], value); } } render() { const __self = this; return `
${__self._child(Counter, { })}
`; } } export { Counter, App }; // Mount the app mount(App, '#app');