1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
pub mod app;
pub mod attribute_value;
pub mod component;
pub mod dehydrate;
pub mod elements;
pub mod hydrate;
pub mod option_string_value;
pub mod string_value;

#[cfg(target_arch = "wasm32")]
mod client;
#[cfg(target_arch = "wasm32")]
pub use crate::client::*;

#[cfg(not(target_arch = "wasm32"))]
mod server;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::server::*;

pub mod prelude {
	pub use crate::{
		app::App,
		clone,
		component::Component,
		dehydrate::Dehydrate,
		elements::{html, html::*, svg},
		fragment, html,
		hydrate::hydrate,
		text, Element, Fragment, Namespace, Node, SignalNode, SignalVecNode, Text,
	};
	pub use crate::{pending_with, PendingWith};
	pub use futures_signals::{
		signal::{Mutable, Signal, SignalExt},
		signal_vec::{MutableVec, SignalVec, SignalVecExt},
	};
	pub use pinwheel_macro::{builder, children, new};
}

pub use futures_signals::signal;
pub use futures_signals::signal_vec;

#[macro_export]
macro_rules! clone {
	($($name:ident),*$(,)?) => {
		$(let $name = $name.clone();)*
	}
}

pub fn html<T: component::Component>(component: T) -> String {
	format!("<!doctype html>{}", component.into_node())
}

pub fn pending_with<T>(value: T) -> PendingWith<T> {
	PendingWith(value)
}

pub struct PendingWith<T>(T);

impl<T> std::future::Future for PendingWith<T> {
	type Output = T;
	fn poll(
		self: std::pin::Pin<&mut Self>,
		_cx: &mut std::task::Context<'_>,
	) -> std::task::Poll<Self::Output> {
		std::task::Poll::Pending
	}
}