use crate::io::{NodeGraphEditorConfig, NodeGraphViewState};
use crate::runtime::lookups::NodeGraphLookups;
use jellyflow_core::core::Graph;
use jellyflow_core::ops::GraphHistory;
use super::super::NodeGraphStore;
impl NodeGraphStore {
pub fn graph(&self) -> &Graph {
&self.graph
}
pub fn graph_revision(&self) -> u64 {
self.graph_revision
}
pub fn layout_facts_revision(&self) -> u64 {
self.layout_facts_revision
}
pub fn lookups(&self) -> &NodeGraphLookups {
&self.lookups
}
pub(crate) fn lookups_mut(&mut self) -> &mut NodeGraphLookups {
&mut self.lookups
}
pub fn replace_graph(&mut self, graph: Graph) {
let before = self.capture_document_snapshot();
self.graph = graph;
self.bump_graph_revision();
self.view_state.sanitize_for_graph(&self.graph);
self.lookups.rebuild_from(&self.graph);
self.bump_layout_facts_revision();
self.publish_document_replaced(before);
}
pub fn replace_document(
&mut self,
graph: Graph,
mut view_state: NodeGraphViewState,
editor_config: NodeGraphEditorConfig,
) {
let before = self.capture_document_snapshot();
view_state.sanitize_for_graph(&graph);
self.graph = graph;
self.bump_graph_revision();
self.view_state = view_state;
self.interaction = editor_config.interaction;
self.runtime_tuning = editor_config.runtime_tuning;
self.history = GraphHistory::default();
self.lookups.rebuild_from(&self.graph);
self.bump_layout_facts_revision();
self.publish_document_replaced(before);
}
}