-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Content hash based resources #4148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
ec422b6
1b08a3a
be364d9
d4a3e0c
2330a9d
3920949
9860fd6
363d1b0
fa1f4ee
a2795c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| use crate::dispatcher::Dispatcher; | ||
| use crate::messages::prelude::*; | ||
| use graph_craft::application_io::{PlatformApplicationIo, ResourceStorage}; | ||
| pub use graphene_std::uuid::*; | ||
| use std::sync::OnceLock; | ||
|
|
||
|
|
@@ -8,23 +9,29 @@ pub struct Editor { | |
| } | ||
|
|
||
| impl Editor { | ||
| pub fn new(environment: Environment, uuid_random_seed: u64) -> Self { | ||
| pub fn new(environment: Environment, uuid_random_seed: u64, resource_storage: Box<dyn ResourceStorage>) -> Self { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: (Based on your team's feedback about placing integrity-enforcing initialization where the state is created.) Prompt for AI agents |
||
| ENVIRONMENT.set(environment).expect("Editor shoud only be initialized once"); | ||
| graphene_std::uuid::set_uuid_seed(uuid_random_seed); | ||
|
|
||
| Self { dispatcher: Dispatcher::new() } | ||
| Self { | ||
| dispatcher: Dispatcher::new(resource_storage), | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| pub(crate) fn new_local_executor() -> (Self, crate::node_graph_executor::NodeRuntime) { | ||
| let _ = ENVIRONMENT.set(*Editor::environment()); | ||
| graphene_std::uuid::set_uuid_seed(0); | ||
|
|
||
| let (runtime, executor) = crate::node_graph_executor::NodeGraphExecutor::new_with_local_runtime(); | ||
| let (mut runtime, executor) = crate::node_graph_executor::NodeGraphExecutor::new_with_local_runtime(); | ||
| let editor = Self { | ||
| dispatcher: Dispatcher::with_executor(executor), | ||
| }; | ||
|
|
||
| let mut application_io = PlatformApplicationIo::default(); | ||
| application_io.inject_resources(editor.dispatcher.message_handlers.resource_message_handler.resources()); | ||
| runtime.replace_application_io(application_io); | ||
|
|
||
| (editor, runtime) | ||
| } | ||
|
|
||
|
|
@@ -37,6 +44,11 @@ impl Editor { | |
| pub fn poll_node_graph_evaluation(&mut self, responses: &mut VecDeque<Message>) -> Result<(), String> { | ||
| self.dispatcher.poll_node_graph_evaluation(responses) | ||
| } | ||
|
|
||
| pub async fn replace_application_io(&mut self, mut application_io: PlatformApplicationIo) { | ||
| application_io.inject_resources(self.dispatcher.message_handlers.resource_message_handler.resources()); | ||
| crate::node_graph_executor::replace_application_io(application_io).await; | ||
| } | ||
| } | ||
|
|
||
| static ENVIRONMENT: OnceLock<Environment> = OnceLock::new(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Do not block on
FrontendMessage::Awaithere. This makes save-time resource loading run on the desktop event-loop thread and can freeze the app while the document is being prepared.Prompt for AI agents