Skip to main content

seam_server/
page.rs

1/* src/server/core/rust/src/page.rs */
2
3use std::collections::HashMap;
4use std::sync::Arc;
5
6pub type LoaderInputFn = Arc<dyn Fn(&HashMap<String, String>) -> serde_json::Value + Send + Sync>;
7
8pub struct LoaderDef {
9	pub data_key: String,
10	pub procedure: String,
11	pub input_fn: LoaderInputFn,
12}
13
14/// One entry in a layout chain (outer to inner order).
15/// Each layout owns a set of loader data keys.
16pub struct LayoutChainEntry {
17	pub id: String,
18	pub loader_keys: Vec<String>,
19}
20
21pub struct PageDef {
22	/// Axum route syntax, e.g. "/user/{id}"
23	pub route: String,
24	pub template: String,
25	/// Per-locale pre-resolved templates (layout chain already applied). Keyed by locale.
26	pub locale_templates: Option<HashMap<String, String>>,
27	pub loaders: Vec<LoaderDef>,
28	/// Optional derive definitions from route-manifest.
29	pub derives: Option<serde_json::Value>,
30	/// Script ID for the injected data JSON. Defaults to "__data".
31	pub data_id: String,
32	/// Layout chain from outer to inner. Each entry records which loader keys belong to that layout.
33	pub layout_chain: Vec<LayoutChainEntry>,
34	/// Data keys from page-level loaders (not layout). Used to split data in the data script.
35	pub page_loader_keys: Vec<String>,
36	/// Merged i18n keys from route + layout chain. Empty means include all keys.
37	pub i18n_keys: Vec<String>,
38	/// Per-loader field projections for schema narrowing. None = no narrowing.
39	pub projections: Option<HashMap<String, Vec<String>>>,
40	/// SSG: serve pre-rendered static HTML instead of running loaders.
41	pub prerender: bool,
42	/// SSG: directory containing pre-rendered HTML files.
43	pub static_dir: Option<std::path::PathBuf>,
44}
45
46/// Runtime i18n configuration loaded from build output.
47#[derive(Clone)]
48pub struct I18nConfig {
49	pub locales: Vec<String>,
50	pub default: String,
51	pub mode: String,
52	pub cache: bool,
53	/// Route pattern -> route hash (8 hex)
54	pub route_hashes: HashMap<String, String>,
55	/// Route hash -> { locale -> content hash (4 hex) }
56	pub content_hashes: HashMap<String, HashMap<String, String>>,
57	/// Memory mode: locale -> routeHash -> messages
58	pub messages: HashMap<String, HashMap<String, serde_json::Value>>,
59	/// Paged mode: base directory for on-demand reads
60	pub dist_dir: Option<std::path::PathBuf>,
61}