diff --git a/crates/bevy_app/Cargo.toml b/crates/bevy_app/Cargo.toml index 984518d1cc..15f511ceb3 100644 --- a/crates/bevy_app/Cargo.toml +++ b/crates/bevy_app/Cargo.toml @@ -31,6 +31,7 @@ thiserror = "1.0" [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = { version = "0.2" } web-sys = { version = "0.3", features = ["Window"] } +console_error_panic_hook = "0.1.6" [lints] workspace = true diff --git a/crates/bevy_app/src/lib.rs b/crates/bevy_app/src/lib.rs index d231780c4a..232c3e801e 100644 --- a/crates/bevy_app/src/lib.rs +++ b/crates/bevy_app/src/lib.rs @@ -9,6 +9,7 @@ mod app; mod main_schedule; +mod panic_handler; mod plugin; mod plugin_group; mod schedule_runner; @@ -16,6 +17,7 @@ mod schedule_runner; pub use app::*; pub use bevy_derive::DynamicPlugin; pub use main_schedule::*; +pub use panic_handler::*; pub use plugin::*; pub use plugin_group::*; pub use schedule_runner::*; diff --git a/crates/bevy_panic_handler/src/lib.rs b/crates/bevy_app/src/panic_handler.rs similarity index 80% rename from crates/bevy_panic_handler/src/lib.rs rename to crates/bevy_app/src/panic_handler.rs index 398877f595..d66062e104 100644 --- a/crates/bevy_panic_handler/src/lib.rs +++ b/crates/bevy_app/src/panic_handler.rs @@ -1,10 +1,4 @@ -#![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![doc( - html_logo_url = "https://bevyengine.org/assets/icon.png", - html_favicon_url = "https://bevyengine.org/assets/icon.png" -)] - -//! This crate provides panic handlers for [Bevy](https://bevyengine.org) +//! This module provides panic handlers for [Bevy](https://bevyengine.org) //! apps, and automatically configures platform specifics (i.e. WASM or Android). //! //! By default, the [`PanicHandlerPlugin`] from this crate is included in Bevy's `DefaultPlugins`. @@ -12,7 +6,8 @@ //! For more fine-tuned control over panic behavior, disable the [`PanicHandlerPlugin`] or //! `DefaultPlugins` during app initialization. -use bevy_app::{App, Plugin}; +use crate::App; +use crate::Plugin; /// Adds sensible panic handlers to Apps. This plugin is part of the `DefaultPlugins`. Adding /// this plugin will setup a panic hook appropriate to your target platform: @@ -21,8 +16,7 @@ use bevy_app::{App, Plugin}; /// * Other platforms are currently not setup. /// /// ```no_run -/// # use bevy_app::{App, NoopPluginGroup as MinimalPlugins, PluginGroup}; -/// # use bevy_panic_handler::PanicHandlerPlugin; +/// # use bevy_app::{App, NoopPluginGroup as MinimalPlugins, PluginGroup, PanicHandlerPlugin}; /// fn main() { /// App::new() /// .add_plugins(MinimalPlugins) @@ -34,8 +28,7 @@ use bevy_app::{App, Plugin}; /// If you want to setup your own panic handler, you should disable this /// plugin from `DefaultPlugins`: /// ```no_run -/// # use bevy_app::{App, NoopPluginGroup as DefaultPlugins, PluginGroup}; -/// # use bevy_panic_handler::PanicHandlerPlugin; +/// # use bevy_app::{App, NoopPluginGroup as DefaultPlugins, PluginGroup, PanicHandlerPlugin}; /// fn main() { /// App::new() /// .add_plugins(DefaultPlugins.build().disable::()) diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index 4520256258..25476de016 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -182,7 +182,6 @@ bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev" } bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.14.0-dev" } bevy_input = { path = "../bevy_input", version = "0.14.0-dev" } bevy_log = { path = "../bevy_log", version = "0.14.0-dev" } -bevy_panic_handler = { path = "../bevy_panic_handler", version = "0.14.0-dev" } bevy_math = { path = "../bevy_math", version = "0.14.0-dev" } bevy_ptr = { path = "../bevy_ptr", version = "0.14.0-dev" } bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", features = [ diff --git a/crates/bevy_internal/src/default_plugins.rs b/crates/bevy_internal/src/default_plugins.rs index fdc33428e5..14e04238c9 100644 --- a/crates/bevy_internal/src/default_plugins.rs +++ b/crates/bevy_internal/src/default_plugins.rs @@ -1,7 +1,7 @@ use bevy_app::{Plugin, PluginGroup, PluginGroupBuilder}; /// This plugin group will add all the default plugins for a *Bevy* application: -/// * [`PanicHandlerPlugin`](crate::panic_handler::PanicHandlerPlugin) +/// * [`PanicHandlerPlugin`](crate::app::PanicHandlerPlugin) /// * [`LogPlugin`](crate::log::LogPlugin) /// * [`TaskPoolPlugin`](crate::core::TaskPoolPlugin) /// * [`TypeRegistrationPlugin`](crate::core::TypeRegistrationPlugin) @@ -43,7 +43,7 @@ impl PluginGroup for DefaultPlugins { fn build(self) -> PluginGroupBuilder { let mut group = PluginGroupBuilder::start::(); group = group - .add(bevy_panic_handler::PanicHandlerPlugin) + .add(bevy_app::PanicHandlerPlugin) .add(bevy_log::LogPlugin::default()) .add(bevy_core::TaskPoolPlugin::default()) .add(bevy_core::TypeRegistrationPlugin) diff --git a/crates/bevy_internal/src/lib.rs b/crates/bevy_internal/src/lib.rs index 5bb91b57ae..944502e484 100644 --- a/crates/bevy_internal/src/lib.rs +++ b/crates/bevy_internal/src/lib.rs @@ -60,11 +60,6 @@ pub mod log { pub use bevy_log::*; } -pub mod panic_handler { - //! Platform-specific panic handlers - pub use bevy_panic_handler::*; -} - pub mod math { //! Math types (Vec3, Mat4, Quat, etc) and helpers. pub use bevy_math::*; diff --git a/crates/bevy_panic_handler/Cargo.toml b/crates/bevy_panic_handler/Cargo.toml deleted file mode 100644 index 5a99d2bd33..0000000000 --- a/crates/bevy_panic_handler/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "bevy_panic_handler" -version = "0.14.0-dev" -edition = "2021" -description = "Provides panic handlers for Bevy Engine" -homepage = "https://bevyengine.org" -repository = "https://github.com/bevyengine/bevy" -license = "MIT OR Apache-2.0" -keywords = ["bevy"] - -[features] - -[dependencies] -bevy_app = { path = "../bevy_app", version = "0.14.0-dev" } - -[target.'cfg(target_arch = "wasm32")'.dependencies] -console_error_panic_hook = "0.1.6" - -[lints] -workspace = true - -[package.metadata.docs.rs] -rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"] -all-features = true