diff --git a/app/package.json b/app/package.json index f6eeaeb..f27c68c 100644 --- a/app/package.json +++ b/app/package.json @@ -11,7 +11,6 @@ }, "dependencies": { "@nodes/registry": "link:../packages/registry", - "@nodes/runtime": "link:../packages/runtime", "@nodes/ui": "link:../packages/ui", "@nodes/utils": "link:../packages/utils", "@sveltejs/kit": "^2.7.4", diff --git a/app/src/lib/graph-interface/graph-manager.ts b/app/src/lib/graph-interface/graph-manager.ts index 3e8c5db..c962126 100644 --- a/app/src/lib/graph-interface/graph-manager.ts +++ b/app/src/lib/graph-interface/graph-manager.ts @@ -29,16 +29,22 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any, " private _nodes: Map = new Map(); nodes: Writable> = writable(new Map()); - settingTypes: Record = {}; - settings: Record = {}; + private _edges: Edge[] = []; edges: Writable = writable([]); + settingTypes: Record = {}; + settings: Record = {}; + currentUndoGroup: number | null = null; inputSockets: Writable> = writable(new Set()); history: HistoryManager = new HistoryManager(); + execute = throttle(() => { + if (this.loaded === false) return; + this.emit("result", this.serialize()); + }, 10); constructor(public registry: NodeRegistry) { super(); @@ -53,7 +59,6 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any, " } this.inputSockets.set(s); }); - this.execute = throttle(() => this._execute(), 10); } serialize(): Graph { @@ -67,7 +72,6 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any, " const edges = this._edges.map(edge => [edge[0].id, edge[1], edge[2].id, edge[3]]) as Graph["edges"]; const serialized = { id: this.graph.id, settings: this.settings, nodes, edges }; logger.groupEnd(); - console.log({ serialized }); return clone(serialized); } @@ -86,11 +90,6 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any, " } - execute() { } - _execute() { - if (this.loaded === false) return; - this.emit("result", this.serialize()); - } getNodeDefinitions() { return this.registry.getAllNodes(); @@ -111,9 +110,7 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any, " return [...nodes.values()]; } - getEdgesBetweenNodes(nodes: Node[]): [number, number, number, string][] { - const edges = []; for (const node of nodes) { const children = node.tmp?.children || []; diff --git a/app/src/lib/graph-interface/graph/Graph.svelte b/app/src/lib/graph-interface/graph/Graph.svelte index b06cfbd..b51f7fc 100644 --- a/app/src/lib/graph-interface/graph/Graph.svelte +++ b/app/src/lib/graph-interface/graph/Graph.svelte @@ -21,11 +21,10 @@ import HelpView from "../HelpView.svelte"; import FileSaver from "file-saver"; import { Canvas } from "@threlte/core"; + import { getGraphManager } from "./context.js"; const state = getGraphState(); - export let manager: GraphManager; - export let snapToGrid = true; export let showGrid = true; export let showHelp = false; @@ -33,7 +32,8 @@ let keymap = getContext>("keymap") || createKeyMap([]); - setContext("graphManager", manager); + const manager = getGraphManager(); + const status = manager.status; const nodes = manager.nodes; const edges = manager.edges; @@ -965,6 +965,7 @@ - diff --git a/packages/ui/src/lib/elements/Select.svelte b/packages/ui/src/lib/elements/Select.svelte index c657512..39fc11f 100644 --- a/packages/ui/src/lib/elements/Select.svelte +++ b/packages/ui/src/lib/elements/Select.svelte @@ -25,4 +25,3 @@ border: none; } -