The current `axum` feature and `server` feature are incompatible with wasm32-unknown-unknown target due to: 1. depends on axum features not compatible with wasm 2. SSR requires reading the filesystem for index.html With this patch I add the `server_fn_axum` feature which disables SSR and enables targeting wasm32-unknown-unknown with server functions enabled. Note that for this to work, `server_fn` depends on `inventory` and as stated in this docs depending on the context you might need to expose and call [`__wasm_call_ctors`](https://docs.rs/inventory/latest/inventory/#webassembly-and-constructors) (I needed that specifically for cloudflare workers) change axum_server_fn feature for axum_wasm and include SSR tools there This change additionaly make axum_server_fn feature additive by exposing a different `DioxusRouterWasmExt` with only the wasm-compatible parts instead of exposing the `DioxusRouter` trait under the same name. Docs are updated to reflect this change. rename axum_wasm to axum_core and update docs fix typo re-enable default-features for axum in dioxus-cli re-enable axum default-features for liveview re-enable default-features for axum for playwright-tests
80 lines
2.2 KiB
Rust
80 lines
2.2 KiB
Rust
#![doc = include_str!("../README.md")]
|
|
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
|
|
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
|
|
#![deny(missing_docs)]
|
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
|
|
|
use std::sync::Arc;
|
|
|
|
pub use once_cell;
|
|
|
|
mod html_storage;
|
|
|
|
#[allow(unused)]
|
|
pub(crate) type ContextProviders =
|
|
Arc<Vec<Box<dyn Fn() -> Box<dyn std::any::Any> + Send + Sync + 'static>>>;
|
|
|
|
#[cfg(feature = "axum")]
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "axum")))]
|
|
pub mod server;
|
|
|
|
#[cfg(feature = "axum_core")]
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "axum_core")))]
|
|
pub mod axum_core;
|
|
|
|
mod hooks;
|
|
|
|
pub mod document;
|
|
#[cfg(feature = "server")]
|
|
mod render;
|
|
#[cfg(feature = "server")]
|
|
mod streaming;
|
|
|
|
#[cfg(feature = "server")]
|
|
mod serve_config;
|
|
|
|
#[cfg(feature = "server")]
|
|
pub use serve_config::*;
|
|
|
|
#[cfg(feature = "server")]
|
|
mod server_context;
|
|
|
|
/// A prelude of commonly used items in dioxus-fullstack.
|
|
pub mod prelude {
|
|
use crate::hooks;
|
|
pub use hooks::{server_cached::use_server_cached, server_future::use_server_future};
|
|
|
|
#[cfg(feature = "axum")]
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "axum")))]
|
|
pub use crate::server::*;
|
|
|
|
#[cfg(feature = "axum_core")]
|
|
pub use crate::axum_core::*;
|
|
|
|
#[cfg(feature = "server")]
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
|
|
pub use crate::render::{FullstackHTMLTemplate, SSRState};
|
|
|
|
#[cfg(feature = "server")]
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
|
|
pub use crate::serve_config::{ServeConfig, ServeConfigBuilder};
|
|
|
|
#[cfg(feature = "axum")]
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "axum")))]
|
|
pub use crate::server_context::Axum;
|
|
|
|
#[cfg(feature = "server")]
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
|
|
pub use crate::server_context::{
|
|
extract, server_context, with_server_context, DioxusServerContext, FromContext,
|
|
FromServerContext, ProvideServerContext,
|
|
};
|
|
|
|
#[cfg(feature = "server")]
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
|
|
pub use dioxus_isrg::{IncrementalRenderer, IncrementalRendererConfig};
|
|
|
|
pub use dioxus_server_macro::*;
|
|
pub use server_fn::{self, ServerFn as _, ServerFnError};
|
|
}
|