1#[derive(Debug, Clone, Copy, Eq, PartialEq)]
10pub struct Asset {
11 pub path: &'static str,
15 pub contents: &'static str,
17}
18
19include!(concat!(env!("OUT_DIR"), "/assets.rs"));
20
21pub fn css_assets() -> &'static [Asset] {
23 CSS_ASSETS
24}
25
26pub fn js_assets() -> &'static [Asset] {
28 JS_ASSETS
29}
30
31pub fn foundry_assets() -> &'static [Asset] {
33 FOUNDRY_ASSETS
34}
35
36pub fn all_assets() -> impl Iterator<Item = &'static Asset> {
38 CSS_ASSETS.iter().chain(JS_ASSETS).chain(FOUNDRY_ASSETS)
39}
40
41pub fn asset(path: &str) -> Option<&'static Asset> {
43 all_assets().find(|asset| asset.path == path)
44}
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn exposes_core_css_asset() {
52 let index = asset("css/index.css").expect("index css should be embedded");
53 assert!(index.contents.contains("tokens.css"));
54 }
55
56 #[test]
57 fn exposes_foundry_component_asset() {
58 let button = asset("foundry/Button.ax").expect("button component should be embedded");
59 assert!(button.contents.contains("page Button"));
60 }
61}