diff --git a/editor/src/messages/frontend/frontend_message.rs b/editor/src/messages/frontend/frontend_message.rs index 49d2ab50b..c31c6e2c0 100644 --- a/editor/src/messages/frontend/frontend_message.rs +++ b/editor/src/messages/frontend/frontend_message.rs @@ -13,7 +13,7 @@ use graphene_std::raster::Image; use graphene_std::raster::color::Color; use graphene_std::text::{Font, TextAlign}; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] use crate::messages::portfolio::document::overlays::utility_types::OverlayContext; #[impl_message(Message, Frontend)] @@ -322,7 +322,7 @@ pub enum FrontendMessage { UpdateViewportHolePunch { active: bool, }, - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] RenderOverlays( #[serde(skip, default = "OverlayContext::default")] #[derivative(Debug = "ignore", PartialEq = "ignore")] diff --git a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs index dffcec64d..4a3ba8780 100644 --- a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs +++ b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs @@ -591,7 +591,7 @@ fn static_nodes() -> Vec { description: Cow::Borrowed("Creates a new canvas object."), properties: None, }, - #[cfg(all(feature = "gpu", target_arch = "wasm32"))] + #[cfg(all(feature = "gpu", target_family = "wasm"))] DocumentNodeDefinition { identifier: "Rasterize", category: "Raster", diff --git a/editor/src/messages/portfolio/document/overlays/mod.rs b/editor/src/messages/portfolio/document/overlays/mod.rs index 48e5dd660..f672374cf 100644 --- a/editor/src/messages/portfolio/document/overlays/mod.rs +++ b/editor/src/messages/portfolio/document/overlays/mod.rs @@ -2,7 +2,7 @@ pub mod grid_overlays; mod overlays_message; mod overlays_message_handler; pub mod utility_functions; -#[cfg_attr(not(target_arch = "wasm32"), path = "utility_types_vello.rs")] +#[cfg_attr(not(target_family = "wasm"), path = "utility_types_vello.rs")] pub mod utility_types; #[doc(inline)] diff --git a/editor/src/messages/portfolio/document/overlays/overlays_message_handler.rs b/editor/src/messages/portfolio/document/overlays/overlays_message_handler.rs index 63376b11c..656045cbd 100644 --- a/editor/src/messages/portfolio/document/overlays/overlays_message_handler.rs +++ b/editor/src/messages/portfolio/document/overlays/overlays_message_handler.rs @@ -11,20 +11,24 @@ pub struct OverlaysMessageContext<'a> { #[derive(Debug, Clone, Default, ExtractField)] pub struct OverlaysMessageHandler { pub overlay_providers: HashSet, - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] canvas: Option, - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] context: Option, } #[message_handler_data] impl MessageHandler> for OverlaysMessageHandler { fn process_message(&mut self, message: OverlaysMessage, responses: &mut VecDeque, context: OverlaysMessageContext) { - let OverlaysMessageContext { visibility_settings, ipp, .. } = context; - let device_pixel_ratio = context.device_pixel_ratio; + let OverlaysMessageContext { + visibility_settings, + ipp, + device_pixel_ratio, + .. + } = context; match message { - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] OverlaysMessage::Draw => { use super::utility_functions::overlay_canvas_element; use super::utility_types::OverlayContext; @@ -68,11 +72,10 @@ impl MessageHandler> for OverlaysMes } } } - #[cfg(test)] - OverlaysMessage::Draw => {} - #[cfg(all(not(target_arch = "wasm32"), not(test)))] + #[cfg(all(not(target_family = "wasm"), not(test)))] OverlaysMessage::Draw => { use super::utility_types::OverlayContext; + let size = ipp.viewport_bounds.size(); let overlay_context = OverlayContext::new(size, device_pixel_ratio, visibility_settings); @@ -86,6 +89,13 @@ impl MessageHandler> for OverlaysMes } responses.add(FrontendMessage::RenderOverlays(overlay_context)); } + #[cfg(all(not(target_family = "wasm"), test))] + OverlaysMessage::Draw => { + // Removes unused warnings in test builds + drop(responses); + drop(context); + drop(super::utility_types::OverlayContext::new(ipp.viewport_bounds.size(), device_pixel_ratio, visibility_settings)); + } OverlaysMessage::AddProvider(message) => { self.overlay_providers.insert(message); } diff --git a/editor/src/messages/portfolio/document/utility_types/network_interface.rs b/editor/src/messages/portfolio/document/utility_types/network_interface.rs index 3d557aea5..27fbbcb19 100644 --- a/editor/src/messages/portfolio/document/utility_types/network_interface.rs +++ b/editor/src/messages/portfolio/document/utility_types/network_interface.rs @@ -1424,13 +1424,13 @@ impl NodeNetworkInterface { .any(|id| id == potentially_upstream_node) } - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] fn text_width(&self, node_id: &NodeId, network_path: &[NodeId]) -> Option { warn!("Failed to find width of {node_id:#?} in network_path {network_path:?} due to non-wasm arch"); Some(0.) } - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] fn text_width(&self, node_id: &NodeId, network_path: &[NodeId]) -> Option { let document = web_sys::window().unwrap().document().unwrap(); let div = match document.create_element("div") { diff --git a/editor/src/messages/portfolio/portfolio_message_handler.rs b/editor/src/messages/portfolio/portfolio_message_handler.rs index a32553a2f..1403e3e2f 100644 --- a/editor/src/messages/portfolio/portfolio_message_handler.rs +++ b/editor/src/messages/portfolio/portfolio_message_handler.rs @@ -962,7 +962,7 @@ impl MessageHandler> for Portfolio responses.add(FrontendMessage::UpdateOpenDocumentsList { open_documents }); } PortfolioMessage::UpdateVelloPreference => { - let active = if cfg!(target_arch = "wasm32") { false } else { preferences.use_vello }; + let active = if cfg!(target_family = "wasm") { false } else { preferences.use_vello }; responses.add(FrontendMessage::UpdateViewportHolePunch { active }); responses.add(NodeGraphMessage::RunDocumentGraph); self.persistent_data.use_vello = preferences.use_vello; diff --git a/editor/src/node_graph_executor/runtime.rs b/editor/src/node_graph_executor/runtime.rs index efc9bffe3..701597662 100644 --- a/editor/src/node_graph_executor/runtime.rs +++ b/editor/src/node_graph_executor/runtime.rs @@ -134,9 +134,9 @@ impl NodeRuntime { pub async fn run(&mut self) -> Option { if self.editor_api.application_io.is_none() { self.editor_api = WasmEditorApi { - #[cfg(all(not(test), target_arch = "wasm32"))] + #[cfg(all(not(test), target_family = "wasm"))] application_io: Some(WasmApplicationIo::new().await.into()), - #[cfg(any(test, not(target_arch = "wasm32")))] + #[cfg(any(test, not(target_family = "wasm")))] application_io: Some(WasmApplicationIo::new_offscreen().await.into()), font_cache: self.editor_api.font_cache.clone(), node_graph_message_sender: Box::new(self.sender.clone()), diff --git a/libraries/dyn-any/src/lib.rs b/libraries/dyn-any/src/lib.rs index 57bb10a79..047557a4b 100644 --- a/libraries/dyn-any/src/lib.rs +++ b/libraries/dyn-any/src/lib.rs @@ -363,31 +363,31 @@ fn simple_downcast_panic() { assert_eq!(*downcast::(x).expect("attempted to perform invalid downcast"), 3_u32); } -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] pub trait WasmNotSend: Send {} -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] pub trait WasmNotSend {} -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] impl WasmNotSend for T {} -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] impl WasmNotSend for T {} -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] pub trait WasmNotSync: Sync {} -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] pub trait WasmNotSync {} -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] impl WasmNotSync for T {} -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] impl WasmNotSync for T {} -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] #[cfg(feature = "alloc")] pub type DynFuture<'n, T> = Pin + 'n + Send>>; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] #[cfg(feature = "alloc")] pub type DynFuture<'n, T> = Pin + 'n>>; diff --git a/node-graph/gapplication-io/src/lib.rs b/node-graph/gapplication-io/src/lib.rs index 42a981caf..d53f50cf2 100644 --- a/node-graph/gapplication-io/src/lib.rs +++ b/node-graph/gapplication-io/src/lib.rs @@ -42,7 +42,7 @@ pub trait Size { fn size(&self) -> UVec2; } -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] impl Size for web_sys::HtmlCanvasElement { fn size(&self) -> UVec2 { UVec2::new(self.width(), self.height()) @@ -115,9 +115,9 @@ pub struct SurfaceHandle { pub surface: Surface, } -// #[cfg(target_arch = "wasm32")] +// #[cfg(target_family = "wasm")] // unsafe impl Send for SurfaceHandle {} -// #[cfg(target_arch = "wasm32")] +// #[cfg(target_family = "wasm")] // unsafe impl Sync for SurfaceHandle {} impl Size for SurfaceHandle { @@ -153,9 +153,9 @@ impl<'a, Surface> Drop for SurfaceHandle<'a, Surface> { } }*/ -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] pub type ResourceFuture = Pin, ApplicationError>>>>; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] pub type ResourceFuture = Pin, ApplicationError>> + Send>>; pub trait ApplicationIo { diff --git a/node-graph/gcore/src/registry.rs b/node-graph/gcore/src/registry.rs index a2df73ff8..e8a0a4e5a 100644 --- a/node-graph/gcore/src/registry.rs +++ b/node-graph/gcore/src/registry.rs @@ -56,20 +56,20 @@ pub static NODE_REGISTRY: NodeRegistry = LazyLock::new(|| Mutex::new(HashMap::ne pub static NODE_METADATA: LazyLock>> = LazyLock::new(|| Mutex::new(HashMap::new())); -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] pub type DynFuture<'n, T> = Pin + 'n + Send>>; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] pub type DynFuture<'n, T> = Pin + 'n>>; pub type LocalFuture<'n, T> = Pin + 'n>>; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] pub type Any<'n> = Box + 'n + Send>; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] pub type Any<'n> = Box + 'n>; pub type FutureAny<'n> = DynFuture<'n, Any<'n>>; // TODO: is this safe? This is assumed to be send+sync. -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] pub type TypeErasedNode<'n> = dyn for<'i> NodeIO<'i, Any<'i>, Output = FutureAny<'i>> + 'n + Send + Sync; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] pub type TypeErasedNode<'n> = dyn for<'i> NodeIO<'i, Any<'i>, Output = FutureAny<'i>> + 'n; pub type TypeErasedPinnedRef<'n> = Pin<&'n TypeErasedNode<'n>>; pub type TypeErasedRef<'n> = &'n TypeErasedNode<'n>; diff --git a/node-graph/graph-craft/Cargo.toml b/node-graph/graph-craft/Cargo.toml index ce27305cc..7f8f5ee9e 100644 --- a/node-graph/graph-craft/Cargo.toml +++ b/node-graph/graph-craft/Cargo.toml @@ -38,7 +38,7 @@ tokio = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } # Workspace dependencies -[target.'cfg(target_arch = "wasm32")'.dependencies] +[target.'cfg(target_family = "wasm")'.dependencies] web-sys = { workspace = true, features = [ "Navigator", "Gpu", @@ -46,7 +46,7 @@ web-sys = { workspace = true, features = [ js-sys = { workspace = true } wasm-bindgen = { workspace = true } -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +[target.'cfg(not(target_family = "wasm"))'.dependencies] winit = { workspace = true } [dev-dependencies] diff --git a/node-graph/graph-craft/src/document.rs b/node-graph/graph-craft/src/document.rs index 08679ce41..b2e1fcc95 100644 --- a/node-graph/graph-craft/src/document.rs +++ b/node-graph/graph-craft/src/document.rs @@ -42,7 +42,7 @@ pub struct DocumentNode { /// In the root network, it is resolved when evaluating the borrow tree. /// Ensure the click target in the encapsulating network is updated when the inputs cause the node shape to change (currently only when exposing/hiding an input) /// by using network.update_click_target(node_id). - #[cfg_attr(target_arch = "wasm32", serde(alias = "outputs"))] + #[cfg_attr(target_family = "wasm", serde(alias = "outputs"))] pub inputs: Vec, /// Manual composition is the methodology by which most nodes are implemented, involving a call argument and upstream inputs. /// By contrast, automatic composition is an alternative way to handle the composition of nodes as they execute in the graph. @@ -552,7 +552,7 @@ pub struct OldDocumentNode { /// /// In the root network, it is resolved when evaluating the borrow tree. /// Ensure the click target in the encapsulating network is updated when the inputs cause the node shape to change (currently only when exposing/hiding an input) by using network.update_click_target(node_id). - #[cfg_attr(target_arch = "wasm32", serde(alias = "outputs"))] + #[cfg_attr(target_family = "wasm", serde(alias = "outputs"))] pub inputs: Vec, pub manual_composition: Option, // TODO: Remove once this references its definition instead (see above TODO). @@ -657,7 +657,7 @@ pub struct NodeNetwork { /// The list of data outputs that are exported from this network to the parent network. /// Each export is a reference to a node within this network, paired with its output index, that is the source of the network's exported data. // TODO: Eventually remove this alias document upgrade code - #[cfg_attr(target_arch = "wasm32", serde(alias = "outputs", deserialize_with = "deserialize_exports"))] + #[cfg_attr(target_family = "wasm", serde(alias = "outputs", deserialize_with = "deserialize_exports"))] pub exports: Vec, // TODO: Instead of storing import types in each NodeInput::Network connection, the types are stored here. This is similar to how types need to be defined for parameters when creating a function in Rust. // pub import_types: Vec, diff --git a/node-graph/graph-craft/src/document/value.rs b/node-graph/graph-craft/src/document/value.rs index d8e49d095..bb187af41 100644 --- a/node-graph/graph-craft/src/document/value.rs +++ b/node-graph/graph-craft/src/document/value.rs @@ -186,13 +186,13 @@ tagged_value! { // GRAPHICAL DATA TYPES // ==================== GraphicElement(graphene_core::GraphicElement), - #[cfg_attr(target_arch = "wasm32", serde(deserialize_with = "graphene_core::vector::migrate_vector_data"))] // TODO: Eventually remove this migration document upgrade code + #[cfg_attr(target_family = "wasm", serde(deserialize_with = "graphene_core::vector::migrate_vector_data"))] // TODO: Eventually remove this migration document upgrade code VectorData(graphene_core::vector::VectorDataTable), - #[cfg_attr(target_arch = "wasm32", serde(alias = "ImageFrame", deserialize_with = "graphene_core::raster::image::migrate_image_frame"))] // TODO: Eventually remove this migration document upgrade code + #[cfg_attr(target_family = "wasm", serde(alias = "ImageFrame", deserialize_with = "graphene_core::raster::image::migrate_image_frame"))] // TODO: Eventually remove this migration document upgrade code RasterData(graphene_core::raster_types::RasterDataTable), - #[cfg_attr(target_arch = "wasm32", serde(deserialize_with = "graphene_core::graphic_element::migrate_graphic_group"))] // TODO: Eventually remove this migration document upgrade code + #[cfg_attr(target_family = "wasm", serde(deserialize_with = "graphene_core::graphic_element::migrate_graphic_group"))] // TODO: Eventually remove this migration document upgrade code GraphicGroup(graphene_core::GraphicGroupTable), - #[cfg_attr(target_arch = "wasm32", serde(deserialize_with = "graphene_core::graphic_element::migrate_artboard_group"))] // TODO: Eventually remove this migration document upgrade code + #[cfg_attr(target_family = "wasm", serde(deserialize_with = "graphene_core::graphic_element::migrate_artboard_group"))] // TODO: Eventually remove this migration document upgrade code ArtboardGroup(graphene_core::ArtboardGroupTable), // ============ // STRUCT TYPES diff --git a/node-graph/graph-craft/src/wasm_application_io.rs b/node-graph/graph-craft/src/wasm_application_io.rs index c92d8e712..999b00fe0 100644 --- a/node-graph/graph-craft/src/wasm_application_io.rs +++ b/node-graph/graph-craft/src/wasm_application_io.rs @@ -1,35 +1,35 @@ use dyn_any::StaticType; use graphene_application_io::{ApplicationError, ApplicationIo, ResourceFuture, SurfaceHandle, SurfaceId}; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use js_sys::{Object, Reflect}; use std::collections::HashMap; use std::hash::Hash; use std::sync::Arc; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use std::sync::atomic::AtomicU64; use std::sync::atomic::Ordering; #[cfg(feature = "tokio")] use tokio::io::AsyncReadExt; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use wasm_bindgen::JsCast; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use wasm_bindgen::JsValue; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use web_sys::HtmlCanvasElement; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use web_sys::window; #[cfg(feature = "wgpu")] use wgpu_executor::WgpuExecutor; #[derive(Debug)] struct WindowWrapper { - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] window: SurfaceHandle, - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] window: SurfaceHandle>, } -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] impl Drop for WindowWrapper { fn drop(&mut self) { let window = window().expect("should have a window in this context"); @@ -52,14 +52,14 @@ impl Drop for WindowWrapper { } } -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] unsafe impl Sync for WindowWrapper {} -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] unsafe impl Send for WindowWrapper {} #[derive(Debug, Default)] pub struct WasmApplicationIo { - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] ids: AtomicU64, #[cfg(feature = "wgpu")] pub(crate) gpu_executor: Option, @@ -79,7 +79,7 @@ pub fn wgpu_available() -> Option { impl WasmApplicationIo { pub async fn new() -> Self { - #[cfg(all(feature = "wgpu", target_arch = "wasm32"))] + #[cfg(all(feature = "wgpu", target_family = "wasm"))] 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()?; @@ -95,7 +95,7 @@ impl WasmApplicationIo { None }; - #[cfg(all(feature = "wgpu", not(target_arch = "wasm32")))] + #[cfg(all(feature = "wgpu", not(target_family = "wasm")))] let executor = WgpuExecutor::new().await; #[cfg(not(feature = "wgpu"))] @@ -105,7 +105,7 @@ impl WasmApplicationIo { WGPU_AVAILABLE.store(wgpu_available as i8, Ordering::SeqCst); let mut io = Self { - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] ids: AtomicU64::new(0), #[cfg(feature = "wgpu")] gpu_executor: executor, @@ -130,7 +130,7 @@ impl WasmApplicationIo { WGPU_AVAILABLE.store(wgpu_available as i8, Ordering::SeqCst); let mut io = Self { - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] ids: AtomicU64::new(0), #[cfg(feature = "wgpu")] gpu_executor: executor, @@ -142,7 +142,7 @@ impl WasmApplicationIo { io } - #[cfg(all(not(target_arch = "wasm32"), feature = "wgpu"))] + #[cfg(all(not(target_family = "wasm"), feature = "wgpu"))] pub fn new_with_context(context: wgpu_executor::Context) -> Self { #[cfg(feature = "wgpu")] let executor = WgpuExecutor::with_context(context); @@ -184,16 +184,16 @@ impl<'a> From<&'a WasmApplicationIo> for &'a WgpuExecutor { pub type WasmEditorApi = graphene_application_io::EditorApi; impl ApplicationIo for WasmApplicationIo { - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] type Surface = HtmlCanvasElement; - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] type Surface = Arc; #[cfg(feature = "wgpu")] type Executor = WgpuExecutor; #[cfg(not(feature = "wgpu"))] type Executor = (); - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] fn create_window(&self) -> SurfaceHandle { let wrapper = || { let document = window().expect("should have a window in this context").document().expect("window should have a document"); @@ -228,7 +228,7 @@ impl ApplicationIo for WasmApplicationIo { wrapper().expect("should be able to set canvas in global scope") } - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] fn create_window(&self) -> SurfaceHandle { todo!("winit api changed, calling create_window on EventLoop is deprecated"); @@ -256,7 +256,7 @@ impl ApplicationIo for WasmApplicationIo { // } } - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] fn destroy_window(&self, surface_id: SurfaceId) { let window = window().expect("should have a window in this context"); let window = Object::from(window); @@ -277,7 +277,7 @@ impl ApplicationIo for WasmApplicationIo { wrapper().expect("should be able to set canvas in global scope") } - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] fn destroy_window(&self, _surface_id: SurfaceId) {} #[cfg(feature = "wgpu")] @@ -346,9 +346,9 @@ impl graphene_application_io::GetEditorPreferences for EditorPreferences { impl Default for EditorPreferences { fn default() -> Self { Self { - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] use_vello: false, - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] use_vello: true, } } diff --git a/node-graph/gstd/src/wasm_application_io.rs b/node-graph/gstd/src/wasm_application_io.rs index 7ba1a568d..17f716098 100644 --- a/node-graph/gstd/src/wasm_application_io.rs +++ b/node-graph/gstd/src/wasm_application_io.rs @@ -2,9 +2,9 @@ use graph_craft::document::value::RenderOutput; pub use graph_craft::document::value::RenderOutputType; pub use graph_craft::wasm_application_io::*; use graphene_application_io::{ApplicationIo, ExportFormat, RenderConfig}; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use graphene_core::instances::Instances; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use graphene_core::math::bbox::Bbox; use graphene_core::raster::image::Image; use graphene_core::raster_types::{CPU, Raster, RasterDataTable}; @@ -14,14 +14,14 @@ use graphene_core::{Color, Context, Ctx, ExtractFootprint, GraphicGroupTable, Ow use graphene_svg_renderer::RenderMetadata; use graphene_svg_renderer::{GraphicElementRendered, RenderParams, RenderSvgSegmentList, SvgRender, format_transform_matrix}; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use base64::Engine; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use glam::DAffine2; use std::sync::Arc; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use wasm_bindgen::JsCast; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement}; #[cfg(feature = "wgpu")] @@ -32,7 +32,7 @@ async fn create_surface<'a: 'n>(_: impl Ctx, editor: &'a WasmEditorApi) -> Arc String { - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] { if discard_result { wasm_bindgen_futures::spawn_local(async move { @@ -41,7 +41,7 @@ async fn get_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, disc return String::new(); } } - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] { #[cfg(feature = "tokio")] if discard_result { @@ -62,7 +62,7 @@ async fn get_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, disc #[node_macro::node(category("Web Request"))] async fn post_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, body: Vec, discard_result: bool) -> String { - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] { if discard_result { wasm_bindgen_futures::spawn_local(async move { @@ -71,7 +71,7 @@ async fn post_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, bod return String::new(); } } - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] { #[cfg(feature = "tokio")] if discard_result { @@ -165,7 +165,7 @@ fn render_svg(data: impl GraphicElementRendered, mut render: SvgRender, render_p } #[cfg(feature = "vello")] -#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code))] +#[cfg_attr(not(target_family = "wasm"), allow(dead_code))] async fn render_canvas( render_config: RenderConfig, data: impl GraphicElementRendered, @@ -216,7 +216,7 @@ async fn render_canvas( } } -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] #[node_macro::node(category(""))] async fn rasterize( _: impl Ctx, @@ -326,13 +326,13 @@ async fn render<'a: 'n, T: 'n + GraphicElementRendered + WasmNotSend>( let data = data.eval(ctx.clone()).await; let editor_api = editor_api.eval(None).await; - #[cfg(all(feature = "vello", not(test), target_arch = "wasm32"))] + #[cfg(all(feature = "vello", not(test), target_family = "wasm"))] let _surface_handle = _surface_handle.eval(None).await; - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] let _surface_handle: Option = None; let use_vello = editor_api.editor_preferences.use_vello(); - #[cfg(all(feature = "vello", not(test), target_arch = "wasm32"))] + #[cfg(all(feature = "vello", not(test), target_family = "wasm"))] let use_vello = use_vello && _surface_handle.is_some(); let mut metadata = RenderMetadata::default(); diff --git a/node-graph/node-macro/src/codegen.rs b/node-graph/node-macro/src/codegen.rs index a969460e1..8039fdf27 100644 --- a/node-graph/node-macro/src/codegen.rs +++ b/node-graph/node-macro/src/codegen.rs @@ -406,7 +406,7 @@ pub(crate) fn generate_node_code(parsed: &ParsedNodeFn) -> syn::Result; unsafe impl StaticType for Surface { @@ -186,12 +186,12 @@ impl WgpuExecutor { Ok(texture) } - #[cfg(target_arch = "wasm32")] + #[cfg(target_family = "wasm")] pub fn create_surface(&self, canvas: graphene_application_io::WasmSurfaceHandle) -> Result> { let surface = self.context.instance.create_surface(wgpu::SurfaceTarget::Canvas(canvas.surface))?; self.create_surface_inner(surface, canvas.window_id) } - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] pub fn create_surface(&self, window: SurfaceHandle) -> Result> { let surface = self.context.instance.create_surface(wgpu::SurfaceTarget::Window(Box::new(window.surface)))?; self.create_surface_inner(surface, window.window_id)