use crate::webview::emit_webview_event::EventEmitterPlugin;
use crate::webview::handlers::WryHandlersPlugin;
use crate::webview::ipc_resolve::IpcResolvePlugin;
use crate::webview::load_webview::LoadWebviewPlugin;
use crate::webview::protocol::CustomProtocolPlugin;
use crate::webview::visible::VisiblePlugin;
use bevy::platform::collections::HashMap;
use bevy::prelude::{App, Deref, DerefMut, Entity, Plugin};
use bevy_flurx_ipc::FlurxIpcPlugin;
mod emit_webview_event;
pub mod handlers;
mod ipc_resolve;
mod load_webview;
mod visible;
#[cfg(debug_assertions)]
mod devtools;
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
))]
mod linux;
mod protocol;
#[allow(missing_docs)]
pub mod prelude {
pub use crate::webview::{
WryWebViews,
emit_webview_event::{EmitIpcEvent, EventPayload},
handlers::prelude::*,
};
}
pub(crate) struct WebviewPlugin;
impl Plugin for WebviewPlugin {
fn build(&self, app: &mut App) {
if !app.is_plugin_added::<FlurxIpcPlugin>() {
app.add_plugins(FlurxIpcPlugin);
}
app.add_plugins((
LoadWebviewPlugin,
VisiblePlugin,
EventEmitterPlugin,
IpcResolvePlugin,
WryHandlersPlugin,
CustomProtocolPlugin,
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
))]
linux::WebviewSupportLinuxPlugin,
))
.init_non_send_resource::<WryWebViews>();
#[cfg(debug_assertions)]
app.add_plugins(devtools::DevtoolsPlugin);
}
}
#[repr(transparent)]
#[derive(Deref, DerefMut, Default)]
pub struct WryWebViews(pub(crate) HashMap<Entity, wry::WebView>);