Upgrade to Blitz v0.2.0 (#4731)
* Bump Rust CI version to 1.88 Signed-off-by: Nico Burns <nico@nicoburns.com> * Upgrade to Blitz v0.2.0 Signed-off-by: Nico Burns <nico@nicoburns.com> * Native: enable clipboard and file_dialog support by default * Fix clippy errors Signed-off-by: Nico Burns <nico@nicoburns.com> * See if cargo update magically fixes build Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix compile err Signed-off-by: Nico Burns <nico@nicoburns.com> * Remove unused wasm-opt dep * Fix wgpu_child_window example Signed-off-by: Nico Burns <nico@nicoburns.com> * Update blitz-shell Signed-off-by: Nico Burns <nico@nicoburns.com> * cargo fmt Signed-off-by: Nico Burns <nico@nicoburns.com> * Allow clippy lint Signed-off-by: Nico Burns <nico@nicoburns.com> * CI: Bump pinned nightly version Signed-off-by: Nico Burns <nico@nicoburns.com> * Allow clippy lint in whole module Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix more clippy lints Signed-off-by: Nico Burns <nico@nicoburns.com> * Use Rust 1.90 for clippy Signed-off-by: Nico Burns <nico@nicoburns.com> * cargo update --ignore-rust-version * revert cargo updates Signed-off-by: Nico Burns <nico@nicoburns.com> * Revert another silly clippy lint --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
1 parent
0b1f2fc8c2
commit
9359446017
26 files changed
+1028
-806
No files matched your search
+14
-14
@@ -39,7 +39,7 @@ env:
|
||||
CARGO_TERM_COLOR: always
|
||||
CARGO_INCREMENTAL: 0 # todo(jon): cargo-cache wipes incremental artifacts, but we eventually want to cache them
|
||||
RUST_BACKTRACE: 1
|
||||
rust_nightly: nightly-2025-04-07
|
||||
rust_nightly: nightly-2025-10-05
|
||||
|
||||
jobs:
|
||||
check-msrv:
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: dtolnay/rust-toolchain@1.86.0
|
||||
- uses: dtolnay/rust-toolchain@1.88.0
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-all-crates: "true"
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
with:
|
||||
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
||||
version: 1.0
|
||||
- uses: dtolnay/rust-toolchain@1.86.0
|
||||
- uses: dtolnay/rust-toolchain@1.88.0
|
||||
with:
|
||||
components: rustfmt, clippy
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
with:
|
||||
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
||||
version: 1.0
|
||||
- uses: dtolnay/rust-toolchain@1.86.0
|
||||
- uses: dtolnay/rust-toolchain@1.88.0
|
||||
with:
|
||||
components: rustfmt, clippy
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: dtolnay/rust-toolchain@1.86.0
|
||||
- uses: dtolnay/rust-toolchain@1.88.0
|
||||
with:
|
||||
components: rustfmt
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
@@ -173,7 +173,7 @@ jobs:
|
||||
with:
|
||||
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
||||
version: 1.0
|
||||
- uses: dtolnay/rust-toolchain@1.86.0
|
||||
- uses: dtolnay/rust-toolchain@1.88.0
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-all-crates: "true"
|
||||
@@ -189,7 +189,7 @@ jobs:
|
||||
with:
|
||||
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
||||
version: 1.0
|
||||
- uses: dtolnay/rust-toolchain@1.86.0
|
||||
- uses: dtolnay/rust-toolchain@1.90.0
|
||||
with:
|
||||
components: rustfmt, clippy
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
@@ -281,7 +281,7 @@ jobs:
|
||||
- {
|
||||
target: aarch64-apple-darwin,
|
||||
os: macos-latest,
|
||||
toolchain: "1.86.0",
|
||||
toolchain: "1.88.0",
|
||||
cross: false,
|
||||
command: "test",
|
||||
args: "--all --tests",
|
||||
@@ -290,7 +290,7 @@ jobs:
|
||||
- {
|
||||
target: x86_64-apple-darwin,
|
||||
os: macos-13,
|
||||
toolchain: "1.86.0",
|
||||
toolchain: "1.88.0",
|
||||
cross: false,
|
||||
command: "test",
|
||||
args: "--all --tests",
|
||||
@@ -299,7 +299,7 @@ jobs:
|
||||
- {
|
||||
target: aarch64-apple-ios,
|
||||
os: macos-latest,
|
||||
toolchain: "1.86.0",
|
||||
toolchain: "1.88.0",
|
||||
cross: false,
|
||||
command: "build",
|
||||
args: "--package dioxus-desktop",
|
||||
@@ -308,7 +308,7 @@ jobs:
|
||||
- {
|
||||
target: aarch64-unknown-linux-gnu,
|
||||
os: blacksmith-4vcpu-ubuntu-2404-arm,
|
||||
toolchain: "1.86.0",
|
||||
toolchain: "1.88.0",
|
||||
cross: false,
|
||||
command: "build",
|
||||
args: "--all --tests",
|
||||
@@ -317,7 +317,7 @@ jobs:
|
||||
- {
|
||||
target: aarch64-linux-android,
|
||||
os: blacksmith-4vcpu-ubuntu-2404,
|
||||
toolchain: "1.86.0",
|
||||
toolchain: "1.88.0",
|
||||
cross: true,
|
||||
command: "build",
|
||||
args: "--package dioxus-desktop",
|
||||
@@ -327,7 +327,7 @@ jobs:
|
||||
# - {
|
||||
# target: x86_64-unknown-linux-gnu,
|
||||
# os: ubuntu-24.04,
|
||||
# toolchain: "1.86.0",
|
||||
# toolchain: "1.88.0",
|
||||
# cross: false,
|
||||
# command: "build",
|
||||
# args: "--all --tests",
|
||||
@@ -379,7 +379,7 @@ jobs:
|
||||
name: "cargo test | windows"
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: dtolnay/rust-toolchain@1.86.0
|
||||
- uses: dtolnay/rust-toolchain@1.88.0
|
||||
with:
|
||||
components: rustfmt, clippy
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
@@ -90,7 +90,7 @@ jobs:
|
||||
- name: Install stable
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: "1.86.0"
|
||||
toolchain: "1.88.0"
|
||||
targets: ${{ matrix.platform.target }}
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
Generated
+857
-679
File diff suppressed because it is too large.
Load diff
+42
-23
@@ -137,7 +137,7 @@ members = [
|
||||
"packages/playwright-tests/nested-suspense",
|
||||
"packages/playwright-tests/cli-optimization",
|
||||
"packages/playwright-tests/wasm-split-harness",
|
||||
"packages/playwright-tests/default-features-disabled"
|
||||
"packages/playwright-tests/default-features-disabled",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
@@ -172,8 +172,8 @@ dioxus-stores = { path = "packages/stores", version = "0.7.0-rc.0" }
|
||||
dioxus-stores-macro = { path = "packages/stores-macro", version = "0.7.0-rc.0" }
|
||||
dioxus-devtools = { path = "packages/devtools", version = "0.7.0-rc.0" }
|
||||
dioxus-devtools-types = { path = "packages/devtools-types", version = "0.7.0-rc.0" }
|
||||
dioxus-fullstack = { path = "packages/fullstack", version = "0.7.0-rc.0", default-features = false}
|
||||
dioxus-fullstack-core = { path = "packages/fullstack-core", version = "0.7.0-rc.0", default-features = false}
|
||||
dioxus-fullstack = { path = "packages/fullstack", version = "0.7.0-rc.0", default-features = false }
|
||||
dioxus-fullstack-core = { path = "packages/fullstack-core", version = "0.7.0-rc.0", default-features = false }
|
||||
dioxus-fullstack-macro = { path = "packages/fullstack-macro", version = "0.7.0-rc.0", default-features = false }
|
||||
dioxus-server = { path = "packages/fullstack-server", version = "0.7.0-rc.0" }
|
||||
dioxus-dx-wire-format = { path = "packages/dx-wire-format", version = "0.7.0-rc.0" }
|
||||
@@ -214,15 +214,19 @@ depinfo = { path = "packages/depinfo", version = "0.7.0-rc.0" }
|
||||
warnings = { version = "0.2.1" }
|
||||
|
||||
# blitz
|
||||
blitz-dom = { version = "0.1", default-features = false }
|
||||
blitz-net = { version = "0.1" }
|
||||
blitz-html = { version = "0.1" }
|
||||
blitz-paint = { version = "0.1" }
|
||||
blitz-traits = { version = "0.1" }
|
||||
blitz-shell = { version = "0.1", default-features = false }
|
||||
anyrender = { version = "0.5", default-features = false }
|
||||
anyrender_vello = { version = "0.5", default-features = false }
|
||||
wgpu = { version = "24.0" }
|
||||
blitz-dom = { version = "0.2", default-features = false }
|
||||
blitz-net = { version = "0.2" }
|
||||
blitz-html = { version = "0.2" }
|
||||
blitz-paint = { version = "0.2" }
|
||||
blitz-traits = { version = "0.2" }
|
||||
blitz-shell = { version = "0.2", default-features = false }
|
||||
anyrender = { version = "0.6", default-features = false }
|
||||
anyrender_vello = { version = "0.6", default-features = false }
|
||||
wgpu_context = { version = "0.1", default-features = false }
|
||||
wgpu = { version = "26.0" }
|
||||
vello = "0.6"
|
||||
bevy = "0.17"
|
||||
|
||||
|
||||
# a fork of pretty please for tests - let's get off of this if we can!
|
||||
prettier-please = { version = "0.3.0", features = ["verbatim"] }
|
||||
@@ -257,21 +261,26 @@ lru = "0.16.0"
|
||||
async-trait = "0.1.88"
|
||||
axum = { version = "0.8.4", default-features = false }
|
||||
axum-server = { version = "0.7.2", default-features = false }
|
||||
http-body = { version = "1.0"}
|
||||
http-body = { version = "1.0" }
|
||||
tower = "0.5.2"
|
||||
http = "1.3.1"
|
||||
notify = { version = "8.1.0" }
|
||||
tower-http = "0.6.6"
|
||||
hyper = "1.6.0"
|
||||
hyper-rustls = { version = "0.27.7", default-features = false, features = [
|
||||
"native-tokio",
|
||||
"http1",
|
||||
"http2",
|
||||
"tls12",
|
||||
"logging",
|
||||
"ring",
|
||||
"native-tokio",
|
||||
"http1",
|
||||
"http2",
|
||||
"tls12",
|
||||
"logging",
|
||||
"ring",
|
||||
] }
|
||||
rustls = { version = "0.23.28", default-features = false, features = [
|
||||
"logging",
|
||||
"std",
|
||||
"tls12",
|
||||
"ring",
|
||||
] }
|
||||
rustls = { version = "0.23.28", default-features = false, features = ["logging", "std", "tls12", "ring"] }
|
||||
serde_json = "1.0.140"
|
||||
serde = "1.0.219"
|
||||
syn = "2.0"
|
||||
@@ -310,7 +319,11 @@ digest = "0.10.7"
|
||||
sha2 = "0.10.9"
|
||||
walrus = { version = "0.23.3", features = ["parallel"] }
|
||||
id-arena = "2.2.1"
|
||||
async-compression = { version = "0.4", features = ["futures-io", "gzip", "brotli"] }
|
||||
async-compression = { version = "0.4", features = [
|
||||
"futures-io",
|
||||
"gzip",
|
||||
"brotli",
|
||||
] }
|
||||
getrandom = { version = "0.3.3" }
|
||||
async-once-cell = { version = "0.5.4" }
|
||||
rayon = "1.10.0"
|
||||
@@ -330,7 +343,7 @@ libloading = "0.8.8"
|
||||
libc = "0.2.174"
|
||||
memmap2 = "0.9.5"
|
||||
memfd = "0.6.4"
|
||||
xxhash-rust = {version = "0.8.15", default-features = false}
|
||||
xxhash-rust = { version = "0.8.15", default-features = false }
|
||||
serde_qs = "0.15.0"
|
||||
multer = "3.1.0"
|
||||
const-str = "0.7.0"
|
||||
@@ -469,7 +482,13 @@ uuid = { workspace = true, features = ["v4", "serde"] }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
||||
getrandom = { workspace = true, features = ["wasm_js"] }
|
||||
tokio = { version = "1.46", default-features = false, features = ["sync", "macros", "io-util", "rt", "time"] }
|
||||
tokio = { version = "1.46", default-features = false, features = [
|
||||
"sync",
|
||||
"macros",
|
||||
"io-util",
|
||||
"rt",
|
||||
"time",
|
||||
] }
|
||||
uuid = { workspace = true, features = ["v4", "serde", "js"] }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||
|
||||
@@ -118,17 +118,15 @@ impl<'a> GraphicsResources<'a> {
|
||||
|
||||
// Create the logical device and command queue
|
||||
let (device, queue) = adapter
|
||||
.request_device(
|
||||
&wgpu::DeviceDescriptor {
|
||||
label: None,
|
||||
required_features: wgpu::Features::empty(),
|
||||
// Make sure we use the texture resolution limits from the adapter, so we can support images the size of the swapchain.
|
||||
required_limits: wgpu::Limits::downlevel_webgl2_defaults()
|
||||
.using_resolution(adapter.limits()),
|
||||
memory_hints: wgpu::MemoryHints::default(),
|
||||
},
|
||||
None,
|
||||
)
|
||||
.request_device(&wgpu::DeviceDescriptor {
|
||||
label: None,
|
||||
required_features: wgpu::Features::empty(),
|
||||
// Make sure we use the texture resolution limits from the adapter, so we can support images the size of the swapchain.
|
||||
required_limits: wgpu::Limits::downlevel_webgl2_defaults()
|
||||
.using_resolution(adapter.limits()),
|
||||
memory_hints: wgpu::MemoryHints::default(),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.expect("Failed to create device");
|
||||
|
||||
@@ -235,6 +233,7 @@ fn fs_main() -> @location(0) vec4<f32> {
|
||||
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
|
||||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
depth_slice: None,
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
timestamp_writes: None,
|
||||
|
||||
@@ -12,7 +12,7 @@ native = ["dioxus/native"]
|
||||
tracing = ["dep:tracing-subscriber", "dioxus-native/tracing"]
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.16" }
|
||||
bevy = { workspace = true }
|
||||
dioxus-native = { workspace = true }
|
||||
dioxus = { workspace = true }
|
||||
wgpu = { workspace = true }
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
use crate::bevy_scene_plugin::BevyScenePlugin;
|
||||
use bevy::{
|
||||
camera::{ManualTextureViewHandle, RenderTarget},
|
||||
prelude::*,
|
||||
render::{
|
||||
camera::{ManualTextureView, ManualTextureViewHandle, ManualTextureViews, RenderTarget},
|
||||
render_resource::TextureFormat,
|
||||
renderer::{
|
||||
RenderAdapter, RenderAdapterInfo, RenderDevice, RenderInstance, RenderQueue,
|
||||
WgpuWrapper,
|
||||
},
|
||||
settings::{RenderCreation, RenderResources},
|
||||
texture::ManualTextureView,
|
||||
RenderPlugin,
|
||||
},
|
||||
};
|
||||
use dioxus_native::{CustomPaintCtx, DeviceHandle, TextureHandle};
|
||||
use std::sync::Arc;
|
||||
use wgpu::Instance;
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct UIData {
|
||||
@@ -30,7 +30,7 @@ pub struct BevyRenderer {
|
||||
}
|
||||
|
||||
impl BevyRenderer {
|
||||
pub fn new(instance: &Instance, device_handle: &DeviceHandle) -> Self {
|
||||
pub fn new(device_handle: &DeviceHandle) -> Self {
|
||||
// Create a headless Bevy App.
|
||||
let mut app = App::new();
|
||||
app.add_plugins(
|
||||
@@ -42,7 +42,7 @@ impl BevyRenderer {
|
||||
RenderQueue(Arc::new(WgpuWrapper::new(device_handle.queue.clone()))),
|
||||
RenderAdapterInfo(WgpuWrapper::new(device_handle.adapter.get_info())),
|
||||
RenderAdapter(Arc::new(WgpuWrapper::new(device_handle.adapter.clone()))),
|
||||
RenderInstance(Arc::new(WgpuWrapper::new(instance.clone()))),
|
||||
RenderInstance(Arc::new(WgpuWrapper::new(device_handle.instance.clone()))),
|
||||
)),
|
||||
synchronous_pipeline_compilation: true,
|
||||
..default()
|
||||
@@ -51,6 +51,7 @@ impl BevyRenderer {
|
||||
primary_window: None,
|
||||
exit_condition: bevy::window::ExitCondition::DontExit,
|
||||
close_when_requested: false,
|
||||
..Default::default()
|
||||
})
|
||||
.disable::<bevy::winit::WinitPlugin>(),
|
||||
);
|
||||
@@ -95,7 +96,7 @@ impl BevyRenderer {
|
||||
// Run one frame of the Bevy app to render the 3D scene.
|
||||
self.app.update();
|
||||
|
||||
self.texture_handle
|
||||
self.texture_handle.clone()
|
||||
}
|
||||
|
||||
fn init_texture(&mut self, mut ctx: CustomPaintCtx<'_>, width: u32, height: u32) {
|
||||
@@ -114,9 +115,8 @@ impl BevyRenderer {
|
||||
|
||||
if let Some(mut manual_texture_views) = world.get_resource_mut::<ManualTextureViews>() {
|
||||
// Clean previous texture if any.
|
||||
if let Some(texture_handle) = self.texture_handle {
|
||||
ctx.unregister_texture(texture_handle);
|
||||
self.texture_handle = None;
|
||||
if self.texture_handle.is_some() {
|
||||
ctx.unregister_texture(self.texture_handle.take().unwrap());
|
||||
}
|
||||
if let Some(old_handle) = self.manual_texture_view_handle {
|
||||
manual_texture_views.remove(&old_handle);
|
||||
|
||||
@@ -2,7 +2,6 @@ use crate::bevy_renderer::BevyRenderer;
|
||||
use crate::Color;
|
||||
use dioxus_native::{CustomPaintCtx, CustomPaintSource, DeviceHandle, TextureHandle};
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
use wgpu::Instance;
|
||||
|
||||
pub enum DemoMessage {
|
||||
// Color in RGB format
|
||||
@@ -71,8 +70,8 @@ impl DemoPaintSource {
|
||||
}
|
||||
|
||||
impl CustomPaintSource for DemoPaintSource {
|
||||
fn resume(&mut self, instance: &Instance, device_handle: &DeviceHandle) {
|
||||
let active_state = BevyRenderer::new(instance, device_handle);
|
||||
fn resume(&mut self, device_handle: &DeviceHandle) {
|
||||
let active_state = BevyRenderer::new(device_handle);
|
||||
self.state = DemoRendererState::Active(Box::new(active_state));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ blitz-traits = { workspace = true, default-features = true }
|
||||
anyrender_vello = { workspace = true }
|
||||
wgpu = { workspace = true }
|
||||
tracing-subscriber = { workspace = true, optional = true }
|
||||
bevy = { version = "0.16" }
|
||||
bevy = { workspace = true }
|
||||
vello = { workspace = true }
|
||||
async-std = "1.13"
|
||||
crossbeam-channel = "0.5"
|
||||
paste = "1.0"
|
||||
rustc-hash = "1"
|
||||
vello = "0.5"
|
||||
|
||||
@@ -155,7 +155,7 @@ fn animate(
|
||||
|
||||
fn orbit_camera_system(
|
||||
mut camera_query: Query<(&mut Transform, &mut OrbitCamera), With<Camera3d>>,
|
||||
mut mouse_motion_events: EventReader<MouseMotion>,
|
||||
mut mouse_motion_events: MessageReader<MouseMotion>,
|
||||
mouse_button_input: Res<ButtonInput<MouseButton>>,
|
||||
) {
|
||||
for (mut transform, mut orbit_camera) in camera_query.iter_mut() {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
use std::time::Instant;
|
||||
|
||||
use bevy::asset::RenderAssetUsages;
|
||||
use bevy::prelude::*;
|
||||
use bevy::{
|
||||
input::{
|
||||
keyboard::{Key as BevyKey, KeyCode as BevyKeyCode, KeyboardInput},
|
||||
mouse::{MouseButton, MouseButtonInput},
|
||||
ButtonInput, ButtonState, InputSystem,
|
||||
ButtonInput, ButtonState, InputSystems,
|
||||
},
|
||||
render::{
|
||||
render_asset::{RenderAssetUsages, RenderAssets},
|
||||
render_asset::RenderAssets,
|
||||
render_graph::{self, NodeRunError, RenderGraph, RenderGraphContext, RenderLabel},
|
||||
render_resource::{Extent3d, TextureDimension, TextureFormat},
|
||||
renderer::{RenderContext, RenderDevice, RenderQueue},
|
||||
@@ -16,7 +19,7 @@ use bevy::{
|
||||
window::{CursorMoved, WindowResized},
|
||||
};
|
||||
|
||||
use anyrender_vello::{CustomPaintSource, VelloScenePainter};
|
||||
use anyrender_vello::VelloScenePainter;
|
||||
use blitz_dom::{Document as _, DocumentConfig};
|
||||
use blitz_paint::paint_scene;
|
||||
use blitz_traits::events::{
|
||||
@@ -26,7 +29,6 @@ use blitz_traits::shell::{ColorScheme, Viewport};
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_native_dom::DioxusDocument;
|
||||
use rustc_hash::FxHashMap;
|
||||
use vello::{
|
||||
peniko::color::AlphaColor, RenderParams, Renderer as VelloRenderer, RendererOptions, Scene,
|
||||
};
|
||||
@@ -41,17 +43,22 @@ pub struct DioxusInBevyPlugin<UIProps> {
|
||||
pub props: UIProps,
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
struct AnimationTime(Instant);
|
||||
|
||||
impl<UIProps: std::marker::Send + std::marker::Sync + std::clone::Clone + 'static> Plugin
|
||||
for DioxusInBevyPlugin<UIProps>
|
||||
{
|
||||
fn build(&self, app: &mut App) {
|
||||
let epoch = AnimationTime(Instant::now());
|
||||
|
||||
// Create the dioxus virtual dom and the dioxus-native document
|
||||
// The viewport will be set in setup_ui after we get the window size
|
||||
let vdom = VirtualDom::new_with_props(self.ui, self.props.clone());
|
||||
// FIXME add a NetProvider
|
||||
let mut dioxus_doc = DioxusDocument::new(vdom, DocumentConfig::default());
|
||||
dioxus_doc.initial_build();
|
||||
dioxus_doc.resolve();
|
||||
dioxus_doc.resolve(0.0);
|
||||
|
||||
// Dummy waker
|
||||
struct NullWake;
|
||||
@@ -62,13 +69,14 @@ impl<UIProps: std::marker::Send + std::marker::Sync + std::clone::Clone + 'stati
|
||||
|
||||
app.insert_non_send_resource(dioxus_doc);
|
||||
app.insert_non_send_resource(waker);
|
||||
app.insert_resource(epoch);
|
||||
app.add_systems(Startup, setup_ui);
|
||||
app.add_systems(
|
||||
PreUpdate,
|
||||
(
|
||||
handle_window_resize,
|
||||
handle_mouse_events.after(InputSystem),
|
||||
handle_keyboard_events.after(InputSystem),
|
||||
handle_mouse_events.after(InputSystems),
|
||||
handle_keyboard_events.after(InputSystems),
|
||||
)
|
||||
.chain(),
|
||||
);
|
||||
@@ -202,6 +210,7 @@ fn setup_ui(
|
||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||
mut images: ResMut<Assets<Image>>,
|
||||
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
||||
mut animation_epoch: ResMut<AnimationTime>,
|
||||
windows: Query<&Window>,
|
||||
) {
|
||||
let window = windows
|
||||
@@ -214,8 +223,9 @@ fn setup_ui(
|
||||
debug!("Initial window size: {}x{}", width, height);
|
||||
|
||||
// Set the initial viewport
|
||||
animation_epoch.0 = Instant::now();
|
||||
dioxus_doc.set_viewport(Viewport::new(width, height, SCALE_FACTOR, COLOR_SCHEME));
|
||||
dioxus_doc.resolve();
|
||||
dioxus_doc.resolve(0.0);
|
||||
|
||||
// Create Bevy Image from the texture data
|
||||
let image = create_ui_texture(width, height);
|
||||
@@ -242,6 +252,7 @@ fn setup_ui(
|
||||
commands.insert_resource(TextureImage(handle));
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn update_ui(
|
||||
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
||||
waker: NonSendMut<std::task::Waker>,
|
||||
@@ -249,6 +260,7 @@ fn update_ui(
|
||||
render_device: Res<RenderDevice>,
|
||||
render_queue: Res<RenderQueue>,
|
||||
receiver: Res<MainWorldReceiver>,
|
||||
animation_epoch: Res<AnimationTime>,
|
||||
mut cached_texture: Local<Option<RenderTexture>>,
|
||||
) {
|
||||
while let Ok(texture) = receiver.try_recv() {
|
||||
@@ -261,29 +273,21 @@ fn update_ui(
|
||||
dioxus_doc.poll(Some(std::task::Context::from_waker(&waker)));
|
||||
|
||||
// Refresh the document
|
||||
dioxus_doc.resolve();
|
||||
let animation_time = animation_epoch.0.elapsed().as_secs_f64();
|
||||
dioxus_doc.resolve(animation_time);
|
||||
|
||||
// Create a `VelloScenePainter` to paint into
|
||||
let mut custom_paint_sources =
|
||||
FxHashMap::<u64, Box<dyn CustomPaintSource + 'static>>::default();
|
||||
let mut scene_painter = VelloScenePainter {
|
||||
inner: Scene::new(),
|
||||
renderer: &mut vello_renderer,
|
||||
custom_paint_sources: &mut custom_paint_sources,
|
||||
};
|
||||
// Create a `vello::Scene` to paint into
|
||||
let mut scene = Scene::new();
|
||||
|
||||
// Paint the document
|
||||
paint_scene(
|
||||
&mut scene_painter,
|
||||
&mut VelloScenePainter::new(&mut scene),
|
||||
&dioxus_doc,
|
||||
SCALE_FACTOR as f64,
|
||||
texture.width,
|
||||
texture.height,
|
||||
);
|
||||
|
||||
// Extract the `vello::Scene` from the `VelloScenePainter`
|
||||
let scene = scene_painter.finish();
|
||||
|
||||
// Render the `vello::Scene` to the Texture using the `VelloRenderer`
|
||||
vello_renderer
|
||||
.render_to_texture(
|
||||
@@ -304,7 +308,7 @@ fn update_ui(
|
||||
|
||||
fn handle_window_resize(
|
||||
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
||||
mut resize_events: EventReader<WindowResized>,
|
||||
mut resize_events: MessageReader<WindowResized>,
|
||||
mut commands: Commands,
|
||||
mut images: ResMut<Assets<Image>>,
|
||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||
@@ -319,7 +323,7 @@ fn handle_window_resize(
|
||||
|
||||
// Update the dioxus viewport
|
||||
dioxus_doc.set_viewport(Viewport::new(width, height, SCALE_FACTOR, COLOR_SCHEME));
|
||||
dioxus_doc.resolve();
|
||||
// dioxus_doc.resolve();
|
||||
|
||||
// Create a new texture with the new size
|
||||
let new_image = create_ui_texture(width, height);
|
||||
@@ -369,8 +373,8 @@ fn does_catch_events(dioxus_doc: &DioxusDocument, node_id: usize) -> bool {
|
||||
|
||||
fn handle_mouse_events(
|
||||
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
||||
mut cursor_moved: EventReader<CursorMoved>,
|
||||
mut mouse_button_input_events: ResMut<Events<MouseButtonInput>>,
|
||||
mut cursor_moved: MessageReader<CursorMoved>,
|
||||
mut mouse_button_input_events: ResMut<Messages<MouseButtonInput>>,
|
||||
mut mouse_buttons: ResMut<ButtonInput<MouseButton>>,
|
||||
mut last_mouse_state: Local<MouseState>,
|
||||
) {
|
||||
@@ -438,12 +442,12 @@ fn handle_mouse_events(
|
||||
mouse_buttons.reset_all();
|
||||
}
|
||||
|
||||
dioxus_doc.resolve();
|
||||
// dioxus_doc.resolve();
|
||||
}
|
||||
|
||||
fn handle_keyboard_events(
|
||||
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
||||
mut keyboard_input_events: ResMut<Events<KeyboardInput>>,
|
||||
mut keyboard_input_events: ResMut<Messages<KeyboardInput>>,
|
||||
mut keys: ResMut<ButtonInput<BevyKeyCode>>,
|
||||
mut last_mouse_state: Local<MouseState>,
|
||||
) {
|
||||
@@ -512,7 +516,7 @@ fn handle_keyboard_events(
|
||||
keys.reset_all();
|
||||
}
|
||||
|
||||
dioxus_doc.resolve();
|
||||
// dioxus_doc.resolve();
|
||||
}
|
||||
|
||||
fn bevy_key_to_blitz_key(key: &BevyKey) -> Key {
|
||||
|
||||
@@ -62,6 +62,17 @@ html, body, #main {
|
||||
background-color: blue;
|
||||
}
|
||||
|
||||
.spin-box {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
animation: spin 4s infinite linear;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
from { transform:rotate(0deg); }
|
||||
to { transform:rotate(360deg); }
|
||||
}
|
||||
|
||||
#translation-speed-control, #rotation-speed-control {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
@@ -104,6 +104,11 @@ pub fn ui(props: UIProps) -> Element {
|
||||
}
|
||||
});
|
||||
|
||||
let color = *state.cube_color.read();
|
||||
let [r, g, b, a] = color.map(|c| (c * 255.0) as u8);
|
||||
|
||||
println!("rgba({r}, {g}, {b}, {a})");
|
||||
|
||||
rsx! {
|
||||
style { {include_str!("./ui.css")} }
|
||||
div {
|
||||
@@ -163,6 +168,16 @@ pub fn ui(props: UIProps) -> Element {
|
||||
}
|
||||
}
|
||||
}
|
||||
div {
|
||||
flex: "0 0 150px",
|
||||
display: "grid",
|
||||
align_items: "center",
|
||||
justify_items: "center",
|
||||
div {
|
||||
class: "spin-box",
|
||||
background: "rgba({r}, {g}, {b}, {a}",
|
||||
}
|
||||
}
|
||||
div {
|
||||
id: "footer",
|
||||
p { "Bevy framerate: {state.fps}" }
|
||||
|
||||
@@ -12,11 +12,12 @@ tracing = ["dep:tracing-subscriber", "dioxus-native-dom/tracing"]
|
||||
dioxus = { workspace = true, features = ["html", "hooks", "signals"] }
|
||||
dioxus-native-dom = { workspace = true }
|
||||
anyrender_vello = { workspace = true }
|
||||
vello = "0.5"
|
||||
vello = { workspace = true }
|
||||
rustc-hash = "1"
|
||||
futures-util = { workspace = true }
|
||||
tracing-subscriber = { workspace = true, optional = true }
|
||||
wgpu = { workspace = true }
|
||||
wgpu_context = { workspace = true }
|
||||
pollster = "0.4"
|
||||
bytemuck = "1"
|
||||
blitz-paint = { workspace = true, default-features = true }
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//!
|
||||
//! (this example is not really intended to be run as-is, and requires you to fill
|
||||
//! in the missing pieces)
|
||||
use anyrender_vello::{wgpu_context::WGPUContext, CustomPaintSource, VelloScenePainter};
|
||||
use anyrender_vello::VelloScenePainter;
|
||||
use blitz_dom::{Document as _, DocumentConfig};
|
||||
use blitz_paint::paint_scene;
|
||||
use blitz_traits::{
|
||||
@@ -13,13 +13,13 @@ use blitz_traits::{
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_native_dom::DioxusDocument;
|
||||
use pollster::FutureExt as _;
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::sync::Arc;
|
||||
use std::task::Context;
|
||||
use vello::{
|
||||
peniko::color::AlphaColor, RenderParams, Renderer as VelloRenderer, RendererOptions, Scene,
|
||||
};
|
||||
use wgpu::TextureFormat;
|
||||
use wgpu_context::WGPUContext;
|
||||
|
||||
// Constant width, height, scale factor and color schemefor example purposes
|
||||
const SCALE_FACTOR: f32 = 1.0;
|
||||
@@ -102,14 +102,8 @@ fn main() {
|
||||
// Poll the vdom
|
||||
dioxus_doc.poll(Some(Context::from_waker(&waker)));
|
||||
|
||||
// Create a `VelloScenePainter` to paint into
|
||||
let mut custom_paint_sources =
|
||||
FxHashMap::<u64, Box<dyn CustomPaintSource + 'static>>::default();
|
||||
let mut scene_painter = VelloScenePainter {
|
||||
inner: Scene::new(),
|
||||
renderer: &mut vello_renderer,
|
||||
custom_paint_sources: &mut custom_paint_sources,
|
||||
};
|
||||
// Create a `vello::Scene` to paint into
|
||||
let mut scene = Scene::new();
|
||||
|
||||
// Paint the document using `blitz_paint::paint_scene`
|
||||
//
|
||||
@@ -117,16 +111,13 @@ fn main() {
|
||||
// so you could also write your own implementation if you want more control over rendering
|
||||
// (i.e. to render a custom renderer instead of Vello)
|
||||
paint_scene(
|
||||
&mut scene_painter,
|
||||
&mut VelloScenePainter::new(&mut scene),
|
||||
&dioxus_doc,
|
||||
SCALE_FACTOR as f64,
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
);
|
||||
|
||||
// Extract the `vello::Scene` from the `VelloScenePainter`
|
||||
let scene = scene_painter.finish();
|
||||
|
||||
// Render the `vello::Scene` to the Texture using the `VelloRenderer`
|
||||
vello_renderer
|
||||
.render_to_texture(
|
||||
|
||||
@@ -5,7 +5,7 @@ use dioxus_native::{CustomPaintCtx, CustomPaintSource, DeviceHandle, TextureHand
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
use std::time::Instant;
|
||||
use wgpu::{
|
||||
CommandEncoderDescriptor, Device, Extent3d, FragmentState, Instance, LoadOp, MultisampleState,
|
||||
CommandEncoderDescriptor, Device, Extent3d, FragmentState, LoadOp, MultisampleState,
|
||||
Operations, PipelineLayoutDescriptor, PrimitiveState, PushConstantRange, Queue,
|
||||
RenderPassColorAttachment, RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor,
|
||||
ShaderModuleDescriptor, ShaderSource, ShaderStages, StoreOp, Texture, TextureDescriptor,
|
||||
@@ -21,7 +21,7 @@ pub struct DemoPaintSource {
|
||||
}
|
||||
|
||||
impl CustomPaintSource for DemoPaintSource {
|
||||
fn resume(&mut self, _instance: &Instance, device_handle: &DeviceHandle) {
|
||||
fn resume(&mut self, device_handle: &DeviceHandle) {
|
||||
// Extract device and queue from device_handle
|
||||
let device = &device_handle.device;
|
||||
let queue = &device_handle.queue;
|
||||
@@ -175,8 +175,7 @@ impl ActiveDemoRenderer {
|
||||
// If "next texture" size doesn't match specified size then unregister and drop texture
|
||||
if let Some(next) = &self.next_texture {
|
||||
if next.texture.width() != width || next.texture.height() != height {
|
||||
ctx.unregister_texture(next.handle);
|
||||
self.next_texture = None;
|
||||
ctx.unregister_texture(self.next_texture.take().unwrap().handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +191,7 @@ impl ActiveDemoRenderer {
|
||||
};
|
||||
|
||||
let next_texture = &texture_and_handle.texture;
|
||||
let next_texture_handle = texture_and_handle.handle;
|
||||
let next_texture_handle = texture_and_handle.handle.clone();
|
||||
|
||||
let elapsed: f32 = start_time.elapsed().as_millis() as f32 / 500.;
|
||||
let [light_red, light_green, light_blue] = light;
|
||||
@@ -213,6 +212,7 @@ impl ActiveDemoRenderer {
|
||||
load: LoadOp::Clear(wgpu::Color::GREEN),
|
||||
store: StoreOp::Store,
|
||||
},
|
||||
depth_slice: None,
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
timestamp_writes: None,
|
||||
|
||||
@@ -211,6 +211,7 @@ body {
|
||||
padding: 15px 15px 15px 60px;
|
||||
display: block;
|
||||
line-height: 1.2;
|
||||
transition: color 0.4s;
|
||||
}
|
||||
|
||||
.todo-list li.completed label {
|
||||
@@ -230,6 +231,7 @@ body {
|
||||
font-size: 30px;
|
||||
color: #cc9a9a;
|
||||
margin-bottom: 11px;
|
||||
transition: color 0.2s ease-out;
|
||||
}
|
||||
|
||||
.todo-list li .destroy:hover {
|
||||
|
||||
@@ -106,7 +106,6 @@ tracing-subscriber = { version = "0.3.19", features = [
|
||||
] }
|
||||
console-subscriber = { version = "0.4.1", optional = true }
|
||||
tracing = { workspace = true }
|
||||
wasm-opt = { version = "0.116.1", optional = true }
|
||||
ansi-to-tui = { workspace = true }
|
||||
ansi-to-html = { workspace = true }
|
||||
path-absolutize = { workspace = true }
|
||||
|
||||
@@ -98,6 +98,7 @@ fn merge_profiles(target: &mut Profiles, new: Profiles) {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
if let Some(new_doc) = new.doc {
|
||||
if target.doc.is_none() {
|
||||
target.doc = Some(new_doc);
|
||||
|
||||
@@ -193,11 +193,7 @@ pub(crate) fn post_create(path: &Path, vcs: &Vcs) -> Result<()> {
|
||||
};
|
||||
|
||||
let mut toml = toml.parse::<toml_edit::DocumentMut>().map_err(|e| {
|
||||
anyhow::anyhow!(
|
||||
"failed to parse toml at {}: {}",
|
||||
toml_path.display(),
|
||||
e.to_string()
|
||||
)
|
||||
anyhow::anyhow!("failed to parse toml at {}: {}", toml_path.display(), e)
|
||||
})?;
|
||||
|
||||
toml.as_table_mut().fmt();
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::IncrementalRendererConfig;
|
||||
pub(crate) type ContextProviders =
|
||||
Arc<Vec<Box<dyn Fn() -> Box<dyn std::any::Any> + Send + Sync + 'static>>>;
|
||||
|
||||
/// A ServeConfig is used to configure how to serve a Dioxus application. It contains information about how to serve static assets, and what content to render with [`dioxus-ssr`].
|
||||
/// A ServeConfig is used to configure how to serve a Dioxus application. It contains information about how to serve static assets, and what content to render with [`dioxus_ssr`].
|
||||
#[derive(Clone, Default)]
|
||||
pub struct ServeConfigBuilder {
|
||||
pub(crate) root_id: Option<&'static str>,
|
||||
@@ -491,7 +491,7 @@ pub enum StreamingMode {
|
||||
OutOfOrder,
|
||||
}
|
||||
|
||||
/// Used to configure how to serve a Dioxus application. It contains information about how to serve static assets, and what content to render with [`dioxus-ssr`].
|
||||
/// Used to configure how to serve a Dioxus application. It contains information about how to serve static assets, and what content to render with [`dioxus_ssr`].
|
||||
/// See [`ServeConfigBuilder`] to create a ServeConfig
|
||||
#[derive(Clone)]
|
||||
pub struct ServeConfig {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
//! Generational box errors
|
||||
#![allow(clippy::uninlined_format_args, reason = "causes compile error")]
|
||||
|
||||
use std::error::Error;
|
||||
use std::fmt::Debug;
|
||||
use std::fmt::Display;
|
||||
|
||||
@@ -34,7 +34,7 @@ pub(crate) enum RwLockStorageEntryData {
|
||||
impl Debug for RwLockStorageEntryData {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Reference(location) => write!(f, "Reference({:?})", location),
|
||||
Self::Reference(location) => write!(f, "Reference({location:?})"),
|
||||
Self::Rc(_) => write!(f, "Rc"),
|
||||
Self::Data(_) => write!(f, "Data"),
|
||||
Self::Empty => write!(f, "Empty"),
|
||||
|
||||
@@ -10,7 +10,9 @@ homepage = "https://dioxuslabs.com/learn/0.6/getting_started"
|
||||
keywords = ["dom", "ui", "gui", "react"]
|
||||
|
||||
[features]
|
||||
default = ["accessibility", "hot-reload", "tracing", "net", "html", "svg", "system-fonts"]
|
||||
default = ["accessibility", "hot-reload", "tracing", "net", "html", "svg", "system-fonts", "clipboard", "file_dialog"]
|
||||
clipboard = ["blitz-shell/clipboard"]
|
||||
file_dialog = ["blitz-shell/file_dialog"]
|
||||
svg = ["blitz-dom/svg", "blitz-paint/svg"]
|
||||
net = ["dep:tokio", "dep:blitz-net"]
|
||||
html = ["dep:blitz-html"]
|
||||
|
||||
@@ -6,7 +6,7 @@ use anyrender::WindowRenderer;
|
||||
|
||||
pub use anyrender_vello::{
|
||||
wgpu::{Features, Limits},
|
||||
CustomPaintSource, VelloWindowRenderer as InnerRenderer,
|
||||
CustomPaintSource, VelloRendererOptions, VelloWindowRenderer as InnerRenderer,
|
||||
};
|
||||
|
||||
pub fn use_wgpu<T: CustomPaintSource>(create_source: impl FnOnce() -> T) -> u64 {
|
||||
@@ -45,7 +45,11 @@ impl DioxusNativeWindowRenderer {
|
||||
}
|
||||
|
||||
pub fn with_features_and_limits(features: Option<Features>, limits: Option<Limits>) -> Self {
|
||||
let vello_renderer = InnerRenderer::with_features_and_limits(features, limits);
|
||||
let vello_renderer = InnerRenderer::with_options(VelloRendererOptions {
|
||||
features,
|
||||
limits,
|
||||
..Default::default()
|
||||
});
|
||||
Self::with_inner_renderer(vello_renderer)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,7 @@ mod link_handler;
|
||||
#[doc(inline)]
|
||||
pub use dioxus_native_dom::*;
|
||||
|
||||
pub use anyrender_vello::{
|
||||
wgpu_context::DeviceHandle, CustomPaintCtx, CustomPaintSource, TextureHandle,
|
||||
};
|
||||
pub use anyrender_vello::{CustomPaintCtx, CustomPaintSource, DeviceHandle, TextureHandle};
|
||||
use assets::DioxusNativeNetProvider;
|
||||
pub use dioxus_application::{DioxusNativeApplication, DioxusNativeEvent};
|
||||
pub use dioxus_renderer::{use_wgpu, DioxusNativeWindowRenderer, Features, Limits};
|
||||
|
||||
Reference in new issue
Block a user