Unify feature dependencies with workspace dependencies (#2736)

* graph-craft: fix direct wasm build

* graph-craft: fix no serde feature failing to compile

* graph-craft: make wgpu-executor properly optional

* workspace: unify `image` formats in workspace

* workspace: turn most dependencies into workspace deps, no actual changes

* workspace: unify dependency features in workspace dep
This commit is contained in:
Firestar99 2025-06-22 01:26:25 +02:00 committed by GitHub
parent 990d5b37cf
commit ca5ca863cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 151 additions and 143 deletions

View file

@ -676,10 +676,12 @@ fn migrate_layer_to_merge<'de, D: serde::Deserializer<'de>>(deserializer: D) ->
Ok(s)
}
// TODO: Eventually remove this document upgrade code
#[cfg(feature = "serde")]
fn default_import_metadata() -> (NodeId, IVec2) {
(NodeId::new(), IVec2::new(-25, -4))
}
// TODO: Eventually remove this document upgrade code
#[cfg(feature = "serde")]
fn default_export_metadata() -> (NodeId, IVec2) {
(NodeId::new(), IVec2::new(8, -4))
}

View file

@ -532,7 +532,8 @@ impl ProtoNetwork {
Ok(())
}
}
#[derive(Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum GraphErrorType {
NodeNotFound(NodeId),
InputNodeNotFound(NodeId),
@ -588,7 +589,8 @@ impl Debug for GraphErrorType {
}
}
}
#[derive(Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct GraphError {
pub node_path: Vec<NodeId>,
pub identifier: Cow<'static, str>,

View file

@ -1,5 +1,4 @@
use dyn_any::StaticType;
use graphene_core::application_io::SurfaceHandleFrame;
use graphene_core::application_io::{ApplicationError, ApplicationIo, ResourceFuture, SurfaceHandle, SurfaceId};
#[cfg(target_arch = "wasm32")]
use js_sys::{Object, Reflect};
@ -7,6 +6,7 @@ use std::collections::HashMap;
use std::sync::Arc;
#[cfg(target_arch = "wasm32")]
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
#[cfg(feature = "tokio")]
use tokio::io::AsyncReadExt;
#[cfg(target_arch = "wasm32")]
@ -17,6 +17,7 @@ use wasm_bindgen::JsValue;
use web_sys::HtmlCanvasElement;
#[cfg(target_arch = "wasm32")]
use web_sys::window;
#[cfg(feature = "wgpu")]
use wgpu_executor::WgpuExecutor;
#[derive(Debug)]
@ -76,7 +77,7 @@ pub fn wgpu_available() -> Option<bool> {
}
}
match WGPU_AVAILABLE.load(::std::sync::atomic::Ordering::SeqCst) {
match WGPU_AVAILABLE.load(Ordering::SeqCst) {
-1 => None,
0 => Some(false),
_ => Some(true),
@ -85,7 +86,7 @@ pub fn wgpu_available() -> Option<bool> {
impl WasmApplicationIo {
pub async fn new() -> Self {
#[cfg(target_arch = "wasm32")]
#[cfg(all(feature = "wgpu", target_arch = "wasm32"))]
let executor = if let Some(gpu) = web_sys::window().map(|w| w.navigator().gpu()) {
let request_adapter = || {
let request_adapter = js_sys::Reflect::get(&gpu, &wasm_bindgen::JsValue::from_str("requestAdapter")).ok()?;
@ -101,9 +102,14 @@ impl WasmApplicationIo {
None
};
#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(feature = "wgpu", not(target_arch = "wasm32")))]
let executor = WgpuExecutor::new().await;
WGPU_AVAILABLE.store(executor.is_some() as i8, ::std::sync::atomic::Ordering::SeqCst);
#[cfg(not(feature = "wgpu"))]
let wgpu_available = false;
#[cfg(feature = "wgpu")]
let wgpu_available = executor.is_some();
WGPU_AVAILABLE.store(wgpu_available as i8, Ordering::SeqCst);
let mut io = Self {
#[cfg(target_arch = "wasm32")]
@ -121,9 +127,14 @@ impl WasmApplicationIo {
}
pub async fn new_offscreen() -> Self {
#[cfg(feature = "wgpu")]
let executor = WgpuExecutor::new().await;
WGPU_AVAILABLE.store(executor.is_some() as i8, ::std::sync::atomic::Ordering::SeqCst);
#[cfg(not(feature = "wgpu"))]
let wgpu_available = false;
#[cfg(feature = "wgpu")]
let wgpu_available = executor.is_some();
WGPU_AVAILABLE.store(wgpu_available as i8, Ordering::SeqCst);
// Always enable wgpu when running with Tauri
let mut io = Self {
@ -175,7 +186,7 @@ impl ApplicationIo for WasmApplicationIo {
let document = window().expect("should have a window in this context").document().expect("window should have a document");
let canvas: HtmlCanvasElement = document.create_element("canvas")?.dyn_into::<HtmlCanvasElement>()?;
let id = self.ids.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
let id = self.ids.fetch_add(1, Ordering::SeqCst);
// store the canvas in the global scope so it doesn't get garbage collected
let window = window().expect("should have a window in this context");
let window = Object::from(window);
@ -299,8 +310,10 @@ impl ApplicationIo for WasmApplicationIo {
}
}
#[cfg(feature = "wgpu")]
pub type WasmSurfaceHandle = SurfaceHandle<wgpu_executor::Window>;
pub type WasmSurfaceHandleFrame = SurfaceHandleFrame<wgpu_executor::Window>;
#[cfg(feature = "wgpu")]
pub type WasmSurfaceHandleFrame = graphene_core::application_io::SurfaceHandleFrame<wgpu_executor::Window>;
#[derive(Clone, Debug, PartialEq, Hash, specta::Type)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
@ -330,6 +343,6 @@ impl Default for EditorPreferences {
}
}
unsafe impl dyn_any::StaticType for EditorPreferences {
unsafe impl StaticType for EditorPreferences {
type Static = EditorPreferences;
}