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
68
69
70
71
//! Svelte 5 islands for Autumn, in Maud + htmx pages.
//!
//! The server renders an [`Island`]. The browser loader (`islands.js`)
//! mounts a compiled Svelte component into it.
//!
//! ```rust,no_run
//! use autumn_plugin_svelte::{Island, MountWhen, SveltePlugin, svelte_bundle, svelte_script};
//! use autumn_web::assets::PluginAssets;
//! use autumn_web::prelude::*;
//!
//! // Your Vite build output, compiled into the binary.
//! static ISLANDS: PluginAssets = PluginAssets::from_files(
//! "app-islands",
//! &[("islands.js", b"/* vite build output */")],
//! );
//!
//! #[get("/")]
//! async fn index() -> AutumnResult<Markup> {
//! let counter = Island::new("Counter")
//! .props(&serde_json::json!({ "start": 3 }))?
//! .fallback(html! { p { "Counter: 3" } });
//! Ok(html! {
//! head { (svelte_script()) (svelte_bundle(&ISLANDS)) }
//! body {
//! (counter)
//! (Island::new("Chart").mount_when(MountWhen::Visible))
//! }
//! })
//! }
//!
//! # async fn run() {
//! autumn_web::app()
//! .plugin(SveltePlugin::new().bundle(&ISLANDS))
//! .routes(routes![index])
//! .run()
//! .await;
//! # }
//! ```
//!
//! The Vite entry file registers the components:
//!
//! ```js
//! import { mount, unmount } from "svelte";
//! import Counter from "./Counter.svelte";
//!
//! let queue = window.autumnSvelte;
//! if (!Array.isArray(queue) && queue?.loader !== true) {
//! queue = window.autumnSvelte = []; // an id="autumnSvelte" element can clobber it
//! }
//! queue.push({ mount, unmount, components: { Counter } });
//! ```
//!
//! Put user HTML in an element with `data-svelte-ignore`. The loader does not
//! mount islands in it.
//!
//! # Limits
//!
//! - The server does not render the component. The fallback is the first
//! paint.
//! - You need Node to build components. You do not need Node at run time.
//! - Props go in an HTML attribute. Keep them small.
pub use ;
pub use ;
pub use ;
pub use ;