diff --git a/Cargo.toml b/Cargo.toml index e6341e302d86a..8e9e697c60204 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,7 +131,6 @@ default = [ "animation", "bevy_asset", "bevy_audio", - "bevy_clipboard", "bevy_color", "bevy_core_pipeline", "bevy_core_widgets", @@ -308,12 +307,15 @@ bevy_log = ["bevy_internal/bevy_log"] # Enable input focus subsystem bevy_input_focus = ["bevy_internal/bevy_input_focus"] -# Clipboard access -bevy_clipboard = ["bevy_internal/bevy_clipboard"] +# Platform agnostic features +bevy_platform_services = ["bevy_internal/bevy_platform_services"] # Headless widget collection for Bevy UI. bevy_core_widgets = ["bevy_internal/bevy_core_widgets"] +# Clipboard access +clipboard = ["bevy_internal/clipboard"] + # Feathers widget collection. experimental_bevy_feathers = ["bevy_internal/bevy_feathers"] diff --git a/crates/bevy_clipboard/README.md b/crates/bevy_clipboard/README.md deleted file mode 100644 index d96116fb9d4d8..0000000000000 --- a/crates/bevy_clipboard/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Bevy Clipboard - -[![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/bevyengine/bevy#license) -[![Crates.io](https://img.shields.io/crates/v/bevy_clipboard.svg)](https://crates.io/crates/bevy_clipboard) -[![Downloads](https://img.shields.io/crates/d/bevy_clipboard.svg)](https://crates.io/crates/bevy_clipboard) -[![Docs](https://docs.rs/bevy_clipboard/badge.svg)](https://docs.rs/bevy_clipboard/latest/bevy_clipboard/) -[![Discord](https://img.shields.io/discord/691052431525675048.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/bevy) diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index 645c3edafcbe9..184f67693d912 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -369,7 +369,8 @@ web = [ ] # Clipboard support -bevy_clipboard = ["dep:bevy_clipboard"] +bevy_platform_services = ["dep:bevy_platform_services"] +clipboard = ["bevy_platform_services/clipboard"] hotpatching = ["bevy_app/hotpatching", "bevy_ecs/hotpatching"] @@ -460,7 +461,7 @@ bevy_window = { path = "../bevy_window", optional = true, version = "0.17.0-dev" "bevy_reflect", ] } bevy_winit = { path = "../bevy_winit", optional = true, version = "0.17.0-dev", default-features = false } -bevy_clipboard = { path = "../bevy_clipboard", optional = true, version = "0.17.0-dev" } +bevy_platform_services = { path = "../bevy_platform_services", optional = true, version = "0.17.0-dev" } [lints] workspace = true diff --git a/crates/bevy_internal/src/default_plugins.rs b/crates/bevy_internal/src/default_plugins.rs index 622582e4c1fc5..979d4a54094cb 100644 --- a/crates/bevy_internal/src/default_plugins.rs +++ b/crates/bevy_internal/src/default_plugins.rs @@ -68,8 +68,8 @@ plugin_group! { bevy_dev_tools:::DevToolsPlugin, #[cfg(feature = "bevy_ci_testing")] bevy_dev_tools::ci_testing:::CiTestingPlugin, - #[cfg(feature = "bevy_clipboard")] - bevy_clipboard:::ClipboardPlugin, + #[cfg(feature = "bevy_platform_services")] + bevy_platform_services:::ClipboardPlugin, #[cfg(feature = "hotpatching")] bevy_app::hotpatch:::HotPatchPlugin, #[plugin_group] diff --git a/crates/bevy_internal/src/lib.rs b/crates/bevy_internal/src/lib.rs index 7c38097cd6dba..85f00c6100ba2 100644 --- a/crates/bevy_internal/src/lib.rs +++ b/crates/bevy_internal/src/lib.rs @@ -27,8 +27,6 @@ pub use bevy_asset as asset; pub use bevy_audio as audio; #[cfg(feature = "bevy_camera")] pub use bevy_camera as camera; -#[cfg(feature = "bevy_clipboard")] -pub use bevy_clipboard as clipboard; #[cfg(feature = "bevy_color")] pub use bevy_color as color; #[cfg(feature = "bevy_core_pipeline")] @@ -64,6 +62,8 @@ pub use bevy_pbr as pbr; #[cfg(feature = "bevy_picking")] pub use bevy_picking as picking; pub use bevy_platform as platform; +#[cfg(feature = "bevy_platform_services")] +pub use bevy_platform_services as platform_services; pub use bevy_ptr as ptr; pub use bevy_reflect as reflect; #[cfg(feature = "bevy_remote")] diff --git a/crates/bevy_internal/src/prelude.rs b/crates/bevy_internal/src/prelude.rs index 8aed1aa1ddc05..1b6eaf058149f 100644 --- a/crates/bevy_internal/src/prelude.rs +++ b/crates/bevy_internal/src/prelude.rs @@ -88,5 +88,5 @@ pub use crate::gltf::prelude::*; pub use crate::picking::prelude::*; #[doc(hidden)] -#[cfg(feature = "bevy_clipboard")] -pub use crate::clipboard::prelude::*; +#[cfg(feature = "bevy_platform_services")] +pub use crate::platform_services::prelude::*; diff --git a/crates/bevy_clipboard/Cargo.toml b/crates/bevy_platform_services/Cargo.toml similarity index 93% rename from crates/bevy_clipboard/Cargo.toml rename to crates/bevy_platform_services/Cargo.toml index 2020be26a993e..0371437c084dc 100644 --- a/crates/bevy_clipboard/Cargo.toml +++ b/crates/bevy_platform_services/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bevy_clipboard" +name = "bevy_platform_services" version = "0.17.0-dev" edition = "2024" description = "Provides clipboard support for Bevy Engine" @@ -8,6 +8,10 @@ repository = "https://github.com/bevyengine/bevy" license = "MIT OR Apache-2.0" keywords = ["bevy", "clipboard"] +[features] +default = [] +clipboard = [] + [dependencies] # bevy bevy_app = { path = "../bevy_app", version = "0.17.0-dev", default-features = false } diff --git a/crates/bevy_clipboard/LICENSE-APACHE b/crates/bevy_platform_services/LICENSE-APACHE similarity index 100% rename from crates/bevy_clipboard/LICENSE-APACHE rename to crates/bevy_platform_services/LICENSE-APACHE diff --git a/crates/bevy_clipboard/LICENSE-MIT b/crates/bevy_platform_services/LICENSE-MIT similarity index 100% rename from crates/bevy_clipboard/LICENSE-MIT rename to crates/bevy_platform_services/LICENSE-MIT diff --git a/crates/bevy_platform_services/README.md b/crates/bevy_platform_services/README.md new file mode 100644 index 0000000000000..3a4fbf0480d5f --- /dev/null +++ b/crates/bevy_platform_services/README.md @@ -0,0 +1,8 @@ +# Bevy Platform Services + +[![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/bevyengine/bevy#license) +[![Crates.io](https://img.shields.io/crates/v/bevy_platform_services.svg)](https://crates.io/crates/bevy_platform_services) +[![Downloads](https://img.shields.io/crates/d/bevy_platform_services.svg)](https://crates.io/crates/bevy_platform_services) +[![Docs](https://docs.rs/bevy_platform_services/badge.svg)](https://docs.rs/bevy_platform_services/latest/bevy_platform_services/) +[![Discord](https://img.shields.io/discord/691052431525675048.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/bevy) + diff --git a/crates/bevy_clipboard/src/lib.rs b/crates/bevy_platform_services/src/clipboard.rs similarity index 98% rename from crates/bevy_clipboard/src/lib.rs rename to crates/bevy_platform_services/src/clipboard.rs index 9585319975323..7d8c8727e0355 100644 --- a/crates/bevy_clipboard/src/lib.rs +++ b/crates/bevy_platform_services/src/clipboard.rs @@ -7,11 +7,6 @@ use bevy_ecs::resource::Resource; #[cfg(target_arch = "wasm32")] use {alloc::sync::Arc, bevy_platform::sync::Mutex, wasm_bindgen_futures::JsFuture}; -/// The clipboard prelude -pub mod prelude { - pub use crate::{Clipboard, ClipboardRead}; -} - /// Clipboard plugin #[derive(Default)] pub struct ClipboardPlugin; diff --git a/crates/bevy_platform_services/src/lib.rs b/crates/bevy_platform_services/src/lib.rs new file mode 100644 index 0000000000000..de3fe6a9d4984 --- /dev/null +++ b/crates/bevy_platform_services/src/lib.rs @@ -0,0 +1,16 @@ +//! Implementations of high-level OS-specific services. +//! +//! Currently, only the clipboard is implemented, but this crate can serve to later contain other +//! OS independent services such as an on-screen keyboard for mobile and consoles, or desktop notifications. + +/// Container for standard features +pub mod prelude { + #[cfg(feature = "clipboard")] + pub use crate::clipboard::{Clipboard, ClipboardPlugin, ClipboardRead}; +} + +#[cfg(feature = "clipboard")] +pub mod clipboard; + +#[cfg(feature = "clipboard")] +pub use clipboard::ClipboardPlugin; diff --git a/docs/cargo_features.md b/docs/cargo_features.md index b1df519e83ff4..d4a99a0af3904 100644 --- a/docs/cargo_features.md +++ b/docs/cargo_features.md @@ -19,7 +19,6 @@ The default feature set enables most of the expected features of a game engine, |bevy_anti_aliasing|Provides various anti aliasing solutions| |bevy_asset|Provides asset functionality| |bevy_audio|Provides audio functionality| -|bevy_clipboard|Clipboard access| |bevy_color|Provides shared color types and operations| |bevy_core_pipeline|Provides cameras and other basic render pipeline features| |bevy_core_widgets|Headless widget collection for Bevy UI.| @@ -31,6 +30,7 @@ The default feature set enables most of the expected features of a game engine, |bevy_mesh_picking_backend|Provides an implementation for picking meshes| |bevy_pbr|Adds PBR rendering| |bevy_picking|Provides picking functionality| +|bevy_platform_services|OS-independent services such as clipboard access| |bevy_render|Provides rendering functionality| |bevy_scene|Provides scene functionality| |bevy_sprite|Provides sprite functionality| diff --git a/examples/ui/clipboard.rs b/examples/ui/clipboard.rs index c04b74adfad0d..7040787a7cd20 100644 --- a/examples/ui/clipboard.rs +++ b/examples/ui/clipboard.rs @@ -1,9 +1,9 @@ //! This example demonstrates accessing the clipboard to retrieve and display text. use bevy::{ - clipboard::{Clipboard, ClipboardRead}, color::palettes::css::{GREY, NAVY, RED}, diagnostic::FrameTimeDiagnosticsPlugin, + platform_services::clipboard::{Clipboard, ClipboardRead}, prelude::*, };