mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-01 15:53:26 -10:00
* Create asynchronous rust imaginate node * Make a first imaginate request via rust * Implement parsing of imaginate API result image * Stop refresh timer from affecting imaginate progress requests * Add cargo-about clarification for rustls-webpki * Delete imaginate.ts and all uses of its functions * Add imaginate img2img feature * Fix imaginate random seed button * Fix imaginate ui inferring non-custom resolutions * Fix the imaginate progress indicator * Remove ImaginatePreferences from being compiled into node graph * Regenerate imaginate only when hitting button * Add ability to terminate imaginate requests * Add imaginate server check feature * Do not compile wasm_bindgen bindings in graphite_editor for tests * Address some review suggestions - move wasm futures dependency in editor to the future-executor crate - guard wasm-bindgen in editor behind a `wasm` feature flag - dont make seed number input a slider - remove poll_server_check from process_message function beginning - guard wasm related code behind `cfg(target_arch = "wasm32")` instead of `cfg(test)` - Call the imaginate idle states "Ready" and "Done" instead of "Nothing to do" - Call the imaginate uploading state "Uploading Image" instead of "Uploading Input Image" - Remove the EvalSyncNode * Fix imaginate host name being restored between graphite instances also change the progress status texts a bit. --------- Co-authored-by: Keavon Chambers <[email protected]>
30 lines
772 B
Rust
30 lines
772 B
Rust
use core::future::Future;
|
|
|
|
pub fn block_on<F: Future + 'static>(future: F) -> F::Output {
|
|
#[cfg(target_arch = "wasm32")]
|
|
{
|
|
use wasm_rs_async_executor::single_threaded as executor;
|
|
|
|
let val = std::sync::Arc::new(std::sync::Mutex::new(None));
|
|
let move_val = val.clone();
|
|
let result = executor::spawn(async move {
|
|
let result = executor::yield_async(future).await;
|
|
*move_val.lock().unwrap() = Some(result);
|
|
});
|
|
executor::run(Some(result.task()));
|
|
loop {
|
|
if let Some(result) = val.lock().unwrap().take() {
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
futures::executor::block_on(future)
|
|
}
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
pub fn spawn<F: Future<Output = ()> + 'static>(future: F) {
|
|
wasm_bindgen_futures::spawn_local(future);
|
|
}
|