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
72
73
74
75
76
77
//! `@spa`'s client runtime - hotloaded, SPA-style page navigation (History
//! API fetch-and-swap instead of a full reload). See `docs/MACROS.md`'s
//! `@spa` section for the full directive design; this crate is
//! deliberately tiny, and deliberately its own crate rather than folded
//! into `larust-live`.
//!
//! **Why its own crate, not `larust-live`**: `@spa` shares no machinery at
//! all with `larust-live`'s reactive-component (`@wire`) or server-push
//! (`@live`) features - no component registry, no session-backed mount, no
//! WebSocket. Every request `@spa` navigates to is rendered exactly the
//! same full HTML page `view!(...)` already produces for a hard reload;
//! the client extracts what changed via `DOMParser` and swaps it in. There
//! is no server-side rendering path for this feature at all - this crate
//! is, in full, one vendored static JS asset and the handler that serves
//! it, the same "thin sibling crate" shape `larust-reverb` already
//! establishes for a broadcast/socket variant of `larust-live::push` that
//! likewise didn't belong folded into that crate's own identity.
//!
//! **No feature flag** - re-exported unconditionally through
//! `larust_support::spa`, unlike the optional Tier-1 shim crates
//! (`permissions`/`reverb`/`sanctum`/`sitemap`/`socialite`, each a
//! Laravel-third-party-package equivalent an app opts into via a Cargo
//! feature). `@spa` is core template-directive surface, the same tier as
//! `wire`/`push`.
//!
//! **Route registration is the app's own job**, not automatic - same
//! explicit convention `/__larust_wire/*`/`/__larust_push/*` already use
//! (see `demo/routes/web.rs`). An app that uses `@spa ... @endspa`
//! anywhere registers exactly one route, most easily via [`SpaPlugin`]:
//!
//! ```ignore
//! .plugin(larust_support::spa::SpaPlugin)
//! ```
//!
//! Unlike `wire`/`push`, there is no second route - no `/__larust_spa/{id}`
//! endpoint of any kind - because there is no server-side counterpart to
//! this feature at all; ordinary page routes already serve everything
//! `@spa` needs.
use CONTENT_TYPE;
use IntoResponse;
const RUNTIME_JS: &str = include_str!;
/// Serves the vendored `spa-runtime.js` client script - see this crate's
/// own doc comment for the route the app must register this under.
pub async
/// `@spa`'s one route, bundled for [`larust_http::Router::plugin`] - sugar
/// for the single `.get(...)` call this crate's own doc comment shows an
/// app writing by hand today.
;