tinymist_world/
config.rs

1//! The configuration of the world.
2
3use 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/// The options to create the world.
14#[serde_as]
15#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
16pub struct CompileOpts {
17    /// The path to the entry.
18    pub entry: EntryOpts,
19
20    /// Additional input arguments to compile the entry file.
21    pub inputs: Dict,
22
23    /// The path to the font profile for cache.
24    #[serde(rename = "fontProfileCachePath")]
25    pub font_profile_cache_path: PathBuf,
26
27    /// The paths to the font files.
28    #[serde(rename = "fontPaths")]
29    pub font_paths: Vec<PathBuf>,
30
31    /// Whether to exclude system font paths.
32    #[serde(rename = "noSystemFonts")]
33    pub no_system_fonts: bool,
34
35    /// Whether to include embedded fonts.
36    #[serde(rename = "withEmbeddedFonts")]
37    #[serde_as(as = "Vec<AsCowBytes>")]
38    pub with_embedded_fonts: Vec<Cow<'static, [u8]>>,
39
40    /// The fixed creation timestamp for the world.
41    #[serde(rename = "creationTimestamp")]
42    pub creation_timestamp: Option<i64>,
43}
44
45/// The options to specify the fonts for the world.
46#[serde_as]
47#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
48pub struct CompileFontOpts {
49    /// The paths to the font files.
50    #[serde(rename = "fontPaths")]
51    pub font_paths: Vec<PathBuf>,
52
53    /// Whether to exclude system font paths.
54    #[serde(rename = "noSystemFonts")]
55    pub no_system_fonts: bool,
56
57    /// The embedded fonts to include.
58    #[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}