1use std::borrow::Cow;
4use std::path::PathBuf;
5
6use serde::{Deserialize, Serialize};
7use serde_with::serde_as;
8use tinymist_std::AsCowBytes;
9use typst::foundations::Dict;
10
11use crate::EntryOpts;
12
13#[serde_as]
15#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
16pub struct CompileOpts {
17 pub entry: EntryOpts,
19
20 pub inputs: Dict,
22
23 #[serde(rename = "fontProfileCachePath")]
25 pub font_profile_cache_path: PathBuf,
26
27 #[serde(rename = "fontPaths")]
29 pub font_paths: Vec<PathBuf>,
30
31 #[serde(rename = "noSystemFonts")]
33 pub no_system_fonts: bool,
34
35 #[serde(rename = "withEmbeddedFonts")]
37 #[serde_as(as = "Vec<AsCowBytes>")]
38 pub with_embedded_fonts: Vec<Cow<'static, [u8]>>,
39
40 #[serde(rename = "creationTimestamp")]
42 pub creation_timestamp: Option<i64>,
43}
44
45#[serde_as]
47#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
48pub struct CompileFontOpts {
49 #[serde(rename = "fontPaths")]
51 pub font_paths: Vec<PathBuf>,
52
53 #[serde(rename = "noSystemFonts")]
55 pub no_system_fonts: bool,
56
57 #[serde(rename = "withEmbeddedFonts")]
59 #[serde_as(as = "Vec<AsCowBytes>")]
60 pub with_embedded_fonts: Vec<Cow<'static, [u8]>>,
61}
62
63impl From<CompileOpts> for CompileFontOpts {
64 fn from(opts: CompileOpts) -> Self {
65 Self {
66 font_paths: opts.font_paths,
67 no_system_fonts: opts.no_system_fonts,
68 with_embedded_fonts: opts.with_embedded_fonts,
69 }
70 }
71}