jellyflow_runtime/runtime/store/view/
document.rs1use crate::io::{NodeGraphEditorConfig, NodeGraphViewState};
2use crate::runtime::lookups::NodeGraphLookups;
3use jellyflow_core::core::Graph;
4use jellyflow_core::ops::GraphHistory;
5
6use super::super::NodeGraphStore;
7
8impl NodeGraphStore {
9 pub fn graph(&self) -> &Graph {
10 &self.graph
11 }
12
13 pub fn graph_revision(&self) -> u64 {
14 self.graph_revision
15 }
16
17 pub fn layout_facts_revision(&self) -> u64 {
18 self.layout_facts_revision
19 }
20
21 pub fn lookups(&self) -> &NodeGraphLookups {
22 &self.lookups
23 }
24
25 pub(crate) fn lookups_mut(&mut self) -> &mut NodeGraphLookups {
26 &mut self.lookups
27 }
28
29 pub fn replace_graph(&mut self, graph: Graph) {
37 let before = self.capture_document_snapshot();
38
39 self.graph = graph;
40 self.bump_graph_revision();
41 self.view_state.sanitize_for_graph(&self.graph);
42 self.lookups.rebuild_from(&self.graph);
43 self.bump_layout_facts_revision();
44 self.publish_document_replaced(before);
45 }
46
47 pub fn replace_document(
52 &mut self,
53 graph: Graph,
54 mut view_state: NodeGraphViewState,
55 editor_config: NodeGraphEditorConfig,
56 ) {
57 let before = self.capture_document_snapshot();
58
59 view_state.sanitize_for_graph(&graph);
60 self.graph = graph;
61 self.bump_graph_revision();
62 self.view_state = view_state;
63 self.interaction = editor_config.interaction;
64 self.runtime_tuning = editor_config.runtime_tuning;
65 self.history = GraphHistory::default();
66 self.lookups.rebuild_from(&self.graph);
67 self.bump_layout_facts_revision();
68 self.publish_document_replaced(before);
69 }
70}