Use nightly rustfmt to format imports (#838)

This commit is contained in:
Olivier FAURE 2025-01-20 13:19:26 +00:00 committed by GitHub
parent fc0acae98e
commit 066d4319e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
43 changed files with 211 additions and 238 deletions

View File

@ -11,10 +11,10 @@
//! will use an arena and unsafe code, but should have the exact same exported API as //! will use an arena and unsafe code, but should have the exact same exported API as
//! this module. //! this module.
use super::NodeId;
use hashbrown::HashMap; use hashbrown::HashMap;
use crate::NodeId;
#[derive(Debug)] #[derive(Debug)]
struct TreeNode<T> { struct TreeNode<T> {
id: NodeId, id: NodeId,

View File

@ -2,12 +2,12 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#![allow(unsafe_code, reason = "Purpose is unsafe abstraction")] #![allow(unsafe_code, reason = "Purpose is unsafe abstraction")]
use super::NodeId;
use std::cell::UnsafeCell; use std::cell::UnsafeCell;
use hashbrown::HashMap; use hashbrown::HashMap;
use crate::NodeId;
#[derive(Debug)] #[derive(Debug)]
struct TreeNode<T> { struct TreeNode<T> {
item: T, item: T,

View File

@ -6,12 +6,11 @@
#![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")] #![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")]
use winit::error::EventLoopError; use winit::error::EventLoopError;
use xilem::{ use xilem::core::map_state;
core::map_state, use xilem::view::{
palette, button, flex, grid, label, prose, sized_box, Axis, FlexExt, FlexSpacer, GridExt,
view::{button, flex, grid, label, prose, sized_box, Axis, FlexExt, FlexSpacer, GridExt},
Color, EventLoop, EventLoopBuilder, WidgetView, Xilem,
}; };
use xilem::{palette, Color, EventLoop, EventLoopBuilder, WidgetView, Xilem};
fn app_logic(data: &mut EmojiPagination) -> impl WidgetView<EmojiPagination> { fn app_logic(data: &mut EmojiPagination) -> impl WidgetView<EmojiPagination> {
flex(( flex((

View File

@ -3,10 +3,8 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use crate::{ use crate::core::{DynMessage, View, ViewMarker};
core::{DynMessage, View, ViewMarker}, use crate::{Affine, Pod, ViewCtx, WidgetView};
Affine, Pod, ViewCtx, WidgetView,
};
/// A view which transforms the widget created by child. /// A view which transforms the widget created by child.
/// ///

View File

@ -7,11 +7,10 @@ use masonry::{widget, TextAlignment};
use vello::peniko::Brush; use vello::peniko::Brush;
use xilem_core::ViewPathTracker; use xilem_core::ViewPathTracker;
use super::{label, Label};
use crate::core::{DynMessage, Mut, ViewMarker}; use crate::core::{DynMessage, Mut, ViewMarker};
use crate::{MessageResult, Pod, View, ViewCtx, ViewId}; use crate::{MessageResult, Pod, View, ViewCtx, ViewId};
use super::{label, Label};
/// A view for displaying non-editable text, with a variable [weight](masonry::parley::style::FontWeight). /// A view for displaying non-editable text, with a variable [weight](masonry::parley::style::FontWeight).
pub fn variable_label(text: impl Into<ArcStr>) -> VariableLabel { pub fn variable_label(text: impl Into<ArcStr>) -> VariableLabel {
VariableLabel { VariableLabel {

View File

@ -5,18 +5,15 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use crate::{ use masonry::widget::{self, Alignment, ChildAlignment, WidgetMut};
core::{ use masonry::{FromDynWidget, Widget};
use xilem_core::{MessageResult, ViewId};
use crate::core::{
AppendVec, DynMessage, ElementSplice, Mut, SuperElement, View, ViewElement, ViewMarker, AppendVec, DynMessage, ElementSplice, Mut, SuperElement, View, ViewElement, ViewMarker,
ViewSequence, ViewSequence,
},
Pod, ViewCtx, WidgetView,
}; };
use masonry::{ use crate::{Pod, ViewCtx, WidgetView};
widget::{self, Alignment, ChildAlignment, WidgetMut},
FromDynWidget, Widget,
};
use xilem_core::{MessageResult, ViewId};
/// A widget that lays out its children on top of each other. /// A widget that lays out its children on top of each other.
/// The children are laid out back to front. /// The children are laid out back to front.

View File

@ -1,7 +1,8 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use core::{fmt::Debug, marker::PhantomData}; use core::fmt::Debug;
use core::marker::PhantomData;
use crate::{Mut, View, ViewId, ViewMarker, ViewPathTracker}; use crate::{Mut, View, ViewId, ViewMarker, ViewPathTracker};

View File

@ -1,7 +1,8 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use core::{fmt::Debug, marker::PhantomData}; use core::fmt::Debug;
use core::marker::PhantomData;
use crate::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker}; use crate::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker};

View File

@ -1,8 +1,9 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use core::fmt::Debug;
use core::marker::PhantomData;
use core::mem::size_of; use core::mem::size_of;
use core::{fmt::Debug, marker::PhantomData};
use crate::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker}; use crate::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker};

View File

@ -3,10 +3,8 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use crate::{ use crate::core::{MessageResult, Mut, View, ViewId, ViewMarker};
core::{MessageResult, Mut, View, ViewId, ViewMarker}, use crate::{DomNode, DomView, DynMessage, ViewCtx};
DomNode, DomView, DynMessage, ViewCtx,
};
/// Invokes the `callback` after the inner `element` [`DomView`] was created. /// Invokes the `callback` after the inner `element` [`DomView`] was created.
/// See [`after_build`] for more details. /// See [`after_build`] for more details.

View File

@ -1,14 +1,15 @@
// Copyright 2023 the Xilem Authors // Copyright 2023 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{ use std::cell::RefCell;
core::{AppendVec, MessageResult, ViewId}, use std::rc::Rc;
elements::DomChildrenSplice,
AnyPod, DomFragment, DynMessage, ViewCtx,
};
use std::{cell::RefCell, rc::Rc};
use wasm_bindgen::UnwrapThrowExt; use wasm_bindgen::UnwrapThrowExt;
use crate::core::{AppendVec, MessageResult, ViewId};
use crate::elements::DomChildrenSplice;
use crate::{AnyPod, DomFragment, DynMessage, ViewCtx};
pub(crate) struct AppMessage { pub(crate) struct AppMessage {
pub id_path: Rc<[ViewId]>, pub id_path: Rc<[ViewId]>,
pub body: DynMessage, pub body: DynMessage,

View File

@ -1,12 +1,13 @@
// Copyright 2024 the Xilem Authors and the Druid Authors // Copyright 2024 the Xilem Authors and the Druid Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{
core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker},
DynMessage, OptionalAction, ViewCtx,
};
use std::marker::PhantomData; use std::marker::PhantomData;
use wasm_bindgen::{closure::Closure, JsCast, UnwrapThrowExt};
use wasm_bindgen::closure::Closure;
use wasm_bindgen::{JsCast, UnwrapThrowExt};
use crate::core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker};
use crate::{DynMessage, OptionalAction, ViewCtx};
/// Start an interval which invokes `callback` every `ms` milliseconds /// Start an interval which invokes `callback` every `ms` milliseconds
pub struct Interval<Callback, State, Action> { pub struct Interval<Callback, State, Action> {

View File

@ -1,14 +1,16 @@
// Copyright 2024 the Xilem Authors and the Druid Authors // Copyright 2024 the Xilem Authors and the Druid Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{ use std::future::Future;
core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker, ViewPathTracker}, use std::marker::PhantomData;
DynMessage, OptionalAction, ViewCtx,
}; use wasm_bindgen::closure::Closure;
use std::{future::Future, marker::PhantomData}; use wasm_bindgen::{JsCast, UnwrapThrowExt};
use wasm_bindgen::{closure::Closure, JsCast, UnwrapThrowExt};
use wasm_bindgen_futures::spawn_local; use wasm_bindgen_futures::spawn_local;
use crate::core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker, ViewPathTracker};
use crate::{DynMessage, OptionalAction, ViewCtx};
/// Await a future returned by `init_future` invoked with the argument `data`, `callback` is called with the output of the future. `init_future` will be invoked again, when `data` changes. Use [`memoized_await`] for construction of this [`View`] /// Await a future returned by `init_future` invoked with the argument `data`, `callback` is called with the output of the future. `init_future` will be invoked again, when `data` changes. Use [`memoized_await`] for construction of this [`View`]
pub struct MemoizedAwait<State, Action, OA, InitFuture, Data, Callback, F, FOut> { pub struct MemoizedAwait<State, Action, OA, InitFuture, Data, Callback, F, FOut> {
init_future: InitFuture, init_future: InitFuture,

View File

@ -1,17 +1,19 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use std::{future::Future, marker::PhantomData, rc::Rc}; use std::future::Future;
use std::marker::PhantomData;
use std::rc::Rc;
use crate::{ use futures::channel::oneshot;
context::MessageThunk, use futures::FutureExt;
core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker},
DynMessage, Message, ViewCtx,
};
use futures::{channel::oneshot, FutureExt};
use wasm_bindgen::UnwrapThrowExt; use wasm_bindgen::UnwrapThrowExt;
use wasm_bindgen_futures::spawn_local; use wasm_bindgen_futures::spawn_local;
use crate::context::MessageThunk;
use crate::core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker};
use crate::{DynMessage, Message, ViewCtx};
/// Spawn an async task to update state asynchronously /// Spawn an async task to update state asynchronously
/// ///
/// The `init_future` function is given a [`TaskProxy`] and a [`ShutdownSignal`]. /// The `init_future` function is given a [`TaskProxy`] and a [`ShutdownSignal`].

View File

@ -1,18 +1,15 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use wasm_bindgen_futures::spawn_local; use std::any::{Any, TypeId};
use crate::vecmap::VecMap;
use std::any::Any;
use std::any::TypeId;
use std::rc::Rc; use std::rc::Rc;
use crate::{ use wasm_bindgen_futures::spawn_local;
app::{AppMessage, AppRunner},
core::{ViewId, ViewPathTracker}, use crate::app::{AppMessage, AppRunner};
Message, use crate::core::{ViewId, ViewPathTracker};
}; use crate::vecmap::VecMap;
use crate::Message;
/// A thunk to send messages to the views, it's being used for example in event callbacks /// A thunk to send messages to the views, it's being used for example in event callbacks
pub struct MessageThunk { pub struct MessageThunk {

View File

@ -3,17 +3,18 @@
//! Basic builder functions to create DOM elements, such as [`html::div`] //! Basic builder functions to create DOM elements, such as [`html::div`]
use std::any::Any;
use std::borrow::Cow; use std::borrow::Cow;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::{any::Any, rc::Rc}; use std::rc::Rc;
use wasm_bindgen::{JsCast, UnwrapThrowExt}; use wasm_bindgen::{JsCast, UnwrapThrowExt};
use crate::core::{AppendVec, ElementSplice, MessageResult, Mut, View, ViewId, ViewMarker};
use crate::modifiers::Children;
use crate::vec_splice::VecSplice;
use crate::{ use crate::{
core::{AppendVec, ElementSplice, MessageResult, Mut, View, ViewId, ViewMarker}, document, AnyPod, DomFragment, DomNode, DynMessage, FromWithContext, Pod, ViewCtx, HTML_NS,
document,
modifiers::Children,
vec_splice::VecSplice,
AnyPod, DomFragment, DomNode, DynMessage, FromWithContext, Pod, ViewCtx, HTML_NS,
}; };
// sealed, because this should only cover `ViewSequences` with the blanket impl below // sealed, because this should only cover `ViewSequences` with the blanket impl below

View File

@ -1,14 +1,16 @@
// Copyright 2023 the Xilem Authors // Copyright 2023 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{ use std::borrow::Cow;
core::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker}, use std::marker::PhantomData;
DomView, DynMessage, OptionalAction, ViewCtx,
}; use wasm_bindgen::prelude::Closure;
use std::{borrow::Cow, marker::PhantomData}; use wasm_bindgen::{throw_str, JsCast, UnwrapThrowExt};
use wasm_bindgen::{prelude::Closure, throw_str, JsCast, UnwrapThrowExt};
use web_sys::{js_sys, AddEventListenerOptions}; use web_sys::{js_sys, AddEventListenerOptions};
use crate::core::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker};
use crate::{DomView, DynMessage, OptionalAction, ViewCtx};
/// Use a distinctive number here, to be able to catch bugs. /// Use a distinctive number here, to be able to catch bugs.
/// In case the generational-id view path in `View::Message` lead to a wrong view /// In case the generational-id view path in `View::Message` lead to a wrong view
const ON_EVENT_VIEW_ID: ViewId = ViewId::new(0x2357_1113); const ON_EVENT_VIEW_ID: ViewId = ViewId::new(0x2357_1113);

View File

@ -14,14 +14,12 @@
use std::borrow::Cow; use std::borrow::Cow;
use crate::{
events,
modifiers::{Attr, Class, ClassIter, Rotate, Scale, ScaleValue, Style, StyleIter},
props::{WithElementProps, WithHtmlInputElementProps},
DomNode, DomView, IntoAttributeValue, OptionalAction, Pointer, PointerMsg,
};
use wasm_bindgen::JsCast; use wasm_bindgen::JsCast;
use crate::modifiers::{Attr, Class, ClassIter, Rotate, Scale, ScaleValue, Style, StyleIter};
use crate::props::{WithElementProps, WithHtmlInputElementProps};
use crate::{events, DomNode, DomView, IntoAttributeValue, OptionalAction, Pointer, PointerMsg};
macro_rules! event_handler_mixin { macro_rules! event_handler_mixin {
($(($event_ty: ident, $fn_name:ident, $event:expr, $web_sys_event_type:ident),)*) => { ($(($event_ty: ident, $fn_name:ident, $event:expr, $web_sys_event_type:ident),)*) => {
$( $(

View File

@ -1,7 +1,9 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use std::{any::Any, fmt::Debug, ops::Deref}; use std::any::Any;
use std::fmt::Debug;
use std::ops::Deref;
/// A dynamically typed message for the [`View`] trait. /// A dynamically typed message for the [`View`] trait.
/// ///

View File

@ -1,15 +1,15 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{
core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker},
modifiers::{Modifier, WithModifier},
vecmap::VecMap,
AttributeValue, DomView, DynMessage, IntoAttributeValue, ViewCtx,
};
use std::marker::PhantomData; use std::marker::PhantomData;
use wasm_bindgen::{JsCast, UnwrapThrowExt}; use wasm_bindgen::{JsCast, UnwrapThrowExt};
use crate::core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker};
use crate::modifiers::{Modifier, WithModifier};
use crate::vecmap::VecMap;
use crate::{AttributeValue, DomView, DynMessage, IntoAttributeValue, ViewCtx};
type CowStr = std::borrow::Cow<'static, str>; type CowStr = std::borrow::Cow<'static, str>;
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]

View File

@ -1,16 +1,17 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{ use std::fmt::Debug;
core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker}, use std::marker::PhantomData;
diff::{diff_iters, Diff},
modifiers::{Modifier, WithModifier},
vecmap::VecMap,
DomView, DynMessage, ViewCtx,
};
use std::{fmt::Debug, marker::PhantomData};
use wasm_bindgen::{JsCast, UnwrapThrowExt}; use wasm_bindgen::{JsCast, UnwrapThrowExt};
use crate::core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker};
use crate::diff::{diff_iters, Diff};
use crate::modifiers::{Modifier, WithModifier};
use crate::vecmap::VecMap;
use crate::{DomView, DynMessage, ViewCtx};
type CowStr = std::borrow::Cow<'static, str>; type CowStr = std::borrow::Cow<'static, str>;
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]

View File

@ -242,9 +242,8 @@ macro_rules! overwrite_bool_modifier_view {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::PodFlags;
use super::*; use super::*;
use crate::PodFlags;
#[test] #[test]
fn overwrite_bool_push() { fn overwrite_bool_push() {

View File

@ -1,22 +1,19 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{ use std::collections::{BTreeMap, HashMap};
core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker}, use std::fmt::{Debug, Display};
diff::{diff_iters, Diff}, use std::hash::{BuildHasher, Hash};
vecmap::VecMap, use std::marker::PhantomData;
DomView, DynMessage, ViewCtx,
};
use peniko::kurbo::Vec2; use peniko::kurbo::Vec2;
use std::{
collections::{BTreeMap, HashMap},
fmt::{Debug, Display},
hash::{BuildHasher, Hash},
marker::PhantomData,
};
use wasm_bindgen::{JsCast, UnwrapThrowExt}; use wasm_bindgen::{JsCast, UnwrapThrowExt};
use super::{Modifier, WithModifier}; use super::{Modifier, WithModifier};
use crate::core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker};
use crate::diff::{diff_iters, Diff};
use crate::vecmap::VecMap;
use crate::{DomView, DynMessage, ViewCtx};
type CowStr = std::borrow::Cow<'static, str>; type CowStr = std::borrow::Cow<'static, str>;

View File

@ -1,15 +1,12 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{
core::{
one_of::{OneOf, OneOfCtx, PhantomElementCtx},
Mut,
},
DomNode, Pod, PodFlags, PodMut, ViewCtx,
};
use wasm_bindgen::UnwrapThrowExt; use wasm_bindgen::UnwrapThrowExt;
use crate::core::one_of::{OneOf, OneOfCtx, PhantomElementCtx};
use crate::core::Mut;
use crate::{DomNode, Pod, PodFlags, PodMut, ViewCtx};
impl<N1, N2, N3, N4, N5, N6, N7, N8, N9> impl<N1, N2, N3, N4, N5, N6, N7, N8, N9>
OneOfCtx<Pod<N1>, Pod<N2>, Pod<N3>, Pod<N4>, Pod<N5>, Pod<N6>, Pod<N7>, Pod<N8>, Pod<N9>> OneOfCtx<Pod<N1>, Pod<N2>, Pod<N3>, Pod<N4>, Pod<N5>, Pod<N6>, Pod<N7>, Pod<N8>, Pod<N9>>
for ViewCtx for ViewCtx

View File

@ -3,9 +3,10 @@
use std::ops::DerefMut as _; use std::ops::DerefMut as _;
use wasm_bindgen::UnwrapThrowExt;
use crate::core::{AnyElement, SuperElement, ViewElement}; use crate::core::{AnyElement, SuperElement, ViewElement};
use crate::{AnyNode, DomNode, ViewCtx}; use crate::{AnyNode, DomNode, ViewCtx};
use wasm_bindgen::UnwrapThrowExt;
/// A container, which holds the actual DOM node, and associated props, such as attributes or classes. /// A container, which holds the actual DOM node, and associated props, such as attributes or classes.
/// ///

View File

@ -3,16 +3,17 @@
//! Interactivity with pointer events. //! Interactivity with pointer events.
use crate::{
core::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker},
interfaces::Element,
DomView, DynMessage, ViewCtx,
};
use peniko::kurbo::Point;
use std::marker::PhantomData; use std::marker::PhantomData;
use wasm_bindgen::{prelude::Closure, throw_str, JsCast, UnwrapThrowExt};
use peniko::kurbo::Point;
use wasm_bindgen::prelude::Closure;
use wasm_bindgen::{throw_str, JsCast, UnwrapThrowExt};
use web_sys::PointerEvent; use web_sys::PointerEvent;
use crate::core::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker};
use crate::interfaces::Element;
use crate::{DomView, DynMessage, ViewCtx};
/// Use a distinctive number here, to be able to catch bugs. /// Use a distinctive number here, to be able to catch bugs.
/// In case the generational-id view path in `View::Message` lead to a wrong view /// In case the generational-id view path in `View::Message` lead to a wrong view
const POINTER_VIEW_ID: ViewId = ViewId::new(0x1234_5014); const POINTER_VIEW_ID: ViewId = ViewId::new(0x1234_5014);

View File

@ -1,13 +1,10 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{ use wasm_bindgen::{JsCast, UnwrapThrowExt};
document,
modifiers::{Attributes, Children, Classes, Modifier, Styles}, use crate::modifiers::{Attributes, Children, Classes, Modifier, Styles};
AnyPod, Pod, PodFlags, ViewCtx, use crate::{document, AnyPod, Pod, PodFlags, ViewCtx};
};
use wasm_bindgen::JsCast;
use wasm_bindgen::UnwrapThrowExt;
// Lazy access to attributes etc. to avoid allocating unnecessary memory when it isn't needed // Lazy access to attributes etc. to avoid allocating unnecessary memory when it isn't needed
// Benchmarks have shown, that this can significantly increase performance and reduce memory usage... // Benchmarks have shown, that this can significantly increase performance and reduce memory usage...

View File

@ -1,11 +1,11 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::modifiers::html_input_element::{Checked, DefaultChecked, Disabled, Multiple, Required};
use crate::{props, FromWithContext, Pod, PodFlags, ViewCtx};
use wasm_bindgen::JsCast as _; use wasm_bindgen::JsCast as _;
use super::WithElementProps; use super::WithElementProps;
use crate::modifiers::html_input_element::{Checked, DefaultChecked, Disabled, Multiple, Required};
use crate::{props, FromWithContext, Pod, PodFlags, ViewCtx};
/// Props specific to an input element. /// Props specific to an input element.
pub struct HtmlInputElement { pub struct HtmlInputElement {

View File

@ -1,15 +1,15 @@
// Copyright 2023 the Xilem Authors // Copyright 2023 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{
core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker},
modifiers::{AttributeModifier, Attributes, Modifier, WithModifier},
DomView, DynMessage, ViewCtx,
};
use peniko::{kurbo, Brush};
use std::fmt::Write as _; use std::fmt::Write as _;
use std::marker::PhantomData; use std::marker::PhantomData;
use peniko::{kurbo, Brush};
use crate::core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker};
use crate::modifiers::{AttributeModifier, Attributes, Modifier, WithModifier};
use crate::{DomView, DynMessage, ViewCtx};
pub struct Fill<V, State, Action> { pub struct Fill<V, State, Action> {
child: V, child: V,
// This could reasonably be static Cow also, but keep things simple // This could reasonably be static Cow also, but keep things simple
@ -295,8 +295,10 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use peniko::color::palette;
use peniko::Brush;
use super::brush_to_string; use super::brush_to_string;
use peniko::{color::palette, Brush};
#[test] #[test]
fn color_brush_to_string() { fn color_brush_to_string() {

View File

@ -3,13 +3,12 @@
//! Implementation of the View trait for various kurbo shapes. //! Implementation of the View trait for various kurbo shapes.
use crate::{
core::{MessageResult, Mut, OrphanView, ViewId},
modifiers::{Attributes, WithModifier},
DynMessage, FromWithContext, Pod, ViewCtx, SVG_NS,
};
use peniko::kurbo::{BezPath, Circle, Line, Rect}; use peniko::kurbo::{BezPath, Circle, Line, Rect};
use crate::core::{MessageResult, Mut, OrphanView, ViewId};
use crate::modifiers::{Attributes, WithModifier};
use crate::{DynMessage, FromWithContext, Pod, ViewCtx, SVG_NS};
fn create_element<R>( fn create_element<R>(
name: &str, name: &str,
ctx: &mut ViewCtx, ctx: &mut ViewCtx,

View File

@ -1,13 +1,14 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{ use std::any::TypeId;
core::{MessageResult, Mut, View, ViewId, ViewMarker}, use std::rc::Rc;
DomView, DynMessage, PodMut, ViewCtx,
};
use std::{any::TypeId, rc::Rc};
use wasm_bindgen::UnwrapThrowExt; use wasm_bindgen::UnwrapThrowExt;
use crate::core::{MessageResult, Mut, View, ViewId, ViewMarker};
use crate::{DomView, DynMessage, PodMut, ViewCtx};
/// This view creates an internally cached deep-clone of the underlying DOM node. When the inner view is created again, this will be done more efficiently. /// This view creates an internally cached deep-clone of the underlying DOM node. When the inner view is created again, this will be done more efficiently.
pub struct Templated<V>(Rc<V>); pub struct Templated<V>(Rc<V>);

View File

@ -1,12 +1,11 @@
// Copyright 2024 the Xilem Authors // Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{
core::{MessageResult, Mut, OrphanView, ViewId},
DynMessage, Pod, PodFlags, ViewCtx,
};
use wasm_bindgen::JsCast; use wasm_bindgen::JsCast;
use crate::core::{MessageResult, Mut, OrphanView, ViewId};
use crate::{DynMessage, Pod, PodFlags, ViewCtx};
// strings -> text nodes // strings -> text nodes
macro_rules! impl_string_view { macro_rules! impl_string_view {
($ty:ty) => { ($ty:ty) => {

View File

@ -1,7 +1,10 @@
// Copyright 2023 the Xilem Authors // Copyright 2023 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use std::{borrow::Borrow, fmt, ops::Index, vec::Drain}; use std::borrow::Borrow;
use std::fmt;
use std::ops::Index;
use std::vec::Drain;
#[derive(Clone)] #[derive(Clone)]
/// Basically an ordered `Map` (similar as `BTreeMap`) with a `Vec` as backend for very few elements /// Basically an ordered `Map` (similar as `BTreeMap`) with a `Vec` as backend for very few elements

View File

@ -4,12 +4,9 @@
//! A simple counter //! A simple counter
#![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")] #![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")]
use xilem_web::{ use xilem_web::elements::html as el;
document_body, use xilem_web::interfaces::{Element, HtmlButtonElement};
elements::html as el, use xilem_web::{document_body, App, DomFragment};
interfaces::{Element, HtmlButtonElement},
App, DomFragment,
};
#[derive(Default)] #[derive(Default)]
struct AppState { struct AppState {

View File

@ -5,12 +5,9 @@
#![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")] #![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")]
use xilem_web::{ use xilem_web::elements::custom_element;
document_body, use xilem_web::interfaces::{Element, HtmlElement};
elements::custom_element, use xilem_web::{document_body, App, DomView};
interfaces::{Element, HtmlElement},
App, DomView,
};
#[derive(Default)] #[derive(Default)]
struct AppState { struct AppState {

View File

@ -7,13 +7,10 @@
//! [`map_state`](xilem_web::core::map_state) or //! [`map_state`](xilem_web::core::map_state) or
//! [`adapt`](xilem_web::core::adapt). //! [`adapt`](xilem_web::core::adapt).
use xilem_web::{ use xilem_web::core::map_action;
core::map_action, use xilem_web::elements::html as el;
document_body, use xilem_web::interfaces::{Element, HtmlDivElement};
elements::html as el, use xilem_web::{document_body, Action, App};
interfaces::{Element, HtmlDivElement},
Action, App,
};
#[derive(Debug, Default)] #[derive(Debug, Default)]
struct Model { struct Model {

View File

@ -10,14 +10,14 @@
use gloo_net::http::Request; use gloo_net::http::Request;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use wasm_bindgen::{JsCast, UnwrapThrowExt}; use wasm_bindgen::{JsCast, UnwrapThrowExt};
use xilem_web::{ use xilem_web::concurrent::memoized_await;
concurrent::memoized_await, use xilem_web::core::fork;
core::{fork, one_of::Either}, use xilem_web::core::one_of::Either;
document_body, use xilem_web::elements::html::*;
elements::html::*, use xilem_web::interfaces::{
interfaces::{Element, HtmlDivElement, HtmlImageElement, HtmlInputElement, HtmlLabelElement}, Element, HtmlDivElement, HtmlImageElement, HtmlInputElement, HtmlLabelElement,
App,
}; };
use xilem_web::{document_body, App};
const TOO_MANY_CATS: usize = 8; const TOO_MANY_CATS: usize = 8;

View File

@ -9,10 +9,10 @@
#![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")] #![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")]
use wasm_bindgen::{JsCast, UnwrapThrowExt}; use wasm_bindgen::{JsCast, UnwrapThrowExt};
use xilem_web::{ use xilem_web::elements::{html, mathml as ml, svg};
document_body, elements::html, elements::mathml as ml, elements::svg, interfaces::*, use xilem_web::interfaces::*;
modifiers::style as s, App, use xilem_web::modifiers::style as s;
}; use xilem_web::{document_body, App};
struct Triangle { struct Triangle {
a: u32, a: u32,

View File

@ -10,11 +10,13 @@
//! after a callback has been performed in //! after a callback has been performed in
//! `after_build`, `after_rebuild` or `before_teardown`. //! `after_build`, `after_rebuild` or `before_teardown`.
use std::{cell::Cell, rc::Rc}; use std::cell::Cell;
use std::rc::Rc;
use xilem_web::{ use xilem_web::core::one_of::Either;
core::one_of::Either, document_body, elements::html, interfaces::Element, App, DomView, use xilem_web::elements::html;
}; use xilem_web::interfaces::Element;
use xilem_web::{document_body, App, DomView};
#[derive(Default)] #[derive(Default)]
struct AppState { struct AppState {

View File

@ -8,15 +8,12 @@
use futures::{select, FutureExt}; use futures::{select, FutureExt};
use gloo_timers::future::TimeoutFuture; use gloo_timers::future::TimeoutFuture;
use xilem_web::{ use xilem_web::concurrent::{task, ShutdownSignal, TaskProxy};
concurrent::{task, ShutdownSignal, TaskProxy}, use xilem_web::core::fork;
core::fork, use xilem_web::core::one_of::Either;
core::one_of::Either, use xilem_web::elements::html;
document_body, use xilem_web::interfaces::Element;
elements::html, use xilem_web::{document_body, App};
interfaces::Element,
App,
};
#[derive(Default)] #[derive(Default)]
struct AppState { struct AppState {

View File

@ -4,22 +4,17 @@
//! An example showing how SVG paths can be used for a vector-drawing application //! An example showing how SVG paths can be used for a vector-drawing application
use std::rc::Rc; use std::rc::Rc;
use wasm_bindgen::UnwrapThrowExt; use wasm_bindgen::UnwrapThrowExt;
use xilem_web::{ use xilem_web::elements::html::{div, input, label, span};
document_body, use xilem_web::elements::svg::{g, svg};
elements::{ use xilem_web::interfaces::{
html::{div, input, label, span}, Element, HtmlInputElement, SvgGeometryElement, SvgPathElement, SvggElement,
svg::{g, svg},
},
input_event_target_value,
interfaces::{Element, HtmlInputElement, SvgGeometryElement, SvgPathElement, SvggElement},
modifiers::style as s,
svg::{
kurbo::{BezPath, Point, QuadSpline, Shape, Stroke},
peniko::Color,
},
AnyDomView, App, DomFragment,
}; };
use xilem_web::modifiers::style as s;
use xilem_web::svg::kurbo::{BezPath, Point, QuadSpline, Shape, Stroke};
use xilem_web::svg::peniko::Color;
use xilem_web::{document_body, input_event_target_value, AnyDomView, App, DomFragment};
const RAINBOW_COLORS: [Color; 11] = [ const RAINBOW_COLORS: [Color; 11] = [
Color::from_rgba8(228, 3, 3, 255), // Red Color::from_rgba8(228, 3, 3, 255), // Red

View File

@ -5,18 +5,13 @@
// TODO: `expect` doesn't work here // TODO: `expect` doesn't work here
#![allow(clippy::wildcard_imports, reason = "HTML elements are an exception")] #![allow(clippy::wildcard_imports, reason = "HTML elements are an exception")]
use xilem_web::{ use xilem_web::elements::svg::{g, svg, text};
document_body, use xilem_web::interfaces::*;
elements::svg::{g, svg, text}, use xilem_web::modifiers::style as s;
interfaces::*, use xilem_web::svg::kurbo::{Circle, Line, Rect, Stroke, Vec2};
modifiers::style as s, use xilem_web::svg::peniko::color::palette;
svg::{ use xilem_web::svg::peniko::Color;
kurbo::{Circle, Line, Rect, Stroke, Vec2}, use xilem_web::{document_body, App, DomView, PointerMsg};
peniko::color::palette,
peniko::Color,
},
App, DomView, PointerMsg,
};
#[derive(Default)] #[derive(Default)]
struct AppState { struct AppState {

View File

@ -11,16 +11,12 @@
mod state; mod state;
use state::{AppState, Filter, Todo}; use state::{AppState, Filter, Todo};
use wasm_bindgen::JsCast; use wasm_bindgen::JsCast;
use xilem_web::{ use xilem_web::core::{adapt, MessageResult};
core::{adapt, MessageResult}, use xilem_web::elements::html as el;
elements::html as el, use xilem_web::interfaces::*;
get_element_by_id, use xilem_web::modifiers::style as s;
interfaces::*, use xilem_web::{get_element_by_id, Action, App, DomView};
modifiers::style as s,
Action, App, DomView,
};
// All of these actions arise from within a `Todo`, but we need access to the full state to reduce // All of these actions arise from within a `Todo`, but we need access to the full state to reduce
// them. // them.