diff --git a/Cargo.lock b/Cargo.lock
index 86c4095a4..643c988b2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8,6 +8,18 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+[[package]]
+name = "ahash"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
+dependencies = [
+ "cfg-if",
+ "getrandom",
+ "once_cell",
+ "version_check",
+]
+
[[package]]
name = "aho-corasick"
version = "0.7.20"
@@ -483,6 +495,19 @@ dependencies = [
"syn 2.0.15",
]
+[[package]]
+name = "dashmap"
+version = "5.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc"
+dependencies = [
+ "cfg-if",
+ "hashbrown",
+ "lock_api",
+ "once_cell",
+ "parking_lot_core",
+]
+
[[package]]
name = "data-url"
version = "0.1.1"
@@ -558,6 +583,15 @@ dependencies = [
"syn 1.0.109",
]
+[[package]]
+name = "env_logger"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
+dependencies = [
+ "log",
+]
+
[[package]]
name = "errno"
version = "0.3.1"
@@ -589,6 +623,15 @@ dependencies = [
"regex",
]
+[[package]]
+name = "fastrand"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
+dependencies = [
+ "instant",
+]
+
[[package]]
name = "fdeflate"
version = "0.3.0"
@@ -606,7 +649,7 @@ checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153"
dependencies = [
"cfg-if",
"libc",
- "redox_syscall",
+ "redox_syscall 0.2.16",
"windows-sys 0.48.0",
]
@@ -870,6 +913,29 @@ dependencies = [
"rayon",
]
+[[package]]
+name = "inferno"
+version = "0.11.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2fb7c1b80a1dfa604bb4a649a5c5aeef3d913f7c520cb42b40e534e8a61bcdfc"
+dependencies = [
+ "ahash",
+ "clap 4.2.4",
+ "crossbeam-channel",
+ "crossbeam-utils",
+ "dashmap",
+ "env_logger",
+ "indexmap",
+ "is-terminal",
+ "itoa",
+ "log",
+ "num-format",
+ "once_cell",
+ "quick-xml",
+ "rgb",
+ "str_stack",
+]
+
[[package]]
name = "inotify"
version = "0.9.6"
@@ -890,6 +956,15 @@ dependencies = [
"libc",
]
+[[package]]
+name = "instant"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
+dependencies = [
+ "cfg-if",
+]
+
[[package]]
name = "io-lifetimes"
version = "1.0.10"
@@ -1067,6 +1142,16 @@ dependencies = [
"rand_chacha",
]
+[[package]]
+name = "lock_api"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"
+dependencies = [
+ "autocfg",
+ "scopeguard",
+]
+
[[package]]
name = "log"
version = "0.4.17"
@@ -1164,6 +1249,16 @@ dependencies = [
"windows-sys 0.42.0",
]
+[[package]]
+name = "nu-ansi-term"
+version = "0.46.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
+dependencies = [
+ "overload",
+ "winapi",
+]
+
[[package]]
name = "num-bigint"
version = "0.4.3"
@@ -1175,6 +1270,16 @@ dependencies = [
"num-traits",
]
+[[package]]
+name = "num-format"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3"
+dependencies = [
+ "arrayvec 0.7.2",
+ "itoa",
+]
+
[[package]]
name = "num-integer"
version = "0.1.45"
@@ -1243,6 +1348,12 @@ version = "6.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267"
+[[package]]
+name = "overload"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
+
[[package]]
name = "oxipng"
version = "8.0.0"
@@ -1267,6 +1378,19 @@ dependencies = [
"zopfli",
]
+[[package]]
+name = "parking_lot_core"
+version = "0.9.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall 0.2.16",
+ "smallvec",
+ "windows-sys 0.45.0",
+]
+
[[package]]
name = "paste"
version = "1.0.12"
@@ -1320,6 +1444,12 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468"
+[[package]]
+name = "pin-project-lite"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
+
[[package]]
name = "pixglyph"
version = "0.1.0"
@@ -1357,6 +1487,15 @@ dependencies = [
"unicode-ident",
]
+[[package]]
+name = "psm"
+version = "0.1.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "pulldown-cmark"
version = "0.9.2"
@@ -1369,6 +1508,15 @@ dependencies = [
"unicase",
]
+[[package]]
+name = "quick-xml"
+version = "0.26.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd"
+dependencies = [
+ "memchr",
+]
+
[[package]]
name = "quote"
version = "1.0.26"
@@ -1446,6 +1594,15 @@ dependencies = [
"bitflags",
]
+[[package]]
+name = "redox_syscall"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
+dependencies = [
+ "bitflags",
+]
+
[[package]]
name = "redox_users"
version = "0.4.3"
@@ -1453,7 +1610,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
"getrandom",
- "redox_syscall",
+ "redox_syscall 0.2.16",
"thiserror",
]
@@ -1688,6 +1845,15 @@ dependencies = [
"yaml-rust",
]
+[[package]]
+name = "sharded-slab"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
+dependencies = [
+ "lazy_static",
+]
+
[[package]]
name = "simd-adler32"
version = "0.3.5"
@@ -1727,6 +1893,19 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
+[[package]]
+name = "stacker"
+version = "0.1.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce"
+dependencies = [
+ "cc",
+ "cfg-if",
+ "libc",
+ "psm",
+ "winapi",
+]
+
[[package]]
name = "stderrlog"
version = "0.5.4"
@@ -1739,6 +1918,12 @@ dependencies = [
"thread_local",
]
+[[package]]
+name = "str_stack"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb"
+
[[package]]
name = "strsim"
version = "0.10.0"
@@ -1843,6 +2028,19 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
+[[package]]
+name = "tempfile"
+version = "3.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998"
+dependencies = [
+ "cfg-if",
+ "fastrand",
+ "redox_syscall 0.3.5",
+ "rustix",
+ "windows-sys 0.45.0",
+]
+
[[package]]
name = "termcolor"
version = "1.1.3"
@@ -1932,6 +2130,85 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
+[[package]]
+name = "tracing"
+version = "0.1.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
+dependencies = [
+ "cfg-if",
+ "pin-project-lite",
+ "tracing-attributes",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-attributes"
+version = "0.1.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
+dependencies = [
+ "once_cell",
+ "valuable",
+]
+
+[[package]]
+name = "tracing-error"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e"
+dependencies = [
+ "tracing",
+ "tracing-subscriber",
+]
+
+[[package]]
+name = "tracing-flame"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0bae117ee14789185e129aaee5d93750abe67fdc5a9a62650452bfe4e122a3a9"
+dependencies = [
+ "lazy_static",
+ "tracing",
+ "tracing-subscriber",
+]
+
+[[package]]
+name = "tracing-log"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
+dependencies = [
+ "lazy_static",
+ "log",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-subscriber"
+version = "0.3.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
+dependencies = [
+ "nu-ansi-term",
+ "sharded-slab",
+ "smallvec",
+ "thread_local",
+ "tracing-core",
+ "tracing-log",
+]
+
[[package]]
name = "ttf-parser"
version = "0.15.2"
@@ -1980,10 +2257,12 @@ dependencies = [
"rustybuzz",
"serde",
"siphasher",
+ "stacker",
"subsetter",
"svg2pdf",
"thin-vec",
"tiny-skia",
+ "tracing",
"ttf-parser 0.18.1",
"typst-macros",
"unicode-math-class",
@@ -2006,12 +2285,18 @@ dependencies = [
"comemo",
"dirs",
"elsa",
+ "inferno",
"memmap2",
"notify",
"once_cell",
"open",
"same-file",
"siphasher",
+ "tempfile",
+ "tracing",
+ "tracing-error",
+ "tracing-flame",
+ "tracing-subscriber",
"typst",
"typst-library",
"walkdir",
@@ -2056,6 +2341,7 @@ dependencies = [
"serde_yaml",
"smallvec",
"syntect",
+ "tracing",
"ttf-parser 0.18.1",
"typed-arena",
"typst",
@@ -2276,6 +2562,12 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
+[[package]]
+name = "valuable"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
+
[[package]]
name = "version_check"
version = "0.9.4"
diff --git a/Cargo.toml b/Cargo.toml
index 9c437fd46..36845812c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -51,10 +51,12 @@ unicode-xid = "0.2"
unscanny = "0.1"
usvg = { version = "0.22", default-features = false, features = ["text"] }
xmp-writer = "0.1"
+tracing = "0.1.37"
indexmap = "1.9.3"
+stacker = "0.1.15"
[profile.dev]
-debug = 0
+debug = false
[profile.dev.package."*"]
opt-level = 2
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 768c60530..7719874d4 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -34,6 +34,12 @@ siphasher = "0.3"
walkdir = "2"
clap = { version = "4.2.1", features = ["derive", "env"] }
open = "4.0.1"
+tracing = "0.1.37"
+tracing-subscriber = "0.3.16"
+tracing-flame = "0.2.0"
+tracing-error = "0.2"
+inferno = "0.11.15"
+tempfile = "3.5.0"
[build-dependencies]
clap = { version = "4.2.1", features = ["derive", "string"] }
diff --git a/cli/build.rs b/cli/build.rs
index 75e8492af..b6f7d6eef 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -24,9 +24,9 @@ pub fn typst_version() -> String {
format!("{pkg} ({hash})")
}
-mod args {
- include!("src/args.rs");
-}
+#[path = "src/args.rs"]
+#[allow(dead_code)]
+mod args;
fn main() {
println!("cargo:rerun-if-env-changed=TYPST_VERSION");
diff --git a/cli/src/args.rs b/cli/src/args.rs
index 42d52140f..699dbb97d 100644
--- a/cli/src/args.rs
+++ b/cli/src/args.rs
@@ -17,6 +17,10 @@ pub struct CliArguments {
/// The typst command to run
#[command(subcommand)]
pub command: Command,
+
+ /// Sets the level of verbosity: 0 = none, 1 = warning & error, 2 = info, 3 = debug, 4 = trace
+ #[clap(short, long, action = ArgAction::Count)]
+ pub verbosity: u8,
}
/// What to do.
@@ -35,6 +39,22 @@ pub enum Command {
Fonts(FontsCommand),
}
+impl Command {
+ /// Returns the compile command if this is a compile or watch command.
+ pub fn as_compile(&self) -> Option<&CompileCommand> {
+ match self {
+ Command::Compile(cmd) => Some(cmd),
+ Command::Watch(cmd) => Some(cmd),
+ Command::Fonts(_) => None,
+ }
+ }
+
+ /// Returns whether this is a watch command.
+ pub fn is_watch(&self) -> bool {
+ matches!(self, Command::Watch(_))
+ }
+}
+
/// Compiles the input file into a PDF file
#[derive(Debug, Clone, Parser)]
pub struct CompileCommand {
@@ -47,6 +67,11 @@ pub struct CompileCommand {
/// Opens the output file after compilation using the default PDF viewer
#[arg(long = "open")]
pub open: Option