1pub use config::*;
22pub use log_::*;
23pub use lsp::init::*;
24pub use server::*;
25pub use sync_ls::LspClient;
26pub use tinymist_project::world;
27pub use tinymist_query as query;
28pub use world::{CompileFontArgs, CompileOnceArgs, CompilePackageArgs};
29
30#[cfg(feature = "export")]
31pub use task::export2 as export;
32#[cfg(feature = "export")]
33pub use task::ExportTask;
34#[cfg(feature = "trace")]
35pub use task::UserActionTask;
36
37#[cfg(feature = "dap")]
38pub use dap::RegularInit as DapRegularInit;
39#[cfg(feature = "dap")]
40pub use dap::SuperInit as DapSuperInit;
41
42pub mod project;
43pub mod tool;
44
45#[cfg(feature = "web")]
46pub mod web;
47
48mod actor;
49mod cmd;
50mod config;
51mod input;
52#[path = "log.rs"]
53mod log_;
54mod lsp;
55mod resource;
56mod server;
57mod stats;
58mod task;
59mod utils;
60
61#[cfg(feature = "dap")]
62mod dap;
63#[cfg(feature = "lock")]
64mod route;
65
66use std::sync::LazyLock;
67
68use lsp::query::QueryFuture;
69use serde_json::from_value;
70use sync_ls::*;
71use utils::*;
72use world::*;
73
74const VERGEN_IDEMPOTENT_OUTPUT: &str = "VERGEN_IDEMPOTENT_OUTPUT";
77
78fn git_describe_or_version(value: &str) -> &str {
81 if value.is_empty() || value == VERGEN_IDEMPOTENT_OUTPUT {
82 return env!("CARGO_PKG_VERSION");
83 }
84 value
85}
86
87fn value_or_none(value: &str) -> &str {
91 if value.is_empty() || value == VERGEN_IDEMPOTENT_OUTPUT {
92 return "None";
93 }
94 value
95}
96
97pub static LONG_VERSION: LazyLock<String> = LazyLock::new(|| {
99 format!(
100 "v{}
101Build Timestamp: {}
102Build Git Describe: {}
103Commit SHA: {}
104Commit Date: {}
105Commit Branch: {}
106Cargo Target Triple: {}
107Typst Version: {}
108Typst Source: {}
109",
110 env!("CARGO_PKG_VERSION"),
111 env!("VERGEN_BUILD_TIMESTAMP"),
112 git_describe_or_version(env!("VERGEN_GIT_DESCRIBE")),
113 option_env!("VERGEN_GIT_SHA").unwrap_or("None"),
114 value_or_none(option_env!("VERGEN_GIT_COMMIT_TIMESTAMP").unwrap_or_default()),
115 value_or_none(option_env!("VERGEN_GIT_BRANCH").unwrap_or_default()),
116 env!("VERGEN_CARGO_TARGET_TRIPLE"),
117 env!("TYPST_VERSION"),
118 env!("TYPST_SOURCE"),
119 )
120});
121
122#[cfg(test)]
123mod tests {
124 use super::*;
125
126 #[test]
127 fn test_long_version_first_line_has_version() {
128 let first_line = LONG_VERSION.lines().next().unwrap();
129 let expected = format!("v{}", env!("CARGO_PKG_VERSION"));
130 assert_eq!(first_line, expected);
131 assert!(first_line.starts_with('v'));
132 assert!(first_line.len() > 1);
133 }
134
135 #[test]
136 fn test_git_describe_or_version_falls_back() {
137 assert_eq!(git_describe_or_version(""), env!("CARGO_PKG_VERSION"));
138 assert_eq!(
139 git_describe_or_version("VERGEN_IDEMPOTENT_OUTPUT"),
140 env!("CARGO_PKG_VERSION")
141 );
142 assert_eq!(git_describe_or_version("v0.15.8"), "v0.15.8");
143 }
144
145 #[test]
146 fn test_value_or_none_falls_back() {
147 assert_eq!(value_or_none(""), "None");
148 assert_eq!(value_or_none("VERGEN_IDEMPOTENT_OUTPUT"), "None");
149 assert_eq!(value_or_none("main"), "main");
150 }
151}