Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/target
/Cargo.lock
/.nvim
examples/leptos-csr/ui/target
examples/leptos-ssr/ui/target
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ repository = "https://github.com/PawelBis/bevy_wry"

[dependencies]
wry = { version = "0.48.1", features = ["transparent", "devtools"] }
bevy = { version = "0.15", default-features = false, features = ["bevy_winit"] }
bevy = { version = "0.16", default-features = false, features = ["bevy_winit"] }
winit = { version = "0.30", features = ["rwh_06"] }
thiserror = "1.0"
serde = { version = "1.0", default-features = false }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1.0" }
hashbrown = "0.15.4"

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
gtk = { version = "0.18" }
x11-dl = "2.21.0"

[dev-dependencies]
bevy = { version = "0.15", default-features = true }
bevy = { version = "0.16", default-features = true }

[[example]]
name = "fullscreen"
Expand Down
10 changes: 3 additions & 7 deletions examples/anchors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,9 @@ fn setup(mut commands: Commands) {
fn next_anchor(
_: Trigger<NextAnchor>,
mut exit_writer: EventWriter<AppExit>,
mut webviews: Query<&mut Anchor, With<Initialized>>,
webviews: Single<&mut Anchor, With<Initialized>>,
) {
if webviews.is_empty() {
return;
}

let mut anchor = webviews.single_mut();
let mut anchor = webviews.into_inner();
let new_anchor = match *anchor {
Anchor::Top => Anchor::TopRight,
Anchor::Bottom => Anchor::BottomLeft,
Expand All @@ -96,7 +92,7 @@ fn next_anchor(
Anchor::CenterVerticalStretch => Anchor::CenterHorizontalStretch,
Anchor::CenterHorizontalStretch => Anchor::FullScreen,
Anchor::FullScreen => {
exit_writer.send(AppExit::Success);
exit_writer.write(AppExit::Success);
return;
}
};
Expand Down
8 changes: 4 additions & 4 deletions examples/fullscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ fn in_commands(
trigger: Trigger<InCommand>,
mut commands: Commands,
mut exit_writer: EventWriter<AppExit>,
mut sprite: Query<(&mut Transform, &Sprite)>,
sprite: Single<(&mut Transform, &Sprite)>,
) {
let event = trigger.event();
let webview_entity = trigger.entity();
let webview_entity = trigger.target();

match event {
InCommand::Rotate { angle } => {
let (mut transform, _) = sprite.single_mut();
let (mut transform, _) = sprite.into_inner();
transform.rotate_z(f32::to_radians(*angle));

let (_, z) = transform.rotation.to_axis_angle();
Expand All @@ -84,7 +84,7 @@ fn in_commands(
}
}
InCommand::Exit => {
exit_writer.send(AppExit::Success);
exit_writer.write(AppExit::Success);
}
}
}
2 changes: 1 addition & 1 deletion examples/leptos-csr/leptos-ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Drop for CommandGuard {

fn main() {
let manifest_path = env::var("CARGO_MANIFEST_DIR").unwrap();
let ui_path = format!("{manifest_path}/examples/leptos/ui");
let ui_path = format!("{manifest_path}/examples/leptos-csr/ui");

// Use trunk to build `ui` which is a leptos project
Command::new("trunk")
Expand Down
6 changes: 3 additions & 3 deletions examples/leptos-csr/ui/dist/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<html>
<head><link rel="modulepreload" href="/ui-4806616c12bf9cb4.js" crossorigin="anonymous" integrity="sha384-aU6orLDiAmjRK4EWWu0wPW1UT3R6cWZUE6NWxOGG06KwVcx+8vVuZTSouthKCew+"><link rel="preload" href="/ui-4806616c12bf9cb4_bg.wasm" crossorigin="anonymous" integrity="sha384-lRtGk/UwbQ/2URR5XX7Rpt2HuTuSp4rF0ZIKity8ZCwyTBiOh+qKD7tgepSqtHgJ" as="fetch" type="application/wasm"></head>
<head><link rel="modulepreload" href="/ui-beddfcf870bf0c04.js" crossorigin="anonymous" integrity="sha384-6x0sT9iCe0KH+RXtqKU8ZCox+ggnYGwMpGrgkLvfnClOypiQ3EMs+4Ifhgsfkaht"><link rel="preload" href="/ui-beddfcf870bf0c04_bg.wasm" crossorigin="anonymous" integrity="sha384-9SZXBeLntQDlwLe70gUK0IcgO/gngihwiv0ZDIuCsnzM4EvLDSkzsSHDz0e+kKFM" as="fetch" type="application/wasm"></head>
<body>
<script type="module">
import init, * as bindings from '/ui-4806616c12bf9cb4.js';
const wasm = await init({ module_or_path: '/ui-4806616c12bf9cb4_bg.wasm' });
import init, * as bindings from '/ui-beddfcf870bf0c04.js';
const wasm = await init({ module_or_path: '/ui-beddfcf870bf0c04_bg.wasm' });


window.wasmBindings = bindings;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ function getDataViewMemory0() {
return cachedDataViewMemory0;
}
function __wbg_adapter_22(arg0, arg1, arg2) {
wasm.closure53_externref_shim(arg0, arg1, arg2);
wasm.closure50_externref_shim(arg0, arg1, arg2);
}

function __wbg_adapter_73(arg0, arg1, arg2, arg3) {
wasm.closure71_externref_shim(arg0, arg1, arg2, arg3);
wasm.closure67_externref_shim(arg0, arg1, arg2, arg3);
}

const __wbindgen_enum_ReadableStreamType = ["bytes"];
Expand Down Expand Up @@ -525,8 +525,8 @@ function __wbg_get_imports() {
const ret = false;
return ret;
};
imports.wbg.__wbindgen_closure_wrapper4716 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 54, __wbg_adapter_22);
imports.wbg.__wbindgen_closure_wrapper4709 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 51, __wbg_adapter_22);
return ret;
};
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions src/components/webview.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{WryPosition, WrySize};
use bevy::prelude::*;
use bevy::utils::hashbrown::hash_map::Values;
use bevy::utils::hashbrown::HashMap;
use hashbrown::hash_map::Values;
use hashbrown::HashMap;
use wry::dpi::{LogicalPosition, LogicalSize};
use wry::WebView;

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ where
///
/// fn send_commands(
/// mut commands: Commands,
/// query: Query<Entity, With<WebViewComponent>>,
/// query: Single<Entity, With<WebViewComponent>>,
/// ) {
/// let entity = query.single();
/// let entity = query.into_inner();
/// commands.trigger_targets(ConsoleLog("Hello from Bevy!".into()), entity);
/// }
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/systems/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) fn produce_out_scripts<E: OutWryEvent>(
trigger: Trigger<E>,
out_bus: Query<&OutMessageBus>,
) {
let ob = out_bus.get(trigger.entity()).unwrap();
let ob = out_bus.get(trigger.target()).unwrap();
let event: &E = trigger.event();
ob.write().push(event.to_script());
}
Expand Down
8 changes: 4 additions & 4 deletions src/systems/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ pub fn create_webviews(
),
Without<Initialized>,
>,
primary_window_entity: Query<Entity, With<PrimaryWindow>>,
primary_window_entity: Single<Entity, With<PrimaryWindow>>,
winit_windows: NonSend<WinitWindows>,
) {
let primary_window = primary_window_entity.single();
let primary_window = primary_window_entity.into_inner();
let primary_window = winit_windows.get_window(primary_window).unwrap();
let window_size = primary_window.inner_size();
let scale_factor = primary_window.scale_factor();
Expand Down Expand Up @@ -68,11 +68,11 @@ pub fn create_webviews(

pub fn keep_webviews_in_bounds(
webviews: NonSendMut<WebViews>,
primary_window_entity: Query<Entity, With<PrimaryWindow>>,
primary_window_entity: Single<Entity, With<PrimaryWindow>>,
winit_windows: NonSend<WinitWindows>,
webview_entities: Query<(&WebViewComponent, &Position, &Size, &Anchor), With<Initialized>>,
) {
let primary_window = primary_window_entity.single();
let primary_window = primary_window_entity.into_inner();
let winit_window = winit_windows.get_window(primary_window).unwrap();
let scale_factor = winit_window.scale_factor();
let window_size = winit_window.inner_size();
Expand Down