rune/ace/
mod.rs

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
mod autocomplete;
pub(crate) use self::autocomplete::build as build_autocomplete;

use anyhow::{anyhow, Context as _, Result};

use crate::alloc::borrow::Cow;
use crate::doc::Artifacts;

mod embed {
    #[cfg(debug_assertions)]
    use rust_alloc::boxed::Box;
    #[cfg(debug_assertions)]
    use rust_alloc::string::String;

    use rust_embed::RustEmbed;

    #[derive(RustEmbed)]
    #[folder = "src/ace/static"]
    pub(super) struct Assets;
}

pub(crate) fn theme(artifacts: &mut Artifacts) -> Result<()> {
    for name in ["rune-mode.js", "rune-highlight-rules.js"] {
        artifacts.asset(false, name, || {
            let file = embed::Assets::get(name).with_context(|| anyhow!("missing {name}"))?;
            Ok(Cow::try_from(file.data)?)
        })?;
    }

    Ok(())
}