From 37ed1ef45d441bb2397db85fe9f684b1419d3a05 Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin Date: Thu, 6 Feb 2025 11:06:54 +0800 Subject: [PATCH] g2 --- Cargo.lock | 832 ++++++++++-------- Cargo.toml | 22 +- cli/src/compile.rs | 80 +- cli/src/export.rs | 265 +++--- cli/src/main.rs | 29 +- cli/src/query_repl.rs | 21 +- crates/reflexo-typst/Cargo.toml | 1 + crates/reflexo-typst/src/compile.rs | 171 ++-- crates/reflexo-typst/src/diag/console.rs | 73 +- crates/reflexo-typst/src/driver.rs | 32 +- crates/reflexo-typst/src/export.rs | 453 +++++----- .../src/export/dynamic_layout.rs | 92 +- crates/reflexo-typst/src/exporter.rs | 320 +------ crates/reflexo-typst/src/exporter/ast.rs | 66 +- crates/reflexo-typst/src/exporter/dyn_svg.rs | 279 ++++++ crates/reflexo-typst/src/exporter/html.rs | 18 +- crates/reflexo-typst/src/exporter/json.rs | 155 ++-- crates/reflexo-typst/src/exporter/pdf.rs | 39 - crates/reflexo-typst/src/exporter/prelude.rs | 10 + crates/reflexo-typst/src/exporter/svg.rs | 139 ++- crates/reflexo-typst/src/exporter/text.rs | 67 +- crates/reflexo-typst/src/lib.rs | 289 +++--- crates/reflexo-typst/src/task.rs | 3 + packages/compiler/src/lib.rs | 71 +- packages/typst.node/src/compiler/boxed.rs | 63 +- packages/typst.node/src/compiler/mod.rs | 6 +- packages/typst.node/src/error.rs | 39 +- packages/typst.node/src/lib.rs | 57 +- server/dev/src/main.rs | 30 +- tests/integration/src/lib.rs | 72 +- 30 files changed, 1928 insertions(+), 1866 deletions(-) create mode 100644 crates/reflexo-typst/src/exporter/dyn_svg.rs create mode 100644 crates/reflexo-typst/src/exporter/prelude.rs diff --git a/Cargo.lock b/Cargo.lock index 04f2ef4a4..df1d8efb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,9 +81,9 @@ dependencies = [ [[package]] name = "ansi-to-html" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d73c455ae09fa2223a75114789f30ad605e9e297f79537953523366c05995f5f" +checksum = "12e283a4fc285735ef99577e81a125f738429516161ac33977e466d0d8d40764" dependencies = [ "regex", "thiserror 1.0.69", @@ -139,19 +139,20 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "approx" @@ -185,9 +186,9 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-compression" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cb8f1d480b0ea3783ab015936d2a55c87e219676f0c0b7dec61494043f21857" +checksum = "df895a515f70646414f4b45c0b79082783b80552b373a68283012928df56f522" dependencies = [ "brotli", "flate2", @@ -205,18 +206,18 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -303,9 +304,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" dependencies = [ "serde", ] @@ -344,9 +345,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "4.0.1" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" +checksum = "74fa05ad7d803d413eb8380983b092cbbaf9a85f151b871360e7b00cd7060b37" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -354,9 +355,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "by_address" @@ -388,9 +389,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.19.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" [[package]] name = "byteorder" @@ -406,9 +407,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "bytes" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" [[package]] name = "camino" @@ -421,32 +422,32 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" dependencies = [ "serde", ] [[package]] name = "cargo_metadata" -version = "0.18.1" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +checksum = "8769706aad5d996120af43197bf46ef6ad0fda35216b4505f926a365a232d924" dependencies = [ "camino", "cargo-platform", "semver", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.11", ] [[package]] name = "cc" -version = "1.2.1" +version = "1.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf" dependencies = [ "shlex", ] @@ -489,9 +490,9 @@ checksum = "7588475145507237ded760e52bf2f1085495245502033756d28ea72ade0e498b" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -541,9 +542,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.21" +version = "4.5.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" +checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796" dependencies = [ "clap_builder", "clap_derive", @@ -551,9 +552,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.21" +version = "4.5.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" +checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" dependencies = [ "anstream", "anstyle", @@ -566,9 +567,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.38" +version = "4.5.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9647a559c112175f17cf724dc72d3645680a883c58481332779192b0d8e7a01" +checksum = "375f9d8255adeeedd51053574fd8d4ba875ea5fa558e86617b07f09f1680c8b6" dependencies = [ "clap", ] @@ -585,27 +586,27 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "clap_lex" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "clap_mangen" -version = "0.2.24" +version = "0.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbae9cbfdc5d4fa8711c09bd7b83f644cb48281ac35bf97af3e47b0675864bdf" +checksum = "724842fa9b144f9b89b3f3d371a89f3455eea660361d13a554f68f8ae5d6c13a" dependencies = [ "clap", "roff", @@ -662,7 +663,7 @@ dependencies = [ "comemo-macros", "once_cell", "parking_lot", - "siphasher 1.0.1", + "siphasher", ] [[package]] @@ -673,7 +674,7 @@ checksum = "c8936e42f9b4f5bdfaf23700609ac1f11cb03ad4c1ec128a4ee4fd0903e228db" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -684,14 +685,14 @@ checksum = "baf0a07a401f374238ab8e2f11a104d2851bf9ce711ec69804834de8af45c7af" [[package]] name = "console" -version = "0.15.8" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" dependencies = [ "encode_unicode", - "lazy_static", "libc", - "windows-sys 0.52.0", + "once_cell", + "windows-sys 0.59.0", ] [[package]] @@ -731,18 +732,18 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "core_maths" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b02505ccb8c50b0aa21ace0fc08c3e53adebd4e58caa18a36152803c7709a3" +checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" dependencies = [ "libm", ] [[package]] name = "cpufeatures" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] @@ -758,18 +759,18 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.13" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -786,24 +787,24 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" [[package]] name = "crypto-common" @@ -838,12 +839,12 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" +checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" dependencies = [ "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -867,7 +868,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -878,7 +879,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -928,7 +929,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -938,7 +939,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -996,14 +997,14 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "divan" -version = "0.1.15" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e05d17bd4ff1c1e7998ed4623d2efd91f72f1e24141ac33aac9377974270e1f" +checksum = "e0583193020b29b03682d8d33bb53a5b0f50df6daacece12ca99b904cfdcb8c4" dependencies = [ "cfg-if", "clap", @@ -1015,13 +1016,13 @@ dependencies = [ [[package]] name = "divan-macros" -version = "0.1.15" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b4464d46ce68bfc7cb76389248c7c254def7baca8bece0693b02b83842c4c88" +checksum = "8dc51d98e636f5e3b0759a39257458b22619cac7e96d932da6eeb052891bb67c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -1047,9 +1048,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elsa" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d98e71ae4df57d214182a2e5cb90230c0192c6ddfcaa05c36453d46a54713e10" +checksum = "2343daaeabe09879d4ea058bb4f1e63da3fc07dadc6634e01bda1b3d6a9d9d2b" dependencies = [ "stable_deref_trait", ] @@ -1068,9 +1069,9 @@ checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" [[package]] name = "encode_unicode" -version = "0.3.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "endian-type" @@ -1095,14 +1096,14 @@ checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "env_filter" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", "regex", @@ -1110,9 +1111,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" dependencies = [ "anstream", "anstyle", @@ -1129,12 +1130,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1178,9 +1179,9 @@ dependencies = [ [[package]] name = "fdeflate" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c6f4c64c1d33a3111c4466f7365ebdcc37c5bd1ea0d62aae2e3d722aacbedb" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" dependencies = [ "simd-adler32", ] @@ -1322,7 +1323,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -1452,9 +1453,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "hayagriva" @@ -1507,12 +1508,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "hex" version = "0.4.3" @@ -1521,11 +1516,11 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "home" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1541,9 +1536,9 @@ dependencies = [ [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -1568,7 +1563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.1.0", + "http 1.2.0", ] [[package]] @@ -1579,16 +1574,16 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "pin-project-lite", ] [[package]] name = "httparse" -version = "1.9.5" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" [[package]] name = "httpdate" @@ -1620,9 +1615,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.31" +version = "0.14.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" dependencies = [ "bytes", "futures-channel", @@ -1644,14 +1639,14 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "httparse", "itoa", @@ -1663,13 +1658,13 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.3" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", - "http 1.1.0", - "hyper 1.5.0", + "http 1.2.0", + "hyper 1.6.0", "hyper-util", "rustls", "rustls-pki-types", @@ -1688,9 +1683,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.0", + "hyper 1.6.0", "pin-project-lite", "socket2", "tokio", @@ -1873,7 +1868,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -1995,7 +1990,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", - "hashbrown 0.15.1", + "hashbrown 0.15.2", "serde", ] @@ -2027,22 +2022,23 @@ dependencies = [ [[package]] name = "insta" -version = "1.41.1" +version = "1.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9ffc4d4892617c50a928c52b2961cb5174b6fc6ebf252b2fac9d21955c48b8" +checksum = "71c1b125e30d93896b365e156c33dadfffab45ee8400afcbba4752f59de08a86" dependencies = [ "console", - "lazy_static", "linked-hash-map", + "once_cell", + "pin-project", "serde", "similar", ] [[package]] name = "ipnet" -version = "2.10.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "is_terminal_polyfill" @@ -2052,16 +2048,17 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -2112,15 +2109,15 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.162" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libloading" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", "windows-targets 0.52.6", @@ -2138,7 +2135,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "libc", "redox_syscall", ] @@ -2151,9 +2148,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "lipsum" @@ -2167,9 +2164,9 @@ dependencies = [ [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" dependencies = [ "serde", ] @@ -2186,9 +2183,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "lsp-types" @@ -2246,9 +2243,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ "adler2", "simd-adler32", @@ -2274,11 +2271,10 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi", "libc", "wasi", "windows-sys 0.52.0", @@ -2298,11 +2294,11 @@ checksum = "16cf681a23b4d0a43fc35024c176437f9dcd818db34e0f42ab456a0ee5ad497b" [[package]] name = "napi" -version = "2.16.13" +version = "2.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "214f07a80874bb96a8433b3cdfc84980d56c7b02e1a0d7ba4ba0db5cef785e2b" +checksum = "c513bcb85385ad355b734a0704fd39e6756c44b37d06517b79818e660a81c074" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "ctor", "napi-derive", "napi-sys", @@ -2313,29 +2309,29 @@ dependencies = [ [[package]] name = "napi-build" -version = "2.1.3" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a" +checksum = "db836caddef23662b94e16bf1f26c40eceb09d6aee5d5b06a7ac199320b69b19" [[package]] name = "napi-derive" -version = "2.16.12" +version = "2.16.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17435f7a00bfdab20b0c27d9c56f58f6499e418252253081bfff448099da31d1" +checksum = "7cbe2585d8ac223f7d34f13701434b9d5f4eb9c332cccce8dee57ea18ab8ab0c" dependencies = [ "cfg-if", "convert_case", "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "napi-derive-backend" -version = "1.0.74" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "967c485e00f0bf3b1bdbe510a38a4606919cf1d34d9a37ad41f25a81aa077abe" +checksum = "1639aaa9eeb76e91c6ae66da8ce3e89e921cd3885e99ec85f4abacae72fc91bf" dependencies = [ "convert_case", "once_cell", @@ -2343,7 +2339,7 @@ dependencies = [ "quote", "regex", "semver", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -2370,7 +2366,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "cfg-if", "cfg_aliases 0.1.1", "libc", @@ -2388,7 +2384,7 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "crossbeam-channel", "filetime", "fsevent-sys", @@ -2461,9 +2457,9 @@ checksum = "e25be21376a772d15f97ae789845340a9651d3c4246ff5ebb6a2b35f9c37bd31" [[package]] name = "object" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] @@ -2482,9 +2478,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "os_info" -version = "3.8.2" +version = "3.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae99c7fa6dd38c7cafe1ec085e804f8f555a2f8659b0dbe03f1f9963a9b51092" +checksum = "6e6520c8cc998c5741ee68ec1dc369fc47e5f0ea5320018ecf2a1ccd6328f48b" dependencies = [ "log", "serde", @@ -2512,7 +2508,7 @@ dependencies = [ "by_address", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -2552,9 +2548,9 @@ checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" [[package]] name = "pathdiff" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" [[package]] name = "pdf-writer" @@ -2562,7 +2558,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be17f48d7fbbd22c6efedb58af5d409aa578e407f40b29a0bcb4e66ed84c5c98" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "itoa", "memchr", "ryu", @@ -2576,9 +2572,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "phf" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" dependencies = [ "phf_macros", "phf_shared", @@ -2586,9 +2582,9 @@ dependencies = [ [[package]] name = "phf_generator" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ "phf_shared", "rand", @@ -2596,24 +2592,24 @@ dependencies = [ [[package]] name = "phf_macros" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" dependencies = [ "phf_generator", "phf_shared", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "phf_shared" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ - "siphasher 0.3.11", + "siphasher", ] [[package]] @@ -2624,29 +2620,29 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" [[package]] name = "pin-project" -version = "1.1.7" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" +checksum = "dfe2e71e1471fe07709406bf725f710b02927c9c54b2b5b2ec0e8087d97c327d" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.7" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" +checksum = "f6e859e6e5bd50440ab63c47e3ebabc90f26251f7c73c3d3e837b74a1cc3fa67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -2654,6 +2650,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pixglyph" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d15afa937836bf3d876f5a04ce28810c06045857bf46c3d0d31073b8aada5494" +dependencies = [ + "ttf-parser", +] + [[package]] name = "plist" version = "1.7.0" @@ -2669,9 +2674,9 @@ dependencies = [ [[package]] name = "png" -version = "0.17.14" +version = "0.17.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -2688,15 +2693,15 @@ checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" [[package]] name = "portable-atomic" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "postcard" -version = "1.0.10" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e" +checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8" dependencies = [ "cobs", "embedded-io 0.4.0", @@ -2730,9 +2735,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -2807,10 +2812,10 @@ dependencies = [ "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash 2.0.0", + "rustc-hash 2.1.0", "rustls", "socket2", - "thiserror 2.0.3", + "thiserror 2.0.11", "tokio", "tracing", ] @@ -2825,11 +2830,11 @@ dependencies = [ "getrandom", "rand", "ring", - "rustc-hash 2.0.0", + "rustc-hash 2.1.0", "rustls", "rustls-pki-types", "slab", - "thiserror 2.0.3", + "thiserror 2.0.11", "tinyvec", "tracing", "web-time", @@ -2837,9 +2842,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" +checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904" dependencies = [ "cfg_aliases 0.2.1", "libc", @@ -2851,9 +2856,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -2935,11 +2940,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", ] [[package]] @@ -2968,12 +2973,12 @@ dependencies = [ "parking_lot", "path-clean", "rkyv", - "rustc-hash 2.0.0", + "rustc-hash 2.1.0", "serde", "serde_json", "serde_repr", "serde_with", - "siphasher 1.0.1", + "siphasher", "tiny-skia-path", "tinymist-std", "typst", @@ -3008,6 +3013,7 @@ dependencies = [ "serde", "serde_json", "tar", + "tinymist-task", "tinymist-world", "tokio", "typst", @@ -3032,7 +3038,7 @@ dependencies = [ "rayon", "reflexo", "rkyv", - "rustc-hash 2.0.0", + "rustc-hash 2.1.0", "serde", "serde_json", "svgtypes", @@ -3168,19 +3174,19 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.9" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" dependencies = [ "base64 0.22.1", "bytes", "futures-channel", "futures-core", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.6.0", "hyper-rustls", "hyper-util", "ipnet", @@ -3201,6 +3207,7 @@ dependencies = [ "sync_wrapper", "tokio", "tokio-rustls", + "tower", "tower-service", "url", "wasm-bindgen", @@ -3325,9 +3332,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" [[package]] name = "rustc_version" @@ -3364,22 +3371,22 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.40" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "9fb9263ab4eb695e42321db096e3b8fbd715a59b154d5c88d82db2175b681ba7" dependencies = [ "once_cell", "ring", @@ -3400,9 +3407,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" dependencies = [ "web-time", ] @@ -3420,9 +3427,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "rustybuzz" @@ -3430,7 +3437,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c85d1ccd519e61834798eb52c4e886e8c2d7d698dd3d6ce0b1b47eb8557f1181" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "bytemuck", "core_maths", "log", @@ -3448,7 +3455,7 @@ version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7803e8936da37efd9b6d4478277f4b2b9bb5cdb37a113e8d63222e58da647e63" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "cfg-if", "clipboard-win", "fd-lock", @@ -3473,14 +3480,14 @@ checksum = "e5af959c8bf6af1aff6d2b463a57f71aae53d1332da58419e30ad8dc7011d951" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "same-file" @@ -3511,9 +3518,9 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "semver" -version = "1.0.23" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" dependencies = [ "serde", ] @@ -3526,9 +3533,9 @@ checksum = "930c0acf610d3fdb5e2ab6213019aaa04e227ebe9547b0649ba599b16d788bd7" [[package]] name = "serde" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] @@ -3546,20 +3553,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", "memchr", @@ -3575,7 +3582,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -3601,9 +3608,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" dependencies = [ "base64 0.22.1", "chrono", @@ -3619,14 +3626,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -3693,25 +3700,19 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "similar" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" [[package]] name = "simplecss" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a11be7c62927d9427e9f40f3444d5499d868648e2edbc4e2116de69e7ec0e89d" +checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c" dependencies = [ "log", ] -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - [[package]] name = "siphasher" version = "1.0.1" @@ -3744,9 +3745,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -3828,7 +3829,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -3856,7 +3857,7 @@ dependencies = [ "once_cell", "pdf-writer", "resvg", - "siphasher 1.0.1", + "siphasher", "subsetter", "tiny-skia", "ttf-parser", @@ -3865,12 +3866,12 @@ dependencies = [ [[package]] name = "svgtypes" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794de53cc48eaabeed0ab6a3404a65f40b3e38c067e4435883a65d2aa4ca000e" +checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc" dependencies = [ "kurbo", - "siphasher 1.0.1", + "siphasher", ] [[package]] @@ -3886,9 +3887,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -3897,9 +3898,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] @@ -3912,7 +3913,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -3965,7 +3966,7 @@ dependencies = [ "getrandom", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3979,9 +3980,9 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" +checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" dependencies = [ "rustix", "windows-sys 0.59.0", @@ -4004,11 +4005,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.3" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl 2.0.3", + "thiserror-impl 2.0.11", ] [[package]] @@ -4019,18 +4020,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "thiserror-impl" -version = "2.0.3" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -4041,9 +4042,9 @@ checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" [[package]] name = "time" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "itoa", @@ -4064,9 +4065,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" dependencies = [ "num-conv", "time-core", @@ -4101,7 +4102,6 @@ dependencies = [ [[package]] name = "tinymist-analysis" version = "0.12.19-rc4" -source = "git+https://github.com/Myriad-Dreamin/tinymist.git?rev=665b27a6291d02375bd58664edcd7db0f44bfe03#665b27a6291d02375bd58664edcd7db0f44bfe03" dependencies = [ "ecow", "lsp-types", @@ -4111,10 +4111,17 @@ dependencies = [ "typst", ] +[[package]] +name = "tinymist-derive" +version = "0.12.19-rc4" +dependencies = [ + "quote", + "syn 2.0.98", +] + [[package]] name = "tinymist-std" version = "0.12.19-rc4" -source = "git+https://github.com/Myriad-Dreamin/tinymist.git?rev=665b27a6291d02375bd58664edcd7db0f44bfe03#665b27a6291d02375bd58664edcd7db0f44bfe03" dependencies = [ "anyhow", "base64 0.22.1", @@ -4130,13 +4137,13 @@ dependencies = [ "parking_lot", "path-clean", "rkyv", - "rustc-hash 2.0.0", + "rustc-hash 2.1.0", "same-file", "serde", "serde_json", "serde_repr", "serde_with", - "siphasher 1.0.1", + "siphasher", "tempfile", "tinymist-analysis", "typst", @@ -4146,10 +4153,43 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "tinymist-task" +version = "0.12.19-rc4" +dependencies = [ + "anyhow", + "chrono", + "clap", + "comemo", + "dirs", + "ecow", + "log", + "notify", + "parking_lot", + "pathdiff", + "rayon", + "rpds", + "semver", + "serde", + "serde_json", + "serde_yaml", + "tinymist-derive", + "tinymist-std", + "tinymist-world", + "tokio", + "toml", + "typst", + "typst-assets 0.12.0 (git+https://github.com/typst/typst-assets?rev=8cccef9)", + "typst-eval", + "typst-html", + "typst-pdf", + "typst-render", + "typst-svg", +] + [[package]] name = "tinymist-vfs" version = "0.12.19-rc4" -source = "git+https://github.com/Myriad-Dreamin/tinymist.git?rev=665b27a6291d02375bd58664edcd7db0f44bfe03#665b27a6291d02375bd58664edcd7db0f44bfe03" dependencies = [ "comemo", "indexmap 2.7.1", @@ -4167,7 +4207,6 @@ dependencies = [ [[package]] name = "tinymist-world" version = "0.12.19-rc4" -source = "git+https://github.com/Myriad-Dreamin/tinymist.git?rev=665b27a6291d02375bd58664edcd7db0f44bfe03#665b27a6291d02375bd58664edcd7db0f44bfe03" dependencies = [ "anyhow", "chrono", @@ -4183,6 +4222,7 @@ dependencies = [ "log", "parking_lot", "reqwest", + "rpds", "serde", "serde-wasm-bindgen", "serde_json", @@ -4193,7 +4233,7 @@ dependencies = [ "tinymist-std", "tinymist-vfs", "typst", - "typst-assets 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typst-assets 0.12.0 (git+https://github.com/typst/typst-assets?rev=8cccef9)", "wasm-bindgen", "web-sys", ] @@ -4211,9 +4251,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" dependencies = [ "tinyvec_macros", ] @@ -4226,14 +4266,14 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.1" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", "libc", - "mio 1.0.2", + "mio 1.0.3", "parking_lot", "pin-project-lite", "signal-hook-registry", @@ -4244,31 +4284,30 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "tokio-rustls" -version = "0.26.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ "rustls", - "rustls-pki-types", "tokio", ] [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", @@ -4300,9 +4339,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.22.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" dependencies = [ "indexmap 2.7.1", "serde", @@ -4311,6 +4350,27 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" version = "0.3.3" @@ -4319,9 +4379,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -4330,9 +4390,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", ] @@ -4370,9 +4430,9 @@ dependencies = [ [[package]] name = "two-face" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ccd4843ea031c609fe9c16cae00e9657bad8a9f735a3cc2e420955d802b4268" +checksum = "d9094d135e70a13e98be717063aa3fda2761946182a40584ed9941f52d8a768a" dependencies = [ "once_cell", "serde", @@ -4409,12 +4469,6 @@ dependencies = [ "typst-utils", ] -[[package]] -name = "typst-assets" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe00da1b24da2c4a7da532fc33d0c3bd43a902ca4c408ee2c36eabe70f2f4ba" - [[package]] name = "typst-assets" version = "0.12.0" @@ -4516,7 +4570,7 @@ version = "0.13.0" source = "git+https://github.com/ParaN3xus/typst?tag=tinymist-nightly-v0.12.19-rc2-content-hint#af49797ee72c87c6b2cf7005740c5c8ebded16e5" dependencies = [ "az", - "bitflags 2.6.0", + "bitflags 2.8.0", "bumpalo", "chinese-number", "ciborium", @@ -4548,7 +4602,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "siphasher 1.0.1", + "siphasher", "smallvec", "syntect", "time", @@ -4577,7 +4631,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -4624,10 +4678,26 @@ dependencies = [ "typst-utils", ] +[[package]] +name = "typst-render" +version = "0.13.0" +source = "git+https://github.com/ParaN3xus/typst?tag=tinymist-nightly-v0.12.19-rc2-content-hint#af49797ee72c87c6b2cf7005740c5c8ebded16e5" +dependencies = [ + "bytemuck", + "comemo", + "image", + "pixglyph", + "resvg", + "tiny-skia", + "ttf-parser", + "typst-library", + "typst-macros", + "typst-timing", +] + [[package]] name = "typst-shim" version = "0.12.19-rc4" -source = "git+https://github.com/Myriad-Dreamin/tinymist.git?rev=665b27a6291d02375bd58664edcd7db0f44bfe03#665b27a6291d02375bd58664edcd7db0f44bfe03" dependencies = [ "cfg-if", "comemo", @@ -4935,7 +5005,7 @@ dependencies = [ "once_cell", "portable-atomic", "rayon", - "siphasher 1.0.1", + "siphasher", "thin-vec", ] @@ -4960,9 +5030,9 @@ dependencies = [ [[package]] name = "unicase" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" [[package]] name = "unicode-bidi" @@ -4984,9 +5054,9 @@ checksum = "260bc6647b3893a9a90668360803a15f96b85a5257b1c3a0c3daf6ae2496de42" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "unicode-math-class" @@ -5059,9 +5129,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.3" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -5086,7 +5156,7 @@ dependencies = [ "roxmltree", "rustybuzz", "simplecss", - "siphasher 1.0.1", + "siphasher", "strict-num", "svgtypes", "tiny-skia-path", @@ -5116,18 +5186,18 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.11.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" +checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" dependencies = [ "getrandom", ] [[package]] name = "vergen" -version = "9.0.1" +version = "9.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349ed9e45296a581f455bc18039878f409992999bc1d5da12a6800eb18c8752f" +checksum = "e0d2f179f8075b805a43a2a21728a46f0cc2921b3c58695b28fa8817e103cd9a" dependencies = [ "anyhow", "cargo_metadata", @@ -5141,9 +5211,9 @@ dependencies = [ [[package]] name = "vergen-gitcl" -version = "1.0.1" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3a7f91caabecefc3c249fd864b11d4abe315c166fbdb568964421bccfd2b7a" +checksum = "b2f89d70a58a4506a6079cedf575c64cf51649ccbb4e02a63dac539b264b7711" dependencies = [ "anyhow", "derive_builder", @@ -5155,9 +5225,9 @@ dependencies = [ [[package]] name = "vergen-lib" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229eaddb0050920816cf051e619affaf18caa3dd512de8de5839ccbc8e53abb0" +checksum = "9b07e6010c0f3e59fcb164e0163834597da68d1f864e2b8ca49f74de01e9c166" dependencies = [ "anyhow", "derive_builder", @@ -5201,7 +5271,7 @@ dependencies = [ "futures-util", "headers", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.32", "log", "mime", "mime_guess", @@ -5225,47 +5295,48 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.45" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5273,33 +5344,34 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-bindgen-test" -version = "0.3.45" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d381749acb0943d357dcbd8f0b100640679883fcdeeef04def49daf8d33a5426" +checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" dependencies = [ - "console_error_panic_hook", "js-sys", "minicov", - "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test-macro", @@ -5307,13 +5379,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.45" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c97b2ef2c8d627381e51c071c2ab328eac606d3f69dd82bcbca20a9e389d95f0" +checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -5371,9 +5443,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -5391,9 +5463,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.6" +version = "0.26.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9" dependencies = [ "rustls-pki-types", ] @@ -5624,9 +5696,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" dependencies = [ "memchr", ] @@ -5654,9 +5726,9 @@ dependencies = [ [[package]] name = "xattr" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" +checksum = "e105d177a3871454f754b33bb0ee637ecaaac997446375fd3e5d43a2ed00c909" dependencies = [ "libc", "linux-raw-sys", @@ -5692,9 +5764,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -5704,13 +5776,13 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", "synstructure", ] @@ -5732,27 +5804,27 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", "synstructure", ] @@ -5794,7 +5866,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.98", ] [[package]] @@ -5805,9 +5877,13 @@ checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" [[package]] name = "zune-jpeg" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16099418600b4d8f028622f73ff6e3deaabdff330fb9a2a131dea781ee8b0768" +checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028" dependencies = [ "zune-core", ] + +[[patch.unused]] +name = "tinymist-project" +version = "0.12.19-rc4" diff --git a/Cargo.toml b/Cargo.toml index 30f22c047..77fff30b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -197,7 +197,9 @@ vergen-gitcl = { version = "1.0.1" } # tinymist's world implementation typst-shim = { git = "https://github.com/Myriad-Dreamin/tinymist.git", rev = "665b27a6291d02375bd58664edcd7db0f44bfe03" } tinymist-analysis = { git = "https://github.com/Myriad-Dreamin/tinymist.git", rev = "665b27a6291d02375bd58664edcd7db0f44bfe03" } +tinymist-project = { git = "https://github.com/Myriad-Dreamin/tinymist.git", rev = "665b27a6291d02375bd58664edcd7db0f44bfe03" } tinymist-std = { git = "https://github.com/Myriad-Dreamin/tinymist.git", rev = "665b27a6291d02375bd58664edcd7db0f44bfe03", default-features = false } +tinymist-task = { git = "https://github.com/Myriad-Dreamin/tinymist.git", rev = "665b27a6291d02375bd58664edcd7db0f44bfe03", default-features = false } tinymist-world = { git = "https://github.com/Myriad-Dreamin/tinymist.git", rev = "665b27a6291d02375bd58664edcd7db0f44bfe03", default-features = false } # project core @@ -234,6 +236,10 @@ undocumented_unsafe_blocks = "warn" [patch.crates-io] +reflexo = { path = "crates/reflexo/" } +reflexo-typst = { path = "crates/reflexo-typst/" } +reflexo-vec2svg = { path = "crates/conversion/vec2svg/" } + # typst = { git = "https://github.com/Myriad-Dreamin/typst.git", branch = "typst.ts-v0.10.0" } # typst-syntax = { git = "https://github.com/Myriad-Dreamin/typst.git", branch = "typst.ts-v0.10.0" } # typst-ide = { git = "https://github.com/Myriad-Dreamin/typst.git", branch = "typst.ts-v0.10.0" } @@ -244,9 +250,13 @@ typst = { git = "https://github.com/ParaN3xus/typst", tag = "tinymist-nightly-v0 typst-syntax = { git = "https://github.com/ParaN3xus/typst", tag = "tinymist-nightly-v0.12.19-rc2-content-hint" } typst-ide = { git = "https://github.com/ParaN3xus/typst", tag = "tinymist-nightly-v0.12.19-rc2-content-hint" } typst-svg = { git = "https://github.com/ParaN3xus/typst", tag = "tinymist-nightly-v0.12.19-rc2-content-hint" } +typst-render = { git = "https://github.com/ParaN3xus/typst", tag = "tinymist-nightly-v0.12.19-rc2-content-hint" } typst-pdf = { git = "https://github.com/ParaN3xus/typst", tag = "tinymist-nightly-v0.12.19-rc2-content-hint" } typst-eval = { git = "https://github.com/ParaN3xus/typst", tag = "tinymist-nightly-v0.12.19-rc2-content-hint" } typst-html = { git = "https://github.com/ParaN3xus/typst", tag = "tinymist-nightly-v0.12.19-rc2-content-hint" } +typst-assets = { git = "https://github.com/typst/typst-assets", rev = "8cccef9", features = [ + "fonts", +] } # comemo = { path = "../comemo" } # typst = { path = "../typst/crates/typst" } @@ -257,8 +267,10 @@ typst-html = { git = "https://github.com/ParaN3xus/typst", tag = "tinymist-night # fontdb = { path = "../fontdb" } -# [patch."https://github.com/Myriad-Dreamin/tinymist.git"] -# typst-shim = { path = "../tinymist/crates/typst-shim" } -# tinymist-analysis = { path = "../tinymist/crates/tinymist-analysis" } -# tinymist-std = { path = "../tinymist/crates/tinymist-std" } -# tinymist-world = { path = "../tinymist/crates/tinymist-world" } +[patch."https://github.com/Myriad-Dreamin/tinymist.git"] +typst-shim = { path = "../tinymist/crates/typst-shim" } +tinymist-analysis = { path = "../tinymist/crates/tinymist-analysis" } +tinymist-project = { path = "../tinymist/crates/tinymist-project" } +tinymist-std = { path = "../tinymist/crates/tinymist-std" } +tinymist-task = { path = "../tinymist/crates/tinymist-task" } +tinymist-world = { path = "../tinymist/crates/tinymist-world" } diff --git a/cli/src/compile.rs b/cli/src/compile.rs index d73b9876b..b21696fcb 100644 --- a/cli/src/compile.rs +++ b/cli/src/compile.rs @@ -6,14 +6,13 @@ use std::sync::Arc; use reflexo_typst::config::entry::{EntryOpts, MEMORY_MAIN_ENTRY}; use reflexo_typst::config::CompileOpts; use reflexo_typst::features::{FeatureSet, DIAG_FMT_FEATURE}; -use reflexo_typst::TypstDocument; -use reflexo_typst::{exporter_builtins::GroupExporter, path::PathClean}; +use reflexo_typst::path::PathClean; use reflexo_typst::{ - CompilationHandle, CompileActor, CompileDriver, CompileExporter, CompileServerOpts, - CompileStarter, CompiledArtifact, CompilerFeat, ConsoleDiagReporter, DynExporter, - DynamicLayoutCompiler, EntryManager, EntryReader, GenericExporter, PureCompiler, ShadowApi, - SystemCompilerFeat, TypstSystemUniverse, TypstSystemWorld, + CompilationHandle, CompileActor, CompileDriver, CompileServerOpts, CompilerFeat, + DynComputation, DynamicLayoutCompiler, EntryManager, EntryReader, PureCompiler, ShadowApi, + SystemCompilerFeat, TypstSystemUniverse, TypstSystemWorld, WorldComputeGraph, }; +use reflexo_typst::{DynSystemComputation, TypstDocument}; use tokio::sync::mpsc; use typst::diag::{FileError, FileResult}; use typst::foundations::{Bytes, Dict, IntoValue}; @@ -24,7 +23,7 @@ use crate::{ CompileArgs, CompileOnceArgs, }; -pub fn create_driver(args: CompileOnceArgs) -> CompileDriver> { +pub fn create_driver(args: CompileOnceArgs) -> CompileDriver { let workspace_dir = Path::new(args.workspace.as_str()).clean(); let entry = args.entry; let entry_file_path = Path::new(entry.as_str()).clean(); @@ -112,52 +111,20 @@ pub fn create_driver(args: CompileOnceArgs) -> CompileDriver) -> ! { +pub fn compile_export(args: CompileArgs, exporter: DynSystemComputation) -> ! { let (intr_tx, intr_rx) = mpsc::unbounded_channel(); - // todo: make dynamic layout exporter - let output_dir = { - let dir = args.compile.output_dir(); - if args.compile.is_stdin() { - dir.join("main") - } else { - dir.join( - args.compile - .main_id() - .vpath() - .as_rooted_path() - .file_name() - .expect("entry_file has no file name"), - ) - } - }; - let driver = create_driver(args.compile); let feature_set = FeatureSet::default().configure(&DIAG_FMT_FEATURE, args.diagnostic_format.into()); let verse = driver.universe; - // todo: when there is only dynamic export, it is not need to compile first. - let mut exporters: Vec>> = vec![]; - - if !exporter.is_empty() { - let driver = CompileExporter::new(std::marker::PhantomData).with_exporter(exporter); - exporters.push(Box::new(CompileStarter::new(driver))); - } - - if args.dynamic_layout { - let driver = DynamicLayoutCompiler::new(std::marker::PhantomData, output_dir); - exporters.push(Box::new(CompileStarter::new(driver))); - } - - let handle = Arc::new(CompileHandler { - exporter: GroupExporter::new(exporters), - }); + let handle = Arc::new(CompileHandler { exporter }); let actor = CompileActor::new_with( verse, @@ -172,7 +139,7 @@ pub fn compile_export(args: CompileArgs, exporter: GroupExporter) .with_watch(args.watch); utils::async_continue(async move { - utils::logical_exit(actor.run().await); + utils::logical_exit(actor.run().await.unwrap_or_exit()); }) } @@ -190,31 +157,18 @@ fn read_from_stdin() -> FileResult> { } pub struct CompileHandler { - exporter: GroupExporter>, + exporter: DynComputation, } impl CompilationHandle for CompileHandler { fn status(&self, _revision: usize, _rep: reflexo_typst::CompileReport) {} - fn notify_compile( - &self, - compiled: &reflexo_typst::CompiledArtifact, - rep: reflexo_typst::CompileReport, - ) { - use reflexo_typst::Exporter; - if let reflexo_typst::CompileReport::CompileSuccess(t, ..) = rep { - let curr = reflexo_typst::time::now(); - let errs = self - .exporter - .export(compiled.world.as_ref(), Arc::new(compiled.clone())); - if let Err(errs) = errs { - let elapsed = curr.elapsed().unwrap_or_default(); - let rep = reflexo_typst::CompileReport::ExportError(t, errs, elapsed); - let _ = ConsoleDiagReporter::default().export( - compiled.world.as_ref(), - Arc::new((compiled.env.features.clone(), rep.clone())), - ); - } + fn notify_compile(&self, g: &Arc>) { + let res = (self.exporter)(g); + if let Err(err) = res { + eprintln!("export failed: {err}"); } + + todo!() } } diff --git a/cli/src/export.rs b/cli/src/export.rs index 4f9ef1dfb..f8748d786 100644 --- a/cli/src/export.rs +++ b/cli/src/export.rs @@ -1,19 +1,18 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; -use reflexo_typst::exporter_builtins::{FsPathExporter, GroupExporter}; +use reflexo_typst::error::prelude::*; use reflexo_typst::program_meta::REPORT_BUG_MESSAGE; use reflexo_typst::svg::DefaultExportFeature; use reflexo_typst::{ - Exporter, TypstDatetime, TypstDocument, TypstHtmlDocument, TypstPagedDocument, + AstExport, AstExportTask, Bytes, ConfigTask, DynSystemComputation, FlagTask, + HtmlCompilationTask, HtmlExport, PagedCompilationTask, PdfExport, SystemCompilerFeat, + TextExport, WebSvgExport, WebSvgHtmlExport, WebSvgModuleExport, WorldComputeGraph, }; -use typst::World; -use typst_pdf::Timestamp; +use typst::diag::SourceResult; use crate::{utils::current_dir, CompileArgs, ExportArgs}; -type GroupDocExporter = GroupExporter; - /// builtin formats should be enabled by default, and non-builtin formats should /// be pub static AVAILABLE_FORMATS: &[(/* format name */ &str, /* feature hint */ &str)] = &[ @@ -60,107 +59,156 @@ fn prepare_exporters_impl( args: ExportArgs, out: PathBuf, mut formats: Vec, -) -> GroupDocExporter { - let mut doc: ExporterVec = vec![]; - let mut paged: ExporterVec = vec![]; - let mut html: ExporterVec = vec![]; - - /// connect export flow from $x to $y - #[allow(unused_macros)] - macro_rules! sink_flow { - ($x:ident -> $y:ident) => { - if !$y.is_empty() { - $x.push(Box::new(FromExporter::new($y))); - } - }; - } - - /// write $exporters as $exporter to path `$output_dir @@ $extension` - macro_rules! sink_path { - ($exporter:ty as $ser:ty as $exporters:ident, $output_dir:ident @@ $extension:literal) => {{ - let output_path = $output_dir.with_extension($extension); - $exporters.push(Box::new(FsPathExporter::<$ser, _>::new( - output_path, - <$exporter>::default(), - ))); - }}; - (|| $exporter:tt as $ser:ty as $exporters:ident, $output_dir:ident @@ $extension:literal) => {{ - let output_path = $output_dir.with_extension($extension); - let exporter = $exporter; - $exporters.push(Box::new(FsPathExporter::<$ser, _>::new( - output_path, - exporter, - ))); - }}; - } - - // sink exporters according to the given formats - { - formats.sort(); - formats.dedup(); - #[rustfmt::skip] - formats.iter().map(String::as_str).for_each(|f| match f { - "nothing" => (), - "ast" => sink_path!(WithAst as _ as paged, out @@ "ast.ansi.text"), - #[cfg(feature = "pdf")] - "pdf" => sink_path!(|| { - WithPdf::default().with_ctime(args.creation_timestamp.and_then(convert_datetime)) - } as _ as paged, out @@ "pdf"), - #[cfg(feature = "html")] - "html" => sink_path!(WithHtml as _ as html, out @@ "artifact.html"), - #[cfg(feature = "svg")] - "svg" => sink_path!(WithSvg as _ as paged, out @@ "artifact.svg"), - #[cfg(feature = "svg")] - "svg_html" => sink_path!(WithSvgHtml as _ as paged, out @@ "artifact.svg.html"), - #[cfg(feature = "svg")] - "sir" => sink_path!(WithSIR as _ as paged, out @@ "artifact.sir.in"), - #[cfg(feature = "svg")] - "vector" => sink_path!(WithSIR as _ as paged, out @@ "artifact.sir.in"), - #[cfg(feature = "text")] - "text" => sink_path!(WithText as _ as paged, out @@ "txt"), - _ => exit_by_unknown_format(f), - }); - } - - if !paged.is_empty() { - let exporter = GroupExporter::new(paged); - doc.push(Box::new( - move |world: &dyn World, doc: Arc| match doc.as_ref() { - TypstDocument::Paged(doc) => exporter.export(world, doc.clone()), - _ => unreachable!(), - }, - )); - } - - if !html.is_empty() { - let exporter = GroupExporter::new(html); - doc.push(Box::new( - move |world: &dyn World, doc: Arc| match doc.as_ref() { - TypstDocument::Html(doc) => exporter.export(world, doc.clone()), - _ => unreachable!(), - }, - )); - } - - return GroupExporter::new(doc); +) -> DynSystemComputation { + formats.sort(); + formats.dedup(); + Arc::new(move |graph: &Arc>| { + let _ = graph.provide::>(Ok(FlagTask::flag(true))); + let _ = graph.provide::>(Ok(FlagTask::flag(true))); + let _ = graph.provide::>(Ok(Arc::new(AstExportTask))); + let _ = args; + // WithPdf::default().with_ctime(args.creation_timestamp. + // and_then(convert_datetime)) + + // out @@ "ast.ansi.text" + // type WithHtml = reflexo_typst::HtmlExporter; + + fn export_to_path(result: Result>>, output_path: PathBuf) { + // let inner = result.unwrap().unwrap().into_inner(); + // std::fs::write(output_path, inner).unwrap(); + todo!() + } - type Doc = TypstDocument; - type PagedDoc = TypstPagedDocument; - type HtmlDoc = TypstHtmlDocument; + fn export_str_to_path(result: Result>>, output_path: PathBuf) { + // let inner = result.unwrap().unwrap().into_inner(); + // std::fs::write(output_path, inner).unwrap(); + todo!() + } - type WithAst = reflexo_typst::AstExporter; - type WithPdf = reflexo_typst::PdfDocExporter; - type WithSvg = reflexo_typst::PureSvgExporter; - type WithSvgHtml = reflexo_typst::SvgHtmlExporter; - type WithHtml = reflexo_typst::HtmlExporter; - type WithSIR = reflexo_typst::SvgModuleExporter; - type WithText = reflexo_typst::TextExporter; + for output_format in formats.iter().map(String::as_str) { + match output_format { + "nothing" => {} + "ast" => { + // type WithAst = reflexo_typst::AstExport; + + let output_path = out.with_extension("ast.ansi.text"); + let result = graph.compute::(); + export_to_path(result, output_path); + } + #[cfg(feature = "pdf")] + "pdf" => { + let output_path = out.with_extension("pdf"); + let result = graph.compute::(); + export_to_path(result, output_path); + } + #[cfg(feature = "html")] + "html" => { + let output_path = out.with_extension("artifact.html"); + let result = graph.compute::(); + export_str_to_path(result, output_path); + } + #[cfg(feature = "svg")] + "svg" => { + let output_path = out.with_extension("artifact.svg"); + let result = graph.compute::>(); + export_str_to_path(result, output_path); + } + #[cfg(feature = "svg")] + "svg_html" => { + let output_path = out.with_extension("artifact.svg.html"); + let result = graph.compute::>(); + export_str_to_path(result, output_path); + } + #[cfg(feature = "svg")] + "sir" | "vector" => { + let output_path = out.with_extension("artifact.sir.in"); + let result = graph.compute::>(); + export_to_path(result, output_path); + } + #[cfg(feature = "text")] + "text" => { + let output_path = out.with_extension("txt"); + let result = graph.compute::(); + export_str_to_path(result, output_path); + } + _ => exit_by_unknown_format(output_format), + } + } - type ExporterVec = Vec + Send + Sync>>; + // todo: make dynamic layout exporter + // let output_dir = { + // let dir = args.compile.output_dir(); + // if args.compile.is_stdin() { + // dir.join("main") + // } else { + // dir.join( + // args.compile + // .main_id() + // .vpath() + // .as_rooted_path() + // .file_name() + // .expect("entry_file has no file name"), + // ) + // } + // }; + + // todo: when there is only dynamic export, it is not need to compile first. + // if args.dynamic_layout { + // let driver = DynamicLayoutCompiler::new(std::marker::PhantomData, + // output_dir); exporters. + // push(Box::new(CompileStarter::new(driver))); } + + // let env = self.make_env(if is_once { + // self.once_feature_set.clone() + // } else { + // self.watch_feature_set.clone() + // }); + + // Diagnostics + + // let compiled = compiling.compile(); + + // for reader in curr_reads { + // let _ = + // reader.send(SucceededArtifact::Compiled(compiled.clone())); } + + // let elapsed = start.elapsed().unwrap_or_default(); + // let rep = match &compiled.doc { + // Ok(..) => CompileReport::CompileSuccess(id, + // compiled.warnings.clone(), elapsed), Err(err) => + // CompileReport::CompileError(id, err.clone(), elapsed), }; + + // let _ = ConsoleDiagReporter::default().export( + // compiled.world.deref(), + // Arc::new((compiled.env.features.clone(), rep.clone())), + // ); + + // // todo: we need to check revision for really concurrent compilation + // h.notify_compile(&compiled, rep); + + // use reflexo_typst::Exporter; + // if let reflexo_typst::CompileReport::CompileSuccess(t, ..) = rep { + // let curr = reflexo_typst::time::now(); + // let errs = self + // .exporter + // .export(compiled.world.as_ref(), Arc::new(compiled.clone())); + // if let Err(errs) = errs { + // let elapsed = curr.elapsed().unwrap_or_default(); + // let rep = reflexo_typst::CompileReport::ExportError(t, errs, + // elapsed); let _ = + // ConsoleDiagReporter::default().export( + // compiled.world.as_ref(), + // Arc::new((compiled.env.features.clone(), rep.clone())), + // ); + // } + // } + + Ok(()) + }) } /// Prepare exporters from command line arguments. -pub fn prepare_exporters(args: &CompileArgs, entry_file: Option<&Path>) -> GroupDocExporter { +pub fn prepare_exporters(args: &CompileArgs, entry_file: Option<&Path>) -> DynSystemComputation { let output_dir = { // If output is specified, use it. let dir = (!args.compile.output.is_empty()).then(|| Path::new(&args.compile.output)); @@ -192,18 +240,3 @@ pub fn prepare_exporters(args: &CompileArgs, entry_file: Option<&Path>) -> Group prepare_exporters_impl(args.export.clone(), output_dir, formats) } - -/// Convert [`chrono::DateTime`] to [`Timestamp`] -fn convert_datetime(date_time: chrono::DateTime) -> Option { - use chrono::{Datelike, Timelike}; - let datetime = TypstDatetime::from_ymd_hms( - date_time.year(), - date_time.month().try_into().ok()?, - date_time.day().try_into().ok()?, - date_time.hour().try_into().ok()?, - date_time.minute().try_into().ok()?, - date_time.second().try_into().ok()?, - ); - - Some(Timestamp::new_utc(datetime.unwrap())) -} diff --git a/cli/src/main.rs b/cli/src/main.rs index dd6b2e085..ba91f9e82 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -6,12 +6,14 @@ use std::{ }; use clap::FromArgMatches; -use reflexo_typst::config::{entry::EntryOpts, CompileOpts}; -use reflexo_typst::exporter_builtins::GroupExporter; -use reflexo_typst::exporter_utils::map_err; use reflexo_typst::path::{unix_slash, PathClean}; use reflexo_typst::TypstDocument; use reflexo_typst::TypstSystemUniverse; +use reflexo_typst::{ + config::{entry::EntryOpts, CompileOpts}, + SystemCompilerFeat, WorldComputeGraph, +}; +use reflexo_typst::{error::prelude::*, OptionDocumentTask, TypstPagedDocument}; use typst::{text::FontVariant, World}; use typst_assets::fonts; use typst_ts_cli::compile::compile_export; @@ -110,10 +112,16 @@ pub fn query(args: QueryArgs) -> ! { use typst_ts_cli::query::format; let compile_args = args.compile.clone(); - let mut exporter = GroupExporter::::new(vec![]); + let exporter = Arc::new( + move |g: &Arc>| -> Result<()> { + // todo: html query + let output = g + .compute::>()? + .as_ref() + .clone() + .context("no document found")?; + let output = TypstDocument::Paged(output); - exporter.push_front(Box::new( - move |world: &dyn World, output: Arc| { if args.selector == "document_title" { let title = output .info() @@ -121,17 +129,18 @@ pub fn query(args: QueryArgs) -> ! { .as_ref() .map(|e| e.as_str()) .unwrap_or("null"); - let serialized = serialize(&title, "json").map_err(map_err)?; + let serialized = serialize(&title, "json").context("serialize query")?; println!("{}", serialized); return Ok(()); } - let data = retrieve(world, &args.selector, output.as_ref()).map_err(map_err)?; - let serialized = format(data, &args).map_err(map_err)?; + let world = &g.snap.world; + let data = retrieve(world, &args.selector, &output).context("query")?; + let serialized = format(data, &args).context("serialize query")?; println!("{serialized}"); Ok(()) }, - )); + ); compile_export(compile_args, exporter) } diff --git a/cli/src/query_repl.rs b/cli/src/query_repl.rs index 88b96d4fe..195fbc166 100644 --- a/cli/src/query_repl.rs +++ b/cli/src/query_repl.rs @@ -3,10 +3,8 @@ use std::cell::{RefCell, RefMut}; use std::sync::Arc; use reflexo_typst::typst::prelude::*; -use reflexo_typst::{ - CompileDriver, CompileReport, ConsoleDiagReporter, PureCompiler, TypstDocument, -}; -use reflexo_typst::{GenericExporter, ShadowApiExt, TypstSystemWorld}; +use reflexo_typst::{CompileDriver, CompileReport, PureCompiler, TypstDocument}; +use reflexo_typst::{ShadowApiExt, TypstSystemWorld}; use rustyline::completion::{Completer, Pair}; use rustyline::error::ReadlineError; use rustyline::highlight::{Highlighter, MatchingBracketHighlighter}; @@ -31,18 +29,18 @@ struct ReplContext { hinter: HistoryHinter, // typst world state - driver: RefCell>>, - reporter: ConsoleDiagReporter, + driver: RefCell, + // reporter: ConsoleDiagReporter, } impl ReplContext { - fn new(driver: CompileDriver>) -> Self { + fn new(driver: CompileDriver) -> Self { ReplContext { highlighter: MatchingBracketHighlighter::new(), hinter: HistoryHinter {}, validator: MatchingBracketValidator::new(), driver: RefCell::new(driver), - reporter: ConsoleDiagReporter::default(), + // reporter: ConsoleDiagReporter::default(), } } } @@ -302,12 +300,13 @@ pub fn start_repl_test(args: CompileOnceArgs) -> rustyline::Result<()> { impl ReplContext { fn process_err( &self, - driver: &RefMut>>, + driver: &RefMut, err: EcoVec, ) -> Result<(), ()> { let rep = CompileReport::CompileError(driver.main_id(), err, Default::default()); - let _ = self.reporter.export(&driver.snapshot(), Arc::new(rep)); - Ok(()) + // let _ = self.reporter.export(&driver.snapshot(), Arc::new(rep)); + // Ok(()) + todo!() } fn repl_process_line(&mut self, line: String) { diff --git a/crates/reflexo-typst/Cargo.toml b/crates/reflexo-typst/Cargo.toml index 08b42fa3c..bba057e76 100644 --- a/crates/reflexo-typst/Cargo.toml +++ b/crates/reflexo-typst/Cargo.toml @@ -16,6 +16,7 @@ typst-html = { workspace = true, optional = true } reflexo-typst2vec.workspace = true reflexo.workspace = true tinymist-world.workspace = true +tinymist-task.workspace = true comemo.workspace = true ecow.workspace = true diff --git a/crates/reflexo-typst/src/compile.rs b/crates/reflexo-typst/src/compile.rs index 97eb87523..9acbe582f 100644 --- a/crates/reflexo-typst/src/compile.rs +++ b/crates/reflexo-typst/src/compile.rs @@ -4,63 +4,62 @@ use std::{ collections::HashSet, - ops::Deref, path::Path, sync::{Arc, OnceLock}, }; +use reflexo::error::prelude::*; +use reflexo::typst::{TypstHtmlDocument, TypstPagedDocument}; +use tinymist_world::{FlagTask, OptionDocumentTask, ProjectInsId, WorldComputeGraph}; use tokio::sync::{mpsc, oneshot}; use crate::features::{FeatureSet, WITH_COMPILING_STATUS_FEATURE}; use crate::task::CacheTask; use crate::vfs::notify::{FilesystemEvent, MemoryEvent, NotifyMessage, UpstreamUpdateEvent}; use crate::vfs::FsProvider; -use crate::world::{ - CompilerFeat, CompilerUniverse, CompilerWorld, EntryReader, RevisingUniverse, TaskInputs, -}; -use crate::{exporter::GenericExporter, watch::watch_deps, ExportSignal, TypstDocument}; -use crate::{ - CompileEnv, CompileReport, CompileSnapshot, CompiledArtifact, ConsoleDiagReporter, WorldDeps, -}; +use crate::world::{CompilerFeat, CompilerUniverse, EntryReader, RevisingUniverse, TaskInputs}; +use crate::{watch::watch_deps, ExportSignal, TypstDocument}; +use crate::{CompileEnv, CompileReport, CompileSnapshot, WorldDeps}; pub trait CompilationHandle: Send + Sync + 'static { fn status(&self, revision: usize, rep: CompileReport); - fn notify_compile(&self, res: &CompiledArtifact, rep: CompileReport); + // res: &CompiledArtifact, rep: CompileReport + fn notify_compile(&self, g: &Arc>); } impl CompilationHandle for std::marker::PhantomData { fn status(&self, _revision: usize, _: CompileReport) {} - fn notify_compile(&self, _: &CompiledArtifact, _: CompileReport) {} + fn notify_compile(&self, _g: &Arc>) {} } -pub enum SucceededArtifact { - Compiled(CompiledArtifact), - Suspend(CompileSnapshot), -} - -impl SucceededArtifact { - pub fn success_doc(&self) -> Option { - match self { - SucceededArtifact::Compiled(artifact) => artifact.success_doc(), - SucceededArtifact::Suspend(snapshot) => snapshot.success_doc.clone(), - } - } - - pub fn world(&self) -> &Arc> { - match self { - SucceededArtifact::Compiled(artifact) => &artifact.world, - SucceededArtifact::Suspend(snapshot) => &snapshot.world, - } - } -} +// pub enum CompiledArtifact { +// Compiled(CompiledArtifact), +// Suspend(CompileSnapshot), +// } + +// impl CompiledArtifact { +// pub fn success_doc(&self) -> Option { +// match self { +// CompiledArtifact::Compiled(artifact) => artifact.success_doc(), +// CompiledArtifact::Suspend(snapshot) => +// snapshot.success_doc.clone(), } +// } + +// pub fn world(&self) -> &Arc> { +// match self { +// CompiledArtifact::Compiled(artifact) => &artifact.world, +// CompiledArtifact::Suspend(snapshot) => &snapshot.world, +// } +// } +// } pub enum Interrupt { /// Compile anyway. Compile, /// Compiled from computing thread. - Compiled(CompiledArtifact), + Compiled(Arc>), /// Change the watching entry. ChangeTask(TaskInputs), /// Request compiler to respond a snapshot without needing to wait latest @@ -68,7 +67,7 @@ pub enum Interrupt { SnapshotRead(oneshot::Sender>), /// Request compiler to respond a snapshot with at least a compilation /// happens on or after current revision. - CurrentRead(oneshot::Sender>), + CurrentRead(oneshot::Sender>>), /// Memory file changes. Memory(MemoryEvent), /// File system event. @@ -171,9 +170,9 @@ pub struct CompileActor { /// Estimated latest set of shadow files. estimated_shadow_files: HashSet>, /// The latest compiled document. - pub(crate) latest_doc: Option, - /// The latest successly compiled document. - latest_success_doc: Option, + pub(crate) latest_doc: Option>>, + /// The latest successful document. + pub(crate) latest_success_doc: Option, /// feature set for compile_once mode. once_feature_set: Arc, /// Shared feature set for watch mode. @@ -254,10 +253,14 @@ impl CompileActor { } /// Launches the compiler actor. - pub async fn run(mut self) -> bool { + pub async fn run(mut self) -> Result { if !self.enable_watch { - let artifact = self.compile_once().await; - return artifact.doc.is_ok(); + // todo: once flag + return Ok(self + .compile_once() + .await + .compute::>()? + .enabled); } let (dep_tx, dep_rx) = tokio::sync::mpsc::unbounded_channel(); @@ -314,31 +317,25 @@ impl CompileActor { log_send_error("settle_notify", dep_tx.send(NotifyMessage::Settle)); log::info!("CompileActor: exited"); - true + Ok(true) } - fn snapshot(&self, is_once: bool, reason: CompileReasons) -> CompileSnapshot { + fn snapshot(&self, reason: CompileReasons) -> CompileSnapshot { let world = self.verse.snapshot(); - let env = self.make_env(if is_once { - self.once_feature_set.clone() - } else { - self.watch_feature_set.clone() - }); CompileSnapshot { - world: Arc::new(world.clone()), - env: env.clone(), - flags: ExportSignal { + id: ProjectInsId::PRIMARY, + world, + signal: ExportSignal { by_entry_update: reason.by_entry_update, by_mem_events: reason.by_memory_events, by_fs_events: reason.by_fs_events, }, - doc_state: Arc::new(OnceLock::new()), success_doc: self.latest_success_doc.clone(), } } /// Compile the document once. - pub async fn compile_once(&mut self) -> CompiledArtifact { + pub async fn compile_once(&mut self) -> Arc> { self.run_compile(reason_by_entry_change(), &mut vec![], true) .unwrap() } @@ -347,14 +344,14 @@ impl CompileActor { fn run_compile( &mut self, reason: CompileReasons, - curr_reads: &mut Vec>>, + curr_reads: &mut Vec>>>, is_once: bool, - ) -> Option> { + ) -> Option>> { self.suspended_reason.see(reason); let reason = std::mem::take(&mut self.suspended_reason); let start = reflexo::time::now(); - let compiling = self.snapshot(is_once, reason); + let compiling = self.snapshot(reason); self.watch_snap = OnceLock::new(); self.watch_snap.get_or_init(|| compiling.clone()); @@ -362,7 +359,7 @@ impl CompileActor { self.suspended_reason.see(reason); for reader in curr_reads.drain(..) { - let _ = reader.send(SucceededArtifact::Suspend(compiling.clone())); + let _ = reader.send(WorldComputeGraph::new(compiling.clone())); } return None; } @@ -384,27 +381,11 @@ impl CompileActor { h.status(revision, CompileReport::Stage(id, "compiling", start)); let compile = move || { - let compiled = compiling.compile(); - - for reader in curr_reads { - let _ = reader.send(SucceededArtifact::Compiled(compiled.clone())); - } - - let elapsed = start.elapsed().unwrap_or_default(); - let rep = match &compiled.doc { - Ok(..) => CompileReport::CompileSuccess(id, compiled.warnings.clone(), elapsed), - Err(err) => CompileReport::CompileError(id, err.clone(), elapsed), - }; + let compiling = WorldComputeGraph::new(compiling); - let _ = ConsoleDiagReporter::default().export( - compiled.world.deref(), - Arc::new((compiled.env.features.clone(), rep.clone())), - ); + h.notify_compile(&compiling); - // todo: we need to check revision for really concurrent compilation - h.notify_compile(&compiled, rep); - - compiled + compiling }; if is_once { @@ -412,36 +393,62 @@ impl CompileActor { } else { let intr_tx = self.intr_tx.clone(); tokio::task::spawn_blocking(move || { - log_send_error("compiled", intr_tx.send(Interrupt::Compiled(compile()))); + compile(); + panic!("notify compiled") + // log_send_error("compiled", + // intr_tx.send(Interrupt::Compiled())); }); None } } - fn process_compile(&mut self, artifact: CompiledArtifact, send: impl Fn(CompilerResponse)) { + fn process_compile( + &mut self, + artifact: Arc>, + send: impl Fn(CompilerResponse), + ) { self.compiling = false; - let w = &artifact.world; + let w = &artifact.snap.world; let compiled_revision = w.revision().get(); if self.committed_revision >= compiled_revision { return; } - let doc = artifact.doc.ok(); + let doc = { + let paged = artifact + .get::>() + .transpose() + .ok() + .flatten() + .and_then(|e| e.as_ref().clone()); + let html = artifact + .get::>() + .transpose() + .ok() + .flatten() + .and_then(|e| e.as_ref().clone()); + + if let Some(paged) = paged { + Some(TypstDocument::Paged(paged)) + } else { + html.map(TypstDocument::Html) + } + }; // Update state. self.committed_revision = compiled_revision; - self.latest_doc.clone_from(&doc); + self.latest_doc = Some(artifact.clone()); if doc.is_some() { - self.latest_success_doc.clone_from(&self.latest_doc); + self.latest_success_doc = doc; } // Notify the new file dependencies. let mut deps = vec![]; - artifact.world.iter_dependencies(&mut |dep| { - if let Ok(x) = artifact.world.file_path(dep).and_then(|e| e.to_err()) { + w.iter_dependencies(&mut |dep| { + if let Ok(x) = w.file_path(dep).and_then(|e| e.to_err()) { deps.push(x.into()) } }); @@ -478,7 +485,7 @@ impl CompileActor { let _ = task.send( self.watch_snap - .get_or_init(|| self.snapshot(false, no_reason())) + .get_or_init(|| self.snapshot(no_reason())) .clone(), ); no_reason() diff --git a/crates/reflexo-typst/src/diag/console.rs b/crates/reflexo-typst/src/diag/console.rs index e30340a71..3c95a322f 100644 --- a/crates/reflexo-typst/src/diag/console.rs +++ b/crates/reflexo-typst/src/diag/console.rs @@ -11,6 +11,8 @@ use codespan_reporting::{ }, }; +use reflexo::Result; +use tinymist_world::{CompilerFeat, WorldComputable, WorldComputeGraph}; use typst::diag::{Severity, SourceResult}; use typst::syntax::Span; use typst::WorldExt; @@ -22,7 +24,7 @@ use crate::features::{ CompileFeature, FeatureSet, DIAG_FMT_FEATURE, WITH_COMPILING_STATUS_FEATURE, }; use crate::CompileReport; -use crate::{typst::prelude::*, GenericExporter, TakeAs, TypstFileId}; +use crate::{typst::prelude::*, TakeAs, TypstFileId}; use super::DiagnosticFormat; @@ -96,52 +98,41 @@ fn label<'files, W: World + Files<'files, FileId = TypstFileId>>( #[derive(Debug, Clone, Copy)] pub struct ConsoleDiagReporter(PhantomData); -impl Default for ConsoleDiagReporter -where - W: for<'files> codespan_reporting::files::Files<'files, FileId = TypstFileId>, -{ +impl Default for ConsoleDiagReporter { fn default() -> Self { Self(PhantomData) } } -impl GenericExporter for ConsoleDiagReporter -where - X: World + for<'files> codespan_reporting::files::Files<'files, FileId = TypstFileId>, -{ - type W = X; +impl WorldComputable for ConsoleDiagReporter { + type Output = (); - fn export(&self, world: &Self::W, output: Arc) -> SourceResult<()> { - self.export(world, Arc::new((Default::default(), output.take()))) + fn compute(graph: &Arc>) -> Result { + todo!() } -} - -impl GenericExporter<(Arc, CompileReport)> for ConsoleDiagReporter -where - X: World + for<'files> codespan_reporting::files::Files<'files, FileId = TypstFileId>, -{ - type W = X; - - fn export( - &self, - world: &Self::W, - output: Arc<(Arc, CompileReport)>, - ) -> SourceResult<()> { - let (features, report) = output.take(); - - if WITH_COMPILING_STATUS_FEATURE.retrieve(&features) { - log::info!("{}", report.message()); - } - if let Some(diag) = report.diagnostics() { - let _err = print_diagnostics(world, diag, DIAG_FMT_FEATURE.retrieve(&features)); - // todo: log in browser compiler - #[cfg(feature = "system-compile")] - if _err.is_err() { - log::error!("failed to print diagnostics: {_err:?}"); - } - } - - Ok(()) - } + // fn export( + // &self, + // world: &Self::W, + // output: Arc<(Arc, CompileReport)>, + // ) -> SourceResult<()> { + // let (features, report) = output.take(); + + // if WITH_COMPILING_STATUS_FEATURE.retrieve(&features) { + // log::info!("{}", report.message()); + // } + + // if let Some(diag) = report.diagnostics() { + // let _err = print_diagnostics(world, diag, + // DIAG_FMT_FEATURE.retrieve(&features)); + + // // todo: log in browser compiler + // #[cfg(feature = "system-compile")] + // if _err.is_err() { + // log::error!("failed to print diagnostics: {_err:?}"); + // } + // } + + // Ok(()) + // } } diff --git a/crates/reflexo-typst/src/driver.rs b/crates/reflexo-typst/src/driver.rs index 8ea827a78..fb8eb3411 100644 --- a/crates/reflexo-typst/src/driver.rs +++ b/crates/reflexo-typst/src/driver.rs @@ -7,31 +7,33 @@ use typst::{ }; use super::{CompileEnv, Compiler}; -use crate::vfs::{FileId, PathResolution}; use crate::world::{ CompilerFeat, CompilerUniverse, CompilerWorld, EntryReader, ShadowApi, DETACHED_ENTRY, }; +use crate::{ + vfs::{FileId, PathResolution}, + DynComputation, +}; use crate::{Bytes, TypstFileId, TypstPagedDocument}; /// CompileDriverImpl is a driver for typst compiler. /// It is responsible for operating the compiler without leaking implementation /// details of the compiler. -pub struct CompileDriverImpl { - pub compiler: C, +pub struct CompileDriverImpl { /// World that has access to the file system. pub universe: CompilerUniverse, } -impl CompileDriverImpl { +impl CompileDriverImpl { pub fn entry_file(&self) -> Option { - self.universe.path_for_id(self.main_id()).ok() + self.universe.path_for_id(self.universe.main_id()?).ok() } } -impl>> CompileDriverImpl { +impl CompileDriverImpl { /// Create a new driver. - pub fn new(compiler: C, universe: CompilerUniverse) -> Self { - Self { compiler, universe } + pub fn new(_c: DynComputation, universe: CompilerUniverse) -> Self { + Self { universe } } pub fn query( @@ -39,20 +41,22 @@ impl>> CompileDriverImpl selector: String, document: &TypstDocument, ) -> SourceResult> { - self.compiler.query(&self.snapshot(), selector, document) + // self.compiler.query(&self.snapshot(), selector, document) + todo!() } pub fn compile( &mut self, env: &mut CompileEnv, ) -> SourceResult>> { - let world = self.snapshot(); - self.compiler.ensure_main(&world)?; - self.compiler.compile(&world, env) + // let world = self.snapshot(); + // self.compiler.ensure_main(&world)?; + // self.compiler.compile(&world, env) + todo!() } } -impl CompileDriverImpl { +impl CompileDriverImpl { pub fn universe(&self) -> &CompilerUniverse { &self.universe } @@ -148,7 +152,7 @@ impl CompileDriverImpl { } } -impl ShadowApi for CompileDriverImpl { +impl ShadowApi for CompileDriverImpl { #[inline] fn shadow_paths(&self) -> Vec> { self.universe.shadow_paths() diff --git a/crates/reflexo-typst/src/export.rs b/crates/reflexo-typst/src/export.rs index 18d95317b..89b110a01 100644 --- a/crates/reflexo-typst/src/export.rs +++ b/crates/reflexo-typst/src/export.rs @@ -7,9 +7,12 @@ use typst::{ World, }; -use crate::vector::ir::{LayoutRegion, LayoutRegionNode}; use crate::world::{CompilerFeat, CompilerWorld}; -use crate::CompiledArtifact; +// use crate::CompiledArtifact; +use crate::{ + vector::ir::{LayoutRegion, LayoutRegionNode}, + DynComputation, +}; #[cfg(feature = "dynamic-layout")] mod dynamic_layout; @@ -20,230 +23,232 @@ use super::{ features::{CompileFeature, FeatureSet, WITH_COMPILING_STATUS_FEATURE}, CompileEnv, CompileMiddleware, CompileReport, Compiler, }; -use crate::{ - exporter_builtins::GroupExporter, typst::prelude::*, DynExporter, DynGenericExporter, - DynPolymorphicExporter, Exporter, GenericExporter, TakeAs, TypstPagedDocument as Document, -}; +use crate::{typst::prelude::*, TakeAs, TypstPagedDocument as Document}; use crate::{CompileSnapshot, EntryReader}; -pub struct CompileStarter>> { - pub compiler: C, - f: std::marker::PhantomData, -} - -impl>> CompileStarter { - pub fn new(compiler: C) -> Self { - Self { - compiler, - f: std::marker::PhantomData, - } - } -} - -impl> + Clone> Exporter> - for CompileStarter -{ - fn export(&self, _world: &dyn World, output: Arc>) -> SourceResult<()> { - self.compiler - .clone() - .compile(&output.world, &mut output.env.clone()) - .map(|_| ()) - } -} - -#[derive(Clone)] -pub struct CompileExporter { - pub compiler: C, - pub exporter: Arc>, -} - -impl Default for CompileExporter { - fn default() -> Self { - Self::new(C::default()) - } -} - -impl CompileExporter { - pub fn new(compiler: C) -> Self { - Self { - compiler, - exporter: Arc::new(GroupExporter::new(vec![]).into()), - } - } - - /// Wrap driver with a given exporter. - pub fn with_exporter(mut self, exporter: impl Into>) -> Self { - self.set_exporter(exporter); - self - } - - /// set an exporter. - pub fn set_exporter(&mut self, exporter: impl Into>) { - self.exporter = Arc::new(exporter.into()); - } -} - -impl Exporter> for CompileExporter { - /// Export a typst document using `reflexo_typst::DocumentExporter`. - fn export(&self, world: &dyn World, output: Arc>) -> SourceResult<()> { - let doc = output.as_ref().clone().compile().doc?; - self.exporter.export(world, Arc::new(doc))?; - - Ok(()) - } -} - -impl CompileMiddleware for CompileExporter { - type Compiler = C; - - fn inner(&self) -> &Self::Compiler { - &self.compiler - } - - fn inner_mut(&mut self) -> &mut Self::Compiler { - &mut self.compiler - } - - fn wrap_compile( - &mut self, - world: &C::W, - env: &mut CompileEnv, - ) -> SourceResult>> { - let doc = self.inner_mut().compile(world, env)?; - self.exporter - .export(world, Arc::new(TypstDocument::Paged(doc.output.clone())))?; - - Ok(doc) - } -} - -pub type ReportExporter = DynExporter; -pub type FeaturedReportExporter = DynExporter<(Arc, CompileReport)>; - -pub struct CompileReporter { - pub compiler: C, - pub reporter: DynGenericExporter, CompileReport)>, -} - -impl Clone for CompileReporter { - fn clone(&self) -> Self { - Self { - compiler: self.compiler.clone(), - reporter: self.reporter.clone(), - } - } -} - -impl CompileReporter { - pub fn new(compiler: C) -> Self { - let x: FeaturedReportExporter = GroupExporter::new(vec![]).into(); - Self { - compiler, - reporter: Arc::new(DynPolymorphicExporter::::new(x)), - } - } - - /// Wrap driver with a given reporter. - pub fn with_reporter(mut self, reporter: impl Into) -> Self { - self.set_reporter(reporter); - self - } - - /// set an reporter. - pub fn set_reporter(&mut self, reporter: impl Into) { - let reporter = reporter.into(); - let reporter: FeaturedReportExporter = Box::new( - move |world: &dyn World, inp: Arc<(Arc, CompileReport)>| { - // it is believed that no clone will happen here - reporter.export(world, Arc::new(inp.take().1)) - }, - ); - self.reporter = Arc::new(DynPolymorphicExporter::::new(reporter)); - } - - /// Wrap driver with a given featured reporter. - pub fn with_featured_reporter(mut self, reporter: impl Into) -> Self { - self.set_featured_reporter(reporter); - self - } - - /// set an featured reporter. - pub fn set_featured_reporter(&mut self, reporter: impl Into) { - self.reporter = Arc::new(DynPolymorphicExporter::::new(reporter.into())); - } - - /// Wrap driver with a given generic reporter. - pub fn with_generic_reporter( - mut self, - reporter: impl GenericExporter<(Arc, CompileReport), W = W> + Send + Sync + 'static, - ) -> Self { - self.reporter = Arc::new(reporter); - self - } - - /// set an generic reporter. - pub fn set_generic_reporter( - &mut self, - reporter: impl GenericExporter<(Arc, CompileReport), W = W> + Send + Sync + 'static, - ) { - self.reporter = Arc::new(reporter); - } -} - -impl> CompileMiddleware for CompileReporter -where - W: EntryReader, -{ - type Compiler = C; - - fn inner(&self) -> &Self::Compiler { - &self.compiler - } - - fn inner_mut(&mut self) -> &mut Self::Compiler { - &mut self.compiler - } - - fn wrap_compile( - &mut self, - world: &C::W, - env: &mut CompileEnv, - ) -> SourceResult>> { - let start = reflexo::time::now(); - // todo unwrap main id - let id = world.main_id().unwrap(); - if WITH_COMPILING_STATUS_FEATURE.retrieve(&env.features) { - let rep = CompileReport::Stage(id, "compiling", start); - let rep = Arc::new((env.features.clone(), rep)); - // we currently ignore export error here - let _ = self.reporter.export(world, rep); - } - - let doc = self.inner_mut().compile(world, env); - - let elapsed = start.elapsed().unwrap_or_default(); - - let rep; - - let doc = match doc { - Ok(doc) => { - rep = CompileReport::CompileSuccess(id, doc.warnings.clone(), elapsed); - - Ok(doc) - } - Err(err) => { - rep = CompileReport::CompileError(id, err, elapsed); - Err(eco_vec![]) - } - }; - - let rep = Arc::new((env.features.clone(), rep)); - // we currently ignore export error here - let _ = self.reporter.export(world, rep); - - doc - } -} +pub use tinymist_task::compute::*; + +// pub struct CompileStarter>> +// { pub compiler: C, +// f: std::marker::PhantomData, +// } + +// impl>> CompileStarter +// { pub fn new(compiler: C) -> Self { +// Self { +// compiler, +// f: std::marker::PhantomData, +// } +// } +// } + +// impl> + Clone> +// Exporter> for CompileStarter +// { +// fn export(&self, _world: &dyn World, output: Arc>) -> +// SourceResult<()> { self.compiler +// .clone() +// .compile(&output.world, &mut output.env.clone()) +// .map(|_| ()) +// } +// } + +// #[derive(Clone)] +// pub struct CompileExporter { +// pub exporter: Arc>, +// } + +// impl Default for CompileExporter { +// fn default() -> Self { +// Self::new(C::default()) +// } +// } + +// impl CompileExporter { +// pub fn new(compiler: C) -> Self { +// Self { +// compiler, +// exporter: Arc::new(GroupExporter::new(vec![]).into()), +// } +// } + +// /// Wrap driver with a given exporter. +// pub fn with_exporter(mut self, exporter: DynComputation) -> Self { +// self.set_exporter(exporter); +// self +// } + +// /// set an exporter. +// pub fn set_exporter(&mut self, exporter: impl +// Into>) { self.exporter = +// Arc::new(exporter.into()); } +// } + +// impl Exporter> for +// CompileExporter { /// Export a typst document using +// `reflexo_typst::DocumentExporter`. fn export(&self, world: &dyn World, +// output: Arc>) -> SourceResult<()> { let doc = +// output.as_ref().clone().compile().doc?; self.exporter.export(world, +// Arc::new(doc))?; + +// Ok(()) +// } +// } + +// impl CompileMiddleware for CompileExporter { +// type Compiler = C; + +// fn inner(&self) -> &Self::Compiler { +// &self.compiler +// } + +// fn inner_mut(&mut self) -> &mut Self::Compiler { +// &mut self.compiler +// } + +// fn wrap_compile( +// &mut self, +// world: &C::W, +// env: &mut CompileEnv, +// ) -> SourceResult>> { +// let doc = self.inner_mut().compile(world, env)?; +// self.exporter +// .export(world, +// Arc::new(TypstDocument::Paged(doc.output.clone())))?; + +// Ok(doc) +// } +// } + +// pub type ReportExporter = DynExporter; +// pub type FeaturedReportExporter = DynExporter<(Arc, +// CompileReport)>; + +// pub struct CompileReporter { +// pub compiler: C, +// pub reporter: DynGenericExporter, CompileReport)>, +// } + +// impl Clone for CompileReporter { +// fn clone(&self) -> Self { +// Self { +// compiler: self.compiler.clone(), +// reporter: self.reporter.clone(), +// } +// } +// } + +// impl CompileReporter { +// pub fn new(compiler: C) -> Self { +// let x: FeaturedReportExporter = GroupExporter::new(vec![]).into(); +// Self { +// compiler, +// reporter: Arc::new(DynPolymorphicExporter::::new(x)), +// } +// } + +// /// Wrap driver with a given reporter. +// pub fn with_reporter(mut self, reporter: impl Into) -> +// Self { self.set_reporter(reporter); +// self +// } + +// /// set an reporter. +// pub fn set_reporter(&mut self, reporter: impl Into) { +// let reporter = reporter.into(); +// let reporter: FeaturedReportExporter = Box::new( +// move |world: &dyn World, inp: Arc<(Arc, +// CompileReport)>| { // it is believed that no clone will +// happen here reporter.export(world, Arc::new(inp.take().1)) +// }, +// ); +// self.reporter = Arc::new(DynPolymorphicExporter::::new(reporter)); } + +// /// Wrap driver with a given featured reporter. +// pub fn with_featured_reporter(mut self, reporter: impl +// Into) -> Self { self. +// set_featured_reporter(reporter); self +// } + +// /// set an featured reporter. +// pub fn set_featured_reporter(&mut self, reporter: impl +// Into) { self.reporter = +// Arc::new(DynPolymorphicExporter::::new(reporter.into())); } + +// /// Wrap driver with a given generic reporter. +// pub fn with_generic_reporter( +// mut self, +// reporter: impl GenericExporter<(Arc, CompileReport), W = +// W> + Send + Sync + 'static, ) -> Self { +// self.reporter = Arc::new(reporter); +// self +// } + +// /// set an generic reporter. +// pub fn set_generic_reporter( +// &mut self, +// reporter: impl GenericExporter<(Arc, CompileReport), W = +// W> + Send + Sync + 'static, ) { +// self.reporter = Arc::new(reporter); +// } +// } + +// impl> CompileMiddleware for CompileReporter where +// W: EntryReader, +// { +// type Compiler = C; + +// fn inner(&self) -> &Self::Compiler { +// &self.compiler +// } + +// fn inner_mut(&mut self) -> &mut Self::Compiler { +// &mut self.compiler +// } + +// fn wrap_compile( +// &mut self, +// world: &C::W, +// env: &mut CompileEnv, +// ) -> SourceResult>> { +// let start = reflexo::time::now(); +// // todo unwrap main id +// let id = world.main_id().unwrap(); +// if WITH_COMPILING_STATUS_FEATURE.retrieve(&env.features) { +// let rep = CompileReport::Stage(id, "compiling", start); +// let rep = Arc::new((env.features.clone(), rep)); +// // we currently ignore export error here +// let _ = self.reporter.export(world, rep); +// } + +// let doc = self.inner_mut().compile(world, env); + +// let elapsed = start.elapsed().unwrap_or_default(); + +// let rep; + +// let doc = match doc { +// Ok(doc) => { +// rep = CompileReport::CompileSuccess(id, doc.warnings.clone(), +// elapsed); + +// Ok(doc) +// } +// Err(err) => { +// rep = CompileReport::CompileError(id, err, elapsed); +// Err(eco_vec![]) +// } +// }; + +// let rep = Arc::new((env.features.clone(), rep)); +// // we currently ignore export error here +// let _ = self.reporter.export(world, rep); + +// doc +// } +// } pub type LayoutWidths = Vec; diff --git a/crates/reflexo-typst/src/export/dynamic_layout.rs b/crates/reflexo-typst/src/export/dynamic_layout.rs index 91b99abc2..9f9e3ed44 100644 --- a/crates/reflexo-typst/src/export/dynamic_layout.rs +++ b/crates/reflexo-typst/src/export/dynamic_layout.rs @@ -12,9 +12,7 @@ use typst::{diag::SourceResult, World}; use crate::typst::prelude::*; use crate::vector::ir::{LayoutRegion, LayoutRegionNode}; use crate::world::{CompilerFeat, CompilerWorld}; -use crate::{ - CompileEnv, CompileSnapshot, Compiler, Exporter, TypstDict, TypstPagedDocument as Document, -}; +use crate::{CompileEnv, CompileSnapshot, Compiler, TypstDict, TypstPagedDocument as Document}; pub type LayoutWidths = EcoVec; @@ -26,8 +24,7 @@ pub type PostProcessLayoutsFn = Arc) -> Vec + Send + Sync>; // todo: derive clone may slow? -pub struct DynamicLayoutCompiler>> { - pub compiler: C, +pub struct DynamicLayoutCompiler { // todo: abstract this output: PathBuf, pub extension: String, @@ -48,12 +45,9 @@ pub struct DynamicLayoutCompiler> + Clone> Clone - for DynamicLayoutCompiler -{ +impl Clone for DynamicLayoutCompiler { fn clone(&self) -> Self { Self { - compiler: self.compiler.clone(), output: self.output.clone(), extension: self.extension.clone(), layout_widths: self.layout_widths.clone(), @@ -65,10 +59,9 @@ impl> + Clone> Clone } } -impl>> DynamicLayoutCompiler { - pub fn new(compiler: C, output: PathBuf) -> Self { +impl DynamicLayoutCompiler { + pub fn new(output: PathBuf) -> Self { Self { - compiler, output, extension: "multi.sir.in".to_owned(), layout_widths: LayoutWidths::from_iter( @@ -83,14 +76,6 @@ impl>> DynamicLayoutCompiler &C { - &self.compiler - } - - pub fn inner_mut(&mut self) -> &mut C { - &mut self.compiler - } - pub fn set_output(&mut self, output: PathBuf) { self.output = output; } @@ -143,9 +128,9 @@ impl>> DynamicLayoutCompiler -impl>> DynamicLayoutCompiler { +impl DynamicLayoutCompiler { /// Export a typst document using `reflexo_typst::DocumentExporter`. - pub fn do_export( + pub fn do_export( &mut self, world: &CompilerWorld, env: &mut CompileEnv, @@ -156,7 +141,7 @@ impl>> DynamicLayoutCompiler( &mut self, world: &CompilerWorld, env: &mut CompileEnv, @@ -191,20 +176,22 @@ impl>> DynamicLayoutCompiler>> DynamicLayoutCompiler> + Clone> Exporter> - for DynamicLayoutCompiler -{ - fn export(&self, _world: &dyn World, output: Arc>) -> SourceResult<()> { - self.clone() - .compile(&output.world, &mut output.env.clone()) - .map(|_| ()) - } -} - -impl>> Compiler for DynamicLayoutCompiler { - type W = CompilerWorld; - - fn compile( - &mut self, - world: &Self::W, - env: &mut CompileEnv, - ) -> SourceResult>> { - let (res, doc) = self.do_export(world, env)?; - std::fs::write(self.module_dest_path(), doc.to_bytes()).unwrap(); - Ok(res) - } -} +// impl Compiler for DynamicLayoutCompiler { +// type W = CompilerWorld; + +// fn compile( +// &mut self, +// world: &Self::W, +// env: &mut CompileEnv, +// ) -> SourceResult>> { +// // let (res, doc) = self.do_export(world, env)?; +// // std::fs::write(self.module_dest_path(), doc.to_bytes()).unwrap(); +// // Ok(res) +// todo!() +// } +// } diff --git a/crates/reflexo-typst/src/exporter.rs b/crates/reflexo-typst/src/exporter.rs index c78846cfd..e08f5dda9 100644 --- a/crates/reflexo-typst/src/exporter.rs +++ b/crates/reflexo-typst/src/exporter.rs @@ -1,6 +1,9 @@ use std::sync::Arc; -use typst::{diag::SourceResult, World}; +use reflexo::error::prelude::*; +use tinymist_world::WorldComputeGraph; + +mod prelude; #[cfg(feature = "ast")] pub mod ast; @@ -10,6 +13,8 @@ pub mod json; #[cfg(feature = "pdf")] pub mod pdf; +#[cfg(feature = "svg")] +pub mod dyn_svg; #[cfg(feature = "svg")] pub mod svg; @@ -18,315 +23,4 @@ pub mod html; pub mod text; -pub type DynExporter = Box + Send + Sync>; - -pub trait Transformer { - /// Export the given input with given world. the writable world is hidden by - /// trait itself. - fn export(&self, world: &dyn World, output: Input) -> SourceResult; -} - -/// Lambda can automatically implement the Transformer trait. -impl Transformer for F -where - F: (for<'a> Fn(&'a (dyn World + 'a), I) -> SourceResult) + Sized, -{ - fn export(&self, world: &dyn World, output: I) -> SourceResult { - self(world, output) - } -} - -pub trait Exporter { - /// Export the given input with given world. the writable world is hidden by - /// trait itself. - fn export(&self, world: &dyn World, output: Arc) -> SourceResult; -} - -/// Lambda can automatically implement the Exporter trait. -impl Exporter for F -where - F: (for<'a> Fn(&'a (dyn World + 'a), Arc) -> SourceResult) + Sized, -{ - fn export(&self, world: &dyn World, output: Arc) -> SourceResult { - self(world, output) - } -} - -impl From for DynExporter -where - F: (for<'a> Fn(&'a (dyn World + 'a), Arc) -> SourceResult) - + Sized - + Send - + Sync - + 'static, -{ - fn from(f: F) -> Self { - Box::new(f) - } -} - -pub type DynGenericExporter = - Arc + Send + Sync>; - -pub trait GenericTransformer { - type W; - - /// Export the given input with given world. the writable world is hidden by - /// trait itself. - fn export(&self, world: &Self::W, output: Input) -> SourceResult; -} - -pub trait GenericExporter { - type W; - - /// Export the given input with given world. the writable world is hidden by - /// trait itself. - fn export(&self, world: &Self::W, output: Arc) -> SourceResult; -} - -pub enum DynPolymorphicExporter { - /// It is just applied to exactly the same world type. - Just(DynGenericExporter), - /// A dynamic exporter that can be applied to any dyn world. - Dyn(DynExporter), -} - -impl DynPolymorphicExporter { - pub fn new(exporter: DynExporter) -> Self { - Self::Dyn(exporter) - } - pub fn new_dyn(exporter: DynExporter) -> Self { - Self::Dyn(exporter) - } -} - -impl GenericExporter for DynPolymorphicExporter -where - X: World, -{ - type W = X; - - fn export(&self, world: &Self::W, output: Arc) -> SourceResult { - match self { - Self::Just(exporter) => exporter.export(world, output), - Self::Dyn(exporter) => exporter.export(world, output), - } - } -} - -pub mod builtins { - use std::{fs::File, sync::Arc}; - - use crate::{exporter_utils::map_err, AsOwnedBytes, AsOwnedString, AsWritable, Transformer}; - - use super::{utils, DynExporter, Exporter}; - use ecow::EcoVec; - use typst::{diag::SourceResult, World}; - - pub struct GroupExporter { - exporters: Vec>, - } - - impl GroupExporter { - pub fn new(exporters: Vec>) -> Self { - Self { exporters } - } - - pub fn push_front(&mut self, exporter: DynExporter) { - self.exporters.insert(0, exporter) - } - - pub fn push(&mut self, exporter: DynExporter) { - self.exporters.push(exporter) - } - - pub fn is_empty(&self) -> bool { - self.exporters.is_empty() - } - } - - impl Exporter for GroupExporter { - fn export(&self, world: &dyn World, output: Arc) -> SourceResult<()> { - let mut errors = EcoVec::new(); - - for f in &self.exporters { - utils::collect_err(&mut errors, f.export(world, output.clone())) - } - - if errors.is_empty() { - Ok(()) - } else { - Err(errors) - } - } - } - - impl From> for DynExporter { - fn from(exporter: GroupExporter) -> Self { - Box::new(exporter) - } - } - - /// The Exporter> must be explicitly constructed. - pub struct FromExporter { - exporter: GroupExporter, - - from_input: std::marker::PhantomData, - } - - impl FromExporter { - pub fn new(exporters: Vec>) -> Self { - Self { - exporter: GroupExporter { exporters }, - from_input: std::marker::PhantomData, - } - } - } - - impl Exporter for FromExporter - where - A: for<'a> From<&'a I>, - { - fn export(&self, world: &dyn World, output: Arc) -> SourceResult<()> { - let as_output = output.as_ref().into(); - self.exporter.export(world, Arc::new(as_output)) - } - } - - impl From> for DynExporter - where - A: for<'a> From<&'a I>, - { - fn from(exporter: FromExporter) -> Self { - Box::new(exporter) - } - } - - pub struct FsPathExporter { - path: std::path::PathBuf, - exporter: E, - - as_bytes: std::marker::PhantomData, - } - - impl FsPathExporter { - pub fn new(path: std::path::PathBuf, exporter: E) -> Self { - Self { - path, - exporter, - as_bytes: std::marker::PhantomData, - } - } - } - - impl Exporter for FsPathExporter - where - E: Exporter, - Bytes: AsRef<[u8]>, - { - fn export(&self, world: &dyn World, output: Arc) -> SourceResult<()> { - let vec = self.exporter.export(world, output)?; - std::fs::write(&self.path, vec.as_ref()).map_err(map_err)?; - Ok(()) - } - } - - impl Exporter for FsPathExporter - where - E: Transformer<(Arc, File)>, - { - fn export(&self, world: &dyn World, output: Arc) -> SourceResult<()> { - let file = std::fs::File::create(&self.path).map_err(map_err)?; - - self.exporter.export(world, (output, file))?; - Ok(()) - } - } - - impl From> - for DynExporter - where - E: Exporter, - Bytes: AsRef<[u8]>, - { - fn from(exporter: FsPathExporter) -> Self { - Box::new(exporter) - } - } - - impl From> for DynExporter - where - E: Transformer<(Arc, File)>, - { - fn from(exporter: FsPathExporter) -> Self { - Box::new(exporter) - } - } - - pub struct VecExporter { - exporter: E, - - as_bytes: std::marker::PhantomData, - } - - impl VecExporter { - pub fn new(exporter: E) -> Self { - Self { - exporter, - as_bytes: std::marker::PhantomData, - } - } - } - - impl Exporter> for VecExporter - where - E: Exporter>, - { - fn export(&self, world: &dyn World, output: Arc) -> SourceResult> { - let vec = self.exporter.export(world, output)?; - Ok(vec) - } - } - - impl Exporter> for VecExporter - where - E: Exporter, - { - fn export(&self, world: &dyn World, output: Arc) -> SourceResult> { - let vec = self.exporter.export(world, output)?; - Ok(vec.into_bytes()) - } - } - - impl Exporter> for VecExporter - where - E: for<'a> Transformer<(Arc, &'a mut std::io::Cursor>)>, - { - fn export(&self, world: &dyn World, output: Arc) -> SourceResult> { - let mut cursor = std::io::Cursor::new(Vec::new()); - self.exporter.export(world, (output, &mut cursor))?; - Ok(cursor.into_inner()) - } - } -} - -pub mod utils { - use core::fmt::Display; - use ecow::{eco_vec, EcoVec}; - use typst::diag::{SourceDiagnostic, SourceResult}; - - pub fn collect_err(errors: &mut EcoVec, res: SourceResult<()>) { - if let Err(errs) = res { - errors.extend(errs); - } - } - - /// Convert the given error to a vector of source errors. - // todo: report the component position - pub fn map_err(e: E) -> EcoVec { - eco_vec![SourceDiagnostic::error( - typst::syntax::Span::detached(), - e.to_string(), - )] - } -} +pub type DynComputation = Arc>) -> Result<()> + Send + Sync>; diff --git a/crates/reflexo-typst/src/exporter/ast.rs b/crates/reflexo-typst/src/exporter/ast.rs index cf09b8ab8..ac15cf368 100644 --- a/crates/reflexo-typst/src/exporter/ast.rs +++ b/crates/reflexo-typst/src/exporter/ast.rs @@ -1,38 +1,54 @@ use std::fmt::Display; use std::{io, io::Write, sync::Arc}; -use reflexo::typst::TypstPagedDocument; +use reflexo::error::prelude::*; +use reflexo::typst::{Bytes, TypstPagedDocument}; +use tinymist_task::ExportTimings; +use tinymist_world::{CompilerFeat, OptionDocumentTask, WorldComputable, WorldComputeGraph}; +use typst::diag::FileError; +use typst::diag::SourceResult; use typst::syntax::{LinkedNode, Source, SyntaxKind, Tag}; -use typst::{ - diag::{At, FileError}, - syntax::Span, -}; - -use crate::Transformer; - -#[derive(Debug, Clone, Default)] -pub struct AstExporter {} - -impl Transformer<(Arc, W)> for AstExporter -where - W: std::io::Write, -{ - fn export( - &self, - world: &dyn typst::World, - (_output, writer): (Arc, W), - ) -> typst::diag::SourceResult<()> { - let mut writer = std::io::BufWriter::new(writer); - - let src = world.source(world.main()).at(Span::detached())?; +use typst::World; + +pub struct AstExportTask; + +pub struct AstExport; + +impl AstExport { + fn needs_run( + graph: &Arc>, + doc: Option<&TypstPagedDocument>, + _config: &AstExportTask, + ) -> bool { + let timing = tinymist_task::TaskWhen::OnType; + ExportTimings::needs_run(&graph.snap, Some(timing), doc).unwrap_or(true) + } +} + +impl WorldComputable for AstExport { + type Output = Option; + + fn compute(graph: &Arc>) -> Result { + if !OptionDocumentTask::needs_run(graph, Self::needs_run)? { + return Ok(None); + } + + let world = &graph.snap.world; + let mut writer = std::io::BufWriter::new(Vec::new()); + + let src = world + .source(world.main()) + .context_ut("failed to get main")?; let path = src.id().vpath().as_rootless_path(); dump_ast(&path.display().to_string(), &src, &mut writer) .map_err(|e| FileError::from_io(e, path)) - .at(Span::detached())?; + .context_ut("failed to dump ast")?; writer.flush().unwrap(); - Ok(()) + let inner = writer.into_inner().context_ut("failed to write ast")?; + + Ok(Some(Bytes::new(inner))) } } diff --git a/crates/reflexo-typst/src/exporter/dyn_svg.rs b/crates/reflexo-typst/src/exporter/dyn_svg.rs new file mode 100644 index 000000000..79bbb8fdc --- /dev/null +++ b/crates/reflexo-typst/src/exporter/dyn_svg.rs @@ -0,0 +1,279 @@ +use std::{path::PathBuf, sync::Arc}; + +use reflexo::typst::Bytes; +use reflexo_typst2vec::pass::{CommandExecutor, Typst2VecPass}; +use reflexo_typst2vec::IntoTypst; +use reflexo_vec2svg::{DynamicLayoutSvgExporter, MultiVecDocument}; +use tinymist_task::{ExportSvgTask, ExportTask}; +use tinymist_world::TaskInputs; +use typst::diag::Warned; +use typst::foundations::IntoValue; +use typst::utils::LazyHash; +use typst::{diag::SourceResult, World}; + +use super::prelude::*; +use crate::typst::prelude::*; +use crate::vector::ir::{LayoutRegion, LayoutRegionNode}; +use crate::world::{CompilerFeat, CompilerWorld}; +use crate::{CompileEnv, CompileSnapshot, Compiler, TypstDict, TypstPagedDocument as Document}; + +pub type LayoutWidths = EcoVec; + +pub type PostProcessLayoutFn = Arc< + dyn Fn(&mut Typst2VecPass, Arc, LayoutRegionNode) -> LayoutRegionNode + Send + Sync, +>; + +pub type PostProcessLayoutsFn = + Arc) -> Vec + Send + Sync>; + +#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct ExportDynSvgModuleTask { + #[serde(flatten)] + pub export: ExportTask, +} + +pub struct DynSvgModuleExport(std::marker::PhantomData); + +impl ExportComputation + for DynSvgModuleExport +{ + type Output = Bytes; + type Config = ExportDynSvgModuleTask; + + fn needs_run( + graph: &Arc>, + doc: Option<&TypstPagedDocument>, + config: &Self::Config, + ) -> bool { + let timing = config.export.when; + ExportTimings::needs_run(&graph.snap, Some(timing), doc).unwrap_or(true) + } + + fn run_with>>>( + g: &Arc>, + config: &Self::Config, + ) -> Result { + } + + fn run( + _g: &Arc>, + _doc: &Arc, + _config: &Self::Config, + ) -> Result { + None.context("not implemented") + } +} + +impl WorldComputable for DynSvgModuleExport { + type Output = Option; + + fn compute(graph: &Arc>) -> Result { + OptionDocumentTask::run_export::(graph) + } +} + +// todo: derive clone may slow? +pub struct DynamicLayoutCompiler { + // todo: abstract this + output: PathBuf, + pub extension: String, + + pub layout_widths: LayoutWidths, + + pub command_executor: Arc, + + post_process_layout: Option, + post_process_layouts: Option, + + /// Specify the target. It's default value is `web`. + /// You can specify a sub target like `web-dark` to refine the target. + /// Though we even don't encourage you to do so. + /// + /// Before typst allowing passing arguments to the compiler, this is + /// (probably) the only way to control the typst code's behavior. + pub target: String, +} + +impl Clone for DynamicLayoutCompiler { + fn clone(&self) -> Self { + Self { + output: self.output.clone(), + extension: self.extension.clone(), + layout_widths: self.layout_widths.clone(), + command_executor: self.command_executor.clone(), + post_process_layout: self.post_process_layout.clone(), + post_process_layouts: self.post_process_layouts.clone(), + target: self.target.clone(), + } + } +} + +impl DynamicLayoutCompiler { + pub fn new(output: PathBuf) -> Self { + Self { + output, + extension: "multi.sir.in".to_owned(), + layout_widths: LayoutWidths::from_iter( + (0..40).map(|i| { + typst::layout::Abs::pt(750.0) - typst::layout::Abs::pt(i as f64 * 10.0) + }), + ), + command_executor: Arc::new(()), + post_process_layout: None, + post_process_layouts: None, + target: "web".to_owned(), + } + } + + pub fn set_output(&mut self, output: PathBuf) { + self.output = output; + } + + pub fn set_extension(&mut self, extension: String) { + self.extension = extension; + } + + pub fn set_layout_widths(&mut self, layout_widths: LayoutWidths) { + self.layout_widths = layout_widths; + } + + pub fn set_target(&mut self, target: String) { + self.target = target; + } + + /// Experimental + pub fn set_command_executor( + &mut self, + command_sanitizer: Arc, + ) { + self.command_executor = command_sanitizer; + } + + /// Experimental + pub fn set_post_process_layout( + &mut self, + post_process_layout: impl Fn(&mut Typst2VecPass, Arc, LayoutRegionNode) -> LayoutRegionNode + + Send + + Sync + + 'static, + ) { + self.post_process_layout = Some(Arc::new(post_process_layout)); + } + + /// Experimental + pub fn set_post_process_layouts( + &mut self, + post_process_layouts: impl Fn(&mut Typst2VecPass, Vec) -> Vec + + Send + + Sync + + 'static, + ) { + self.post_process_layouts = Some(Arc::new(post_process_layouts)); + } + + pub fn module_dest_path(&self) -> PathBuf { + self.output.with_extension(&self.extension) + } +} + +// F: CompilerFeat, CompilerWorld +impl DynamicLayoutCompiler { + /// Export a typst document using `reflexo_typst::DocumentExporter`. + pub fn do_export( + &mut self, + world: &CompilerWorld, + env: &mut CompileEnv, + ) -> SourceResult<(Warned>, MultiVecDocument)> { + let mut svg_exporter = DynamicLayoutSvgExporter::default(); + svg_exporter.typst2vec.command_executor = self.command_executor.clone(); + self.do_export_with(world, env, svg_exporter) + } + + /// Export a typst document using `reflexo_typst::DocumentExporter`. + pub fn do_export_with( + &mut self, + world: &CompilerWorld, + env: &mut CompileEnv, + mut svg_exporter: reflexo_vec2svg::DynamicLayoutSvgExporter, + ) -> SourceResult<(Warned>, MultiVecDocument)> { + // self.export(doc.clone())?; + // checkout the entry file + + let mut std_doc = None; + + // for each 10pt we rerender once + let instant_begin = reflexo::time::Instant::now(); + for (i, current_width) in self.layout_widths.clone().into_iter().enumerate() { + let instant = reflexo::time::Instant::now(); + // replace layout + + let world = world.task(TaskInputs { + inputs: Some({ + let mut dict = TypstDict::new(); + dict.insert("x-page-width".into(), current_width.into_value()); + dict.insert("x-target".into(), self.target.clone().into_value()); + + Arc::new(LazyHash::new(dict)) + }), + ..Default::default() + }); + + log::trace!( + "rerendering {i} at {:?}, width={current_width:?} target={}", + instant - instant_begin, + self.target, + ); + + // compile and export document + let output = self.compiler.compile(&world, env)?; + let mut layout = svg_exporter.render(&output.output); + + if let Some(post_process_layout) = &self.post_process_layout { + layout = + post_process_layout(&mut svg_exporter.typst2vec, output.output.clone(), layout); + } + svg_exporter + .layouts + .push((current_width.into_typst(), layout)); + + log::trace!("rerendered {i} at {:?}", instant - instant_begin); + + std_doc = Some(output); + + todo!() + } + + // post process + let mut layouts = vec![LayoutRegion::new_by_scalar( + "width".into(), + svg_exporter.layouts, + )]; + if let Some(post_process_layouts) = &self.post_process_layouts { + layouts = post_process_layouts(&mut svg_exporter.typst2vec, layouts); + } + + // finalize + let module = svg_exporter.typst2vec.finalize(); + let doc = MultiVecDocument { module, layouts }; + + let instant = reflexo::time::Instant::now(); + log::trace!("multiple layouts finished at {:?}", instant - instant_begin); + + Ok((std_doc.unwrap(), doc)) + } +} + +impl Compiler for DynamicLayoutCompiler { + type W = CompilerWorld; + + fn compile( + &mut self, + world: &Self::W, + env: &mut CompileEnv, + ) -> SourceResult>> { + let (res, doc) = self.do_export(world, env)?; + std::fs::write(self.module_dest_path(), doc.to_bytes()).unwrap(); + Ok(res) + } +} diff --git a/crates/reflexo-typst/src/exporter/html.rs b/crates/reflexo-typst/src/exporter/html.rs index df1e57a95..d301872aa 100644 --- a/crates/reflexo-typst/src/exporter/html.rs +++ b/crates/reflexo-typst/src/exporter/html.rs @@ -3,15 +3,13 @@ use std::sync::Arc; use reflexo::typst::TypstHtmlDocument; use typst::{diag::SourceResult, World}; -use crate::Exporter; +// #[derive(Debug, Clone, Default)] +// pub struct HtmlExporter {} -#[derive(Debug, Clone, Default)] -pub struct HtmlExporter {} +// impl HtmlExporter {} -impl HtmlExporter {} - -impl Exporter> for HtmlExporter { - fn export(&self, _world: &dyn World, output: Arc) -> SourceResult> { - typst_html::html(output.as_ref()).map(|s| s.into_bytes()) - } -} +// impl Exporter> for HtmlExporter { +// fn export(&self, _world: &dyn World, output: Arc) -> +// SourceResult> { typst_html::html(output.as_ref()).map(|s| +// s.into_bytes()) } +// } diff --git a/crates/reflexo-typst/src/exporter/json.rs b/crates/reflexo-typst/src/exporter/json.rs index 3650a0fe5..efffea7e7 100644 --- a/crates/reflexo-typst/src/exporter/json.rs +++ b/crates/reflexo-typst/src/exporter/json.rs @@ -3,89 +3,86 @@ use std::sync::Arc; use serde::Serialize; use typst::{diag::SourceResult, World}; -use crate::exporter_utils::map_err; -use crate::{Exporter, Transformer}; +// #[derive(Debug, Clone)] +// pub struct JsonExporter { +// should_truncate_precision: bool, -#[derive(Debug, Clone)] -pub struct JsonExporter { - should_truncate_precision: bool, +// _marker: std::marker::PhantomData, +// } - _marker: std::marker::PhantomData, -} +// impl JsonExporter { +// pub fn new(should_truncate_precision: bool) -> Self { +// Self { +// should_truncate_precision, +// _marker: Default::default(), +// } +// } +// } -impl JsonExporter { - pub fn new(should_truncate_precision: bool) -> Self { - Self { - should_truncate_precision, - _marker: Default::default(), - } - } -} +// impl Default for JsonExporter { +// fn default() -> Self { +// Self::new(false) +// } +// } -impl Default for JsonExporter { - fn default() -> Self { - Self::new(false) - } -} +// impl Exporter for JsonExporter { +// fn export(&self, _world: &dyn World, output: Arc) -> +// SourceResult { let json_doc = { +// if self.should_truncate_precision { +// let value = +// &serde_json::to_value(output.as_ref()).map_err(map_err)?; +// serde_json::to_string(&truncate_precision(value)) } else { +// serde_json::to_string(output.as_ref()) +// } +// }; +// json_doc.map_err(map_err) +// } +// } -impl Exporter for JsonExporter { - fn export(&self, _world: &dyn World, output: Arc) -> SourceResult { - let json_doc = { - if self.should_truncate_precision { - let value = &serde_json::to_value(output.as_ref()).map_err(map_err)?; - serde_json::to_string(&truncate_precision(value)) - } else { - serde_json::to_string(output.as_ref()) - } - }; - json_doc.map_err(map_err) - } -} +// impl Transformer<(Arc, W)> for JsonExporter +// where +// W: std::io::Write, +// { +// fn export(&self, _world: &dyn World, (output, writer): (Arc, W)) -> +// SourceResult<()> { let json_doc = { +// if self.should_truncate_precision { +// let value = +// &serde_json::to_value(output.as_ref()).map_err(map_err)?; +// serde_json::to_writer(writer, &truncate_precision(value)) } else +// { serde_json::to_writer(writer, output.as_ref()) +// } +// }; +// json_doc.map_err(map_err) +// } +// } -impl Transformer<(Arc, W)> for JsonExporter -where - W: std::io::Write, -{ - fn export(&self, _world: &dyn World, (output, writer): (Arc, W)) -> SourceResult<()> { - let json_doc = { - if self.should_truncate_precision { - let value = &serde_json::to_value(output.as_ref()).map_err(map_err)?; - serde_json::to_writer(writer, &truncate_precision(value)) - } else { - serde_json::to_writer(writer, output.as_ref()) - } - }; - json_doc.map_err(map_err) - } -} +// fn truncate_precision(output: &serde_json::Value) -> serde_json::Value { +// fn walk_json(val: &serde_json::Value) -> serde_json::Value { +// match val { +// serde_json::Value::Array(arr) => { +// +// serde_json::json!(arr.iter().map(walk_json).collect::>()) +// } serde_json::Value::Object(obj) => { +// serde_json::json!(obj +// .iter() +// .map(|(k, v)| (k.clone(), walk_json(v))) +// .collect::>()) +// } +// serde_json::Value::Number(x) => { +// // round to 3 digits +// if x.is_f64() { +// if let Some(x) = x.as_f64() { +// serde_json::json!(((x * 1000.) as i64 as f64) / +// 1000.) } else { +// unreachable!() +// } +// } else { +// serde_json::json!(x) +// } +// } +// x => x.clone(), +// } +// } -fn truncate_precision(output: &serde_json::Value) -> serde_json::Value { - fn walk_json(val: &serde_json::Value) -> serde_json::Value { - match val { - serde_json::Value::Array(arr) => { - serde_json::json!(arr.iter().map(walk_json).collect::>()) - } - serde_json::Value::Object(obj) => { - serde_json::json!(obj - .iter() - .map(|(k, v)| (k.clone(), walk_json(v))) - .collect::>()) - } - serde_json::Value::Number(x) => { - // round to 3 digits - if x.is_f64() { - if let Some(x) = x.as_f64() { - serde_json::json!(((x * 1000.) as i64 as f64) / 1000.) - } else { - unreachable!() - } - } else { - serde_json::json!(x) - } - } - x => x.clone(), - } - } - - walk_json(output) -} +// walk_json(output) +// } diff --git a/crates/reflexo-typst/src/exporter/pdf.rs b/crates/reflexo-typst/src/exporter/pdf.rs index 3135c3614..8b1378917 100644 --- a/crates/reflexo-typst/src/exporter/pdf.rs +++ b/crates/reflexo-typst/src/exporter/pdf.rs @@ -1,40 +1 @@ -use std::sync::Arc; -use reflexo::typst::TypstPagedDocument; -use typst::{diag::SourceResult, World}; -use typst_pdf::{PdfOptions, PdfStandard, PdfStandards, Timestamp}; - -use crate::Exporter; - -#[derive(Debug, Clone, Default)] -pub struct PdfDocExporter { - ctime: Option, - standards: Option, -} - -impl PdfDocExporter { - pub fn with_ctime(mut self, v: Option) -> Self { - self.ctime = v; - self - } - - pub fn with_standard(mut self, v: Option) -> Self { - self.standards = v.map(|v| PdfStandards::new(&[v]).unwrap()); - self - } -} - -impl Exporter> for PdfDocExporter { - fn export(&self, _world: &dyn World, output: Arc) -> SourceResult> { - // todo: ident option - - typst_pdf::pdf( - output.as_ref(), - &PdfOptions { - timestamp: self.ctime, - standards: self.standards.clone().unwrap_or_default(), - ..Default::default() - }, - ) - } -} diff --git a/crates/reflexo-typst/src/exporter/prelude.rs b/crates/reflexo-typst/src/exporter/prelude.rs new file mode 100644 index 000000000..4105d2922 --- /dev/null +++ b/crates/reflexo-typst/src/exporter/prelude.rs @@ -0,0 +1,10 @@ +pub use std::sync::Arc; + +pub use reflexo::error::prelude::*; +pub use reflexo::typst::TypstPagedDocument; +pub use serde::{Deserialize, Serialize}; +pub use tinymist_task::ExportTimings; +pub use tinymist_world::{ + CompilerFeat, ExportComputation, OptionDocumentTask, WorldComputable, WorldComputeGraph, +}; +pub use typst::{diag::SourceResult, World}; diff --git a/crates/reflexo-typst/src/exporter/svg.rs b/crates/reflexo-typst/src/exporter/svg.rs index 81ec9df3e..3dce46d13 100644 --- a/crates/reflexo-typst/src/exporter/svg.rs +++ b/crates/reflexo-typst/src/exporter/svg.rs @@ -1,48 +1,127 @@ -use std::sync::Arc; +use super::prelude::*; +use reflexo::typst::Bytes; +use reflexo_vec2svg::{render_svg, render_svg_html, ExportFeature, SvgExporter}; +use tinymist_task::{ExportSvgTask, ExportTask}; -use reflexo::typst::TypstPagedDocument; -use reflexo_vec2svg::{ - render_svg, render_svg_html, DefaultExportFeature, ExportFeature, SvgExporter, -}; -use typst::{diag::SourceResult, World}; +#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct ExportWebSvgModuleTask { + #[serde(flatten)] + pub export: ExportTask, +} + +pub struct WebSvgModuleExport(std::marker::PhantomData); + +impl ExportComputation + for WebSvgModuleExport +{ + type Output = Bytes; + type Config = ExportWebSvgModuleTask; -use super::Exporter; + fn needs_run( + graph: &Arc>, + doc: Option<&TypstPagedDocument>, + config: &Self::Config, + ) -> bool { + let timing = config.export.when; + ExportTimings::needs_run(&graph.snap, Some(timing), doc).unwrap_or(true) + } -pub struct SvgHtmlExporter { - _marker: std::marker::PhantomData, + fn run( + _g: &Arc>, + doc: &Arc, + _config: &Self::Config, + ) -> Result { + Ok(Bytes::new(SvgExporter::::svg_doc(doc).to_bytes())) + } } -impl Default for SvgHtmlExporter { - fn default() -> Self { - Self { - _marker: Default::default(), - } +impl WorldComputable for WebSvgModuleExport { + type Output = Option; + + fn compute(graph: &Arc>) -> Result { + OptionDocumentTask::run_export::(graph) } } -impl Exporter for SvgHtmlExporter { - fn export(&self, _world: &dyn World, output: Arc) -> SourceResult { - // html wrap - Ok(render_svg_html::(&output)) +#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct ExportWebSvgTask { + #[serde(flatten)] + pub base: ExportSvgTask, +} + +pub struct WebSvgExport(std::marker::PhantomData); + +impl ExportComputation + for WebSvgExport +{ + type Output = String; + type Config = ExportWebSvgTask; + + fn needs_run( + graph: &Arc>, + doc: Option<&TypstPagedDocument>, + config: &Self::Config, + ) -> bool { + let timing = config.base.export.when; + ExportTimings::needs_run(&graph.snap, Some(timing), doc).unwrap_or(true) + } + + fn run( + _g: &Arc>, + doc: &Arc, + _config: &Self::Config, + ) -> Result { + Ok(render_svg(doc)) + } +} + +impl WorldComputable for WebSvgExport { + type Output = Option; + + fn compute(graph: &Arc>) -> Result { + OptionDocumentTask::run_export::(graph) } } -#[derive(Default)] -pub struct PureSvgExporter; +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct ExportWebSvgHtmlTask { + #[serde(flatten)] + pub base: ExportSvgTask, +} + +pub struct WebSvgHtmlExport(std::marker::PhantomData); + +impl ExportComputation + for WebSvgHtmlExport +{ + type Output = String; + type Config = ExportWebSvgHtmlTask; + + fn needs_run( + graph: &Arc>, + doc: Option<&TypstPagedDocument>, + config: &Self::Config, + ) -> bool { + let timing = config.base.export.when; + ExportTimings::needs_run(&graph.snap, Some(timing), doc).unwrap_or(true) + } -impl Exporter for PureSvgExporter { - fn export(&self, _world: &dyn World, output: Arc) -> SourceResult { - // html wrap - Ok(render_svg(&output)) + fn run( + _g: &Arc>, + doc: &Arc, + _config: &Self::Config, + ) -> Result { + Ok(render_svg_html::(doc)) } } -#[derive(Default)] -pub struct SvgModuleExporter {} +impl WorldComputable for WebSvgHtmlExport { + type Output = Option; -impl Exporter> for SvgModuleExporter { - fn export(&self, _world: &dyn World, output: Arc) -> SourceResult> { - type UsingExporter = SvgExporter; - Ok(UsingExporter::svg_doc(&output).to_bytes()) + fn compute(graph: &Arc>) -> Result { + OptionDocumentTask::run_export::(graph) } } diff --git a/crates/reflexo-typst/src/exporter/text.rs b/crates/reflexo-typst/src/exporter/text.rs index f476ea18e..69c1ee29c 100644 --- a/crates/reflexo-typst/src/exporter/text.rs +++ b/crates/reflexo-typst/src/exporter/text.rs @@ -1,32 +1,50 @@ use core::fmt; -use std::io::Write; use std::sync::Arc; -use crate::exporter_utils::map_err; -use crate::{Transformer, TypstPagedDocument}; +use reflexo::typst::TypstDocument; +use tinymist_task::ExportTextTask; -#[derive(Debug, Clone, Default)] -pub struct TextExporter {} +use super::prelude::*; -impl Transformer<(Arc, W)> for TextExporter -where - W: std::io::Write, -{ - fn export( - &self, - _world: &dyn typst::World, - (output, writer): (Arc, W), - ) -> typst::diag::SourceResult<()> { - let mut w = std::io::BufWriter::new(writer); +use crate::TypstPagedDocument; - write!(w, "{}", FullTextDigest(output)).map_err(map_err)?; +pub struct TextExport; - w.flush().unwrap(); - Ok(()) +impl ExportComputation for TextExport { + type Output = String; + type Config = ExportTextTask; + + fn needs_run( + graph: &Arc>, + doc: Option<&TypstPagedDocument>, + config: &Self::Config, + ) -> bool { + let timing = config.export.when; + ExportTimings::needs_run(&graph.snap, Some(timing), doc).unwrap_or_default() + } + + fn run( + _g: &Arc>, + doc: &Arc, + _config: &ExportTextTask, + ) -> Result { + Ok(format!( + "{}", + FullTextDigest(TypstDocument::Paged(doc.clone())) + )) + } +} + +impl WorldComputable for TextExport { + type Output = Option; + + fn compute(graph: &Arc>) -> Result { + OptionDocumentTask::run_export::(graph) } } -struct FullTextDigest(Arc); +/// A full text digest of a document. +pub struct FullTextDigest(pub TypstDocument); impl FullTextDigest { fn export_frame(f: &mut fmt::Formatter<'_>, doc: &typst::layout::Frame) -> fmt::Result { @@ -57,9 +75,14 @@ impl FullTextDigest { impl fmt::Display for FullTextDigest { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - for page in self.0.pages.iter() { - Self::export_frame(f, &page.frame)?; + match &self.0 { + TypstDocument::Paged(paged_doc) => { + for page in paged_doc.pages.iter() { + Self::export_frame(f, &page.frame)?; + } + Ok(()) + } + _ => Err(fmt::Error), } - Ok(()) } } diff --git a/crates/reflexo-typst/src/lib.rs b/crates/reflexo-typst/src/lib.rs index b0eb9fed0..57f25927b 100644 --- a/crates/reflexo-typst/src/lib.rs +++ b/crates/reflexo-typst/src/lib.rs @@ -41,36 +41,33 @@ pub mod error; pub(crate) mod exporter; #[cfg(feature = "ast")] -pub use exporter::ast::{dump_ast, AstExporter}; +pub use exporter::ast::{dump_ast, AstExport, AstExportTask}; -#[cfg(feature = "html")] -pub use exporter::html::HtmlExporter; +// #[cfg(feature = "html")] +// pub use exporter::html::HtmlExporter; -pub use exporter::json::JsonExporter; +// pub use exporter::json::JsonExporter; -#[cfg(feature = "pdf")] -pub use exporter::pdf::PdfDocExporter; +// #[cfg(feature = "pdf")] +// pub use exporter::pdf::PdfDocExporter; #[cfg(feature = "pdf")] pub use typst_pdf::pdf; #[cfg(feature = "pdf")] pub use typst_pdf::PdfStandard; +#[cfg(feature = "dyn_svg")] +pub use exporter::dyn_svg::*; #[cfg(feature = "svg")] pub use exporter::svg::*; #[cfg(feature = "svg")] pub use reflexo_vec2svg as svg; -pub use exporter::text::TextExporter; +pub use exporter::text::TextExport; pub use reflexo_typst2vec as vector; pub use reflexo_typst2vec::debug_loc; pub use reflexo_typst2vec::hash; -pub use exporter::{builtins as exporter_builtins, utils as exporter_utils}; -pub use exporter::{ - DynExporter, DynGenericExporter, DynPolymorphicExporter, Exporter, GenericExporter, - GenericTransformer, Transformer, -}; // pub use font::{FontLoader, FontResolver, FontSlot}; pub use reflexo::typst_shim as compat; pub use reflexo::*; @@ -123,14 +120,17 @@ pub use watch::*; mod compile; #[cfg(feature = "system-watch")] pub mod task; +// #[cfg(feature = "system-compile")] +// pub use diag::ConsoleDiagReporter; #[cfg(feature = "system-compile")] -pub use diag::ConsoleDiagReporter; +pub type CompileDriver = CompileDriverImpl; #[cfg(feature = "system-compile")] -pub type CompileDriver = CompileDriverImpl; +pub type DynSystemComputation = DynComputation; pub use self::{diag::DiagnosticFormat, features::FeatureSet}; pub use driver::*; pub use export::*; +pub use exporter::DynComputation; use core::fmt; use std::sync::Arc; @@ -256,134 +256,134 @@ type CompileRawResult = Deferred<( )>; type DocState = std::sync::OnceLock; -/// A signal that possibly triggers an export. -/// -/// Whether to export depends on the current state of the document and the user -/// settings. -#[derive(Debug, Clone, Copy)] -pub struct ExportSignal { - /// Whether the revision is annotated by memory events. - pub by_mem_events: bool, - /// Whether the revision is annotated by file system events. - pub by_fs_events: bool, - /// Whether the revision is annotated by entry update. - pub by_entry_update: bool, -} - -pub struct CompileSnapshot { - /// The export signal for the document. - pub flags: ExportSignal, - /// Using env - pub env: CompileEnv, - /// Using world - pub world: Arc>, - /// Compiling the document. - doc_state: Arc, - /// The last successfully compiled document. - pub success_doc: Option, -} - -impl CompileSnapshot { - fn start(&self) -> &CompileRawResult { - self.doc_state.get_or_init(|| { - let w = self.world.clone(); - let mut env = self.env.clone(); - Deferred::new(move || { - let w = w.as_ref(); - let warned = std::marker::PhantomData.compile(&w, &mut env); - let (doc, warnings) = match warned { - Ok(doc) => (Ok(TypstDocument::Paged(doc.output)), doc.warnings), - Err(err) => (Err(err), EcoVec::default()), - }; - (doc, warnings, env) - }) - }) - } - - pub fn task(mut self, inputs: TaskInputs) -> Self { - 'check_changed: { - if let Some(entry) = &inputs.entry { - if *entry != self.world.entry_state() { - break 'check_changed; - } - } - if let Some(inputs) = &inputs.inputs { - if inputs.clone() != self.world.inputs() { - break 'check_changed; - } - } - - return self; - }; - - self.world = Arc::new(self.world.task(inputs)); - self.doc_state = Arc::new(OnceLock::new()); - - self - } - - pub fn compile(&self) -> CompiledArtifact { - let (doc, warnings, env) = self.start().wait().clone(); - CompiledArtifact { - signal: self.flags, - world: self.world.clone(), - env, - doc, - warnings, - success_doc: self.success_doc.clone(), - } - } -} - -impl Clone for CompileSnapshot { - fn clone(&self) -> Self { - Self { - flags: self.flags, - env: self.env.clone(), - world: self.world.clone(), - doc_state: self.doc_state.clone(), - success_doc: self.success_doc.clone(), - } - } -} - -pub struct CompiledArtifact { - /// All the export signal for the document. - pub signal: ExportSignal, - /// Used world - pub world: Arc>, - /// Used env - pub env: CompileEnv, - /// The diagnostics of the document. - pub warnings: EcoVec, - /// The compiled document. - pub doc: SourceResult, - /// The last successfully compiled document. - success_doc: Option, -} - -impl Clone for CompiledArtifact { - fn clone(&self) -> Self { - Self { - signal: self.signal, - world: self.world.clone(), - env: self.env.clone(), - doc: self.doc.clone(), - warnings: self.warnings.clone(), - success_doc: self.success_doc.clone(), - } - } -} - -impl CompiledArtifact { - pub fn success_doc(&self) -> Option { - self.doc - .as_ref() - .ok() - .cloned() - .or_else(|| self.success_doc.clone()) - } -} +// /// A signal that possibly triggers an export. +// /// +// /// Whether to export depends on the current state of the document and the +// user /// settings. +// #[derive(Debug, Clone, Copy)] +// pub struct ExportSignal { +// /// Whether the revision is annotated by memory events. +// pub by_mem_events: bool, +// /// Whether the revision is annotated by file system events. +// pub by_fs_events: bool, +// /// Whether the revision is annotated by entry update. +// pub by_entry_update: bool, +// } + +// pub struct CompileSnapshot { +// /// The export signal for the document. +// pub flags: ExportSignal, +// /// Using env +// pub env: CompileEnv, +// /// Using world +// pub world: Arc>, +// /// Compiling the document. +// doc_state: Arc, +// /// The last successfully compiled document. +// pub success_doc: Option, +// } + +// impl CompileSnapshot { +// fn start(&self) -> &CompileRawResult { +// self.doc_state.get_or_init(|| { +// let w = self.world.clone(); +// let mut env = self.env.clone(); +// Deferred::new(move || { +// let w = w.as_ref(); +// let warned = std::marker::PhantomData.compile(&w, &mut env); +// let (doc, warnings) = match warned { +// Ok(doc) => (Ok(TypstDocument::Paged(doc.output)), +// doc.warnings), Err(err) => (Err(err), EcoVec::default()), +// }; +// (doc, warnings, env) +// }) +// }) +// } + +// pub fn task(mut self, inputs: TaskInputs) -> Self { +// 'check_changed: { +// if let Some(entry) = &inputs.entry { +// if *entry != self.world.entry_state() { +// break 'check_changed; +// } +// } +// if let Some(inputs) = &inputs.inputs { +// if inputs.clone() != self.world.inputs() { +// break 'check_changed; +// } +// } + +// return self; +// }; + +// self.world = Arc::new(self.world.task(inputs)); +// self.doc_state = Arc::new(OnceLock::new()); + +// self +// } + +// pub fn compile(&self) -> CompiledArtifact { +// let (doc, warnings, env) = self.start().wait().clone(); +// CompiledArtifact { +// signal: self.flags, +// world: self.world.clone(), +// env, +// doc, +// warnings, +// success_doc: self.success_doc.clone(), +// } +// } +// } + +// impl Clone for CompileSnapshot { +// fn clone(&self) -> Self { +// Self { +// flags: self.flags, +// env: self.env.clone(), +// world: self.world.clone(), +// doc_state: self.doc_state.clone(), +// success_doc: self.success_doc.clone(), +// } +// } +// } + +// pub struct CompiledArtifact { +// /// All the export signal for the document. +// pub signal: ExportSignal, +// /// Used world +// pub world: Arc>, +// /// Used env +// pub env: CompileEnv, +// /// The diagnostics of the document. +// pub warnings: EcoVec, +// /// The compiled document. +// pub doc: SourceResult, +// /// The last successfully compiled document. +// success_doc: Option, +// } + +// impl Clone for CompiledArtifact { +// fn clone(&self) -> Self { +// Self { +// signal: self.signal, +// world: self.world.clone(), +// env: self.env.clone(), +// doc: self.doc.clone(), +// warnings: self.warnings.clone(), +// success_doc: self.success_doc.clone(), +// } +// } +// } + +// impl CompiledArtifact { +// pub fn success_doc(&self) -> Option { +// self.doc +// .as_ref() +// .ok() +// .cloned() +// .or_else(|| self.success_doc.clone()) +// } +// } pub trait EnvWorld { fn prepare_env(&mut self, _env: &mut CompileEnv) -> SourceResult<()> { @@ -395,6 +395,11 @@ pub trait EnvWorld { } } +pub fn ensure_main(world: &impl EntryReader) -> SourceResult<()> { + let check_main = world.main_id().ok_or_else(|| eco_format!("no entry file")); + check_main.at(Span::detached()).map(|_| ()) +} + pub trait Compiler { type W: World; diff --git a/crates/reflexo-typst/src/task.rs b/crates/reflexo-typst/src/task.rs index 4b2325d0a..cee558cf4 100644 --- a/crates/reflexo-typst/src/task.rs +++ b/crates/reflexo-typst/src/task.rs @@ -4,6 +4,9 @@ mod cache; pub use cache::*; +// mod export; +// pub use export::*; +pub use tinymist_task::*; use std::{ops::DerefMut, pin::Pin, sync::Arc}; diff --git a/packages/compiler/src/lib.rs b/packages/compiler/src/lib.rs index 615151c7d..026006837 100644 --- a/packages/compiler/src/lib.rs +++ b/packages/compiler/src/lib.rs @@ -109,7 +109,7 @@ fn convert_diag( #[wasm_bindgen] pub struct TypstCompiler { - pub(crate) driver: CompileDriverImpl, BrowserCompilerFeat>, + pub(crate) driver: CompileDriverImpl, } impl TypstCompiler { @@ -120,7 +120,7 @@ impl TypstCompiler { ) -> Result { Ok(Self { driver: CompileDriverImpl::new( - std::marker::PhantomData, + todo!(), TypstBrowserUniverse::new( std::path::Path::new("/").to_owned(), None, @@ -304,38 +304,41 @@ impl TypstCompiler { fmt: String, diagnostics_format: u8, ) -> Result { - let vec_exporter: DynExporter> = match fmt.as_str() { - "vector" => Box::new(reflexo_typst::exporter_builtins::VecExporter::new( - reflexo_typst::SvgModuleExporter::default(), - )), - "pdf" => Box::::default(), - _ => { - return Err(error_once!("Unsupported fmt", format: fmt).into()); - } - }; - - let world = self.driver.snapshot(); - - let doc = take_diag!( - diagnostics_format, - &world, - self.driver.compile(&mut Default::default()) - ); - let artifact_bytes = take_diag!( - diagnostics_format, - &world, - vec_exporter.export(&world, doc.output) - ); - - let v: JsValue = Uint8Array::from(artifact_bytes.as_slice()).into(); - - Ok(if diagnostics_format != 0 { - let result = js_sys::Object::new(); - js_sys::Reflect::set(&result, &"result".into(), &v)?; - result.into() - } else { - v - }) + // let vec_exporter: DynExporter> = match + // fmt.as_str() { "vector" => + // Box::new(reflexo_typst::exporter_builtins::VecExporter::new( + // reflexo_typst::SvgModuleExporter::default(), + // )), + // "pdf" => Box::::default(), + // _ => { + // return Err(error_once!("Unsupported fmt", format: fmt).into()); + // } + // }; + + // let world = self.driver.snapshot(); + + // let doc = take_diag!( + // diagnostics_format, + // &world, + // self.driver.compile(&mut Default::default()) + // ); + // let artifact_bytes = take_diag!( + // diagnostics_format, + // &world, + // vec_exporter.export(&world, doc.output) + // ); + + // let v: JsValue = Uint8Array::from(artifact_bytes.as_slice()).into(); + + // Ok(if diagnostics_format != 0 { + // let result = js_sys::Object::new(); + // js_sys::Reflect::set(&result, &"result".into(), &v)?; + // result.into() + // } else { + // v + // }) + + todo!() } pub fn set_compiler_options( diff --git a/packages/typst.node/src/compiler/boxed.rs b/packages/typst.node/src/compiler/boxed.rs index 7ef5c4665..32ab69f56 100644 --- a/packages/typst.node/src/compiler/boxed.rs +++ b/packages/typst.node/src/compiler/boxed.rs @@ -5,9 +5,9 @@ use std::{ sync::Arc, }; -use reflexo_typst::foundations::Content; use reflexo_typst::typst::prelude::*; use reflexo_typst::{config::entry::MEMORY_MAIN_ENTRY, typst::diag::Warned}; +use reflexo_typst::{ensure_main, foundations::Content}; use reflexo_typst::{ error::{prelude::*, TypstSourceDiagnostic}, TypstDocument, @@ -28,11 +28,11 @@ where } // -pub struct BoxedCompiler(Box>>); +pub struct BoxedCompiler(Box); // impl Deref for BoxedCompiler { - type Target = CompileDriver>; + type Target = CompileDriver; fn deref(&self) -> &Self::Target { self.0.as_ref() @@ -46,14 +46,12 @@ impl DerefMut for BoxedCompiler { } // -impl From>> for BoxedCompiler { - fn from(value: CompileDriver>) -> Self { +impl From for BoxedCompiler { + fn from(value: CompileDriver) -> Self { Self(Box::new(value)) } } -type SourceResult = Result>; - impl BoxedCompiler { /// Create a snapshoted world by typst.node's [`CompileDocArgs`]. /// Should not affect the current universe (global state). @@ -124,53 +122,10 @@ impl BoxedCompiler { // FIXME: This is implementation detail, use a better way from // the compiler driver. - let c = &mut self.0.compiler; - c.ensure_main(&world).map_err(map_node_error)?; - Ok(c.compile(&world, &mut CompileEnv::default()).into()) - } -} - -/// A blanket implementation for all `CompileMiddleware`. -/// If you want to wrap a compiler, you should override methods in -/// `CompileMiddleware`. -impl Compiler for BoxedCompiler { - type W = TypstSystemWorld; - - #[inline] - fn pure_compile( - &mut self, - world: &TypstSystemWorld, - env: &mut CompileEnv, - ) -> SourceResult>> { - self.0.compiler.pure_compile(world, env) - } + // let c = &mut self.0.compiler; + // ensure_main(&world).map_err(map_node_error)?; + // Ok(c.compile(&world, &mut CompileEnv::default()).into()) - #[inline] - fn pure_query( - &mut self, - world: &TypstSystemWorld, - selector: String, - document: &TypstDocument, - ) -> SourceResult> { - self.0.compiler.pure_query(world, selector, document) - } - - #[inline] - fn compile( - &mut self, - world: &TypstSystemWorld, - env: &mut CompileEnv, - ) -> SourceResult>> { - self.0.compiler.compile(world, env) - } - - #[inline] - fn query( - &mut self, - world: &TypstSystemWorld, - selector: String, - document: &TypstDocument, - ) -> SourceResult> { - self.0.compiler.query(world, selector, document) + todo!() } } diff --git a/packages/typst.node/src/compiler/mod.rs b/packages/typst.node/src/compiler/mod.rs index b67a0a76d..ae8fa376f 100644 --- a/packages/typst.node/src/compiler/mod.rs +++ b/packages/typst.node/src/compiler/mod.rs @@ -79,9 +79,7 @@ pub struct NodeCompileArgs { pub inputs: Option>, } -pub fn create_driver( - args: Option, -) -> ZResult>> { +pub fn create_driver(args: Option) -> ZResult { use reflexo_typst::path::PathClean; let args = args.unwrap_or_default(); let workspace_dir = Path::new(args.workspace.unwrap_or_default().as_str()).clean(); @@ -132,7 +130,7 @@ pub fn create_driver( Arc::new(searcher.into()), ); - Ok(CompileDriver::new(std::marker::PhantomData, world)) + Ok(CompileDriver::new(todo!(), world)) } /// Convert the input pairs to a dictionary. diff --git a/packages/typst.node/src/error.rs b/packages/typst.node/src/error.rs index 42242a5cd..1f2566a30 100644 --- a/packages/typst.node/src/error.rs +++ b/packages/typst.node/src/error.rs @@ -7,7 +7,7 @@ use reflexo_typst::typst::diag::Warned; use reflexo_typst::typst::prelude::*; use reflexo_typst::{TypstPagedDocument, TypstWorld}; -use crate::NodeTypstPagedDocument; +use crate::NodeTypstDocument; /// The error status of a node error. pub enum NodeErrorStatus { @@ -158,7 +158,7 @@ pub fn map_node_error(e: impl Into) -> napi::Error { /// Result of single typst compilation. #[napi] pub struct NodeTypstCompileResult { - result: Option, + result: Option, // todo: better warning structure warnings: Option, error: Option, @@ -168,7 +168,7 @@ pub struct NodeTypstCompileResult { impl NodeTypstCompileResult { /// Gets the result of compilation. #[napi(getter)] - pub fn result(&self) -> Option { + pub fn result(&self) -> Option { self.result.clone() } @@ -190,21 +190,22 @@ where E: Into, { fn from(res: Result>, E>) -> Self { - match res { - Ok(result) => NodeTypstCompileResult { - result: Some(NodeTypstPagedDocument(result.output)), - warnings: if result.warnings.is_empty() { - None - } else { - Some(result.warnings.into()) - }, - error: None, - }, - Err(e) => NodeTypstCompileResult { - result: None, - warnings: None, - error: Some(e.into()), - }, - } + // match res { + // Ok(result) => NodeTypstCompileResult { + // result: Some(NodeTypstDocument(result.output)), + // warnings: if result.warnings.is_empty() { + // None + // } else { + // Some(result.warnings.into()) + // }, + // error: None, + // }, + // Err(e) => NodeTypstCompileResult { + // result: None, + // warnings: None, + // error: Some(e.into()), + // }, + // } + todo!() } } diff --git a/packages/typst.node/src/lib.rs b/packages/typst.node/src/lib.rs index 347cfd6b3..b56db9567 100644 --- a/packages/typst.node/src/lib.rs +++ b/packages/typst.node/src/lib.rs @@ -414,7 +414,7 @@ impl NodeCompiler { #[napi] pub struct DynLayoutCompiler { /// Inner compiler. - driver: DynamicLayoutCompiler, + driver: DynamicLayoutCompiler, } #[napi] @@ -422,9 +422,10 @@ impl DynLayoutCompiler { /// Creates a new compiler based on the given arguments. #[napi] pub fn from_boxed(b: &mut JsBoxedCompiler) -> Self { - DynLayoutCompiler { - driver: DynamicLayoutCompiler::new(b.grab(), PathBuf::default()), - } + // DynLayoutCompiler { + // driver: DynamicLayoutCompiler::new(b.grab(), PathBuf::default()), + // } + todo!() } /// Sets the target of the compiler. @@ -443,47 +444,15 @@ impl DynLayoutCompiler { /// Exports the document as a vector IR containing multiple layouts. #[napi] pub fn vector(&mut self, compile_by: CompileDocArgs) -> Result { - let compiler = self.driver.inner_mut(); - let world = compiler.create_world(compile_by)?; - let doc = self - .driver - .do_export(&world, &mut Default::default()) - .map_err(map_node_error); - - Ok(doc?.1.to_bytes().into()) - } -} - -/// Parses a UNIX timestamp according to -fn parse_source_date_epoch(timestamp: i64) -> Result, NodeError> { - DateTime::from_timestamp(timestamp, 0) - .ok_or_else(|| map_node_error(error_once!("timestamp out of range"))) -} - -/// Convert [`chrono::DateTime`] to [`Timestamp`] -fn convert_datetime(date_time: chrono::DateTime) -> Option { - use chrono::{Datelike, Timelike}; - let datetime = TypstDatetime::from_ymd_hms( - date_time.year(), - date_time.month().try_into().ok()?, - date_time.day().try_into().ok()?, - date_time.hour().try_into().ok()?, - date_time.minute().try_into().ok()?, - date_time.second().try_into().ok()?, - ); - - Some(TypstTimestamp::new_utc(datetime.unwrap())) -} + // let compiler = self.driver.inner_mut(); + // let world = compiler.create_world(compile_by)?; + // let doc = self + // .driver + // .do_export(&world, &mut Default::default()) + // .map_err(map_node_error); -#[derive(Default)] -struct PlainSvgExporter {} + // Ok(doc?.1.to_bytes().into()) -impl Exporter for PlainSvgExporter { - fn export( - &self, - _world: &dyn TypstWorld, - output: Arc, - ) -> SourceResult { - Ok(typst_svg::svg_merged(&output, Default::default())) + todo!() } } diff --git a/server/dev/src/main.rs b/server/dev/src/main.rs index 90e339de6..badea8492 100644 --- a/server/dev/src/main.rs +++ b/server/dev/src/main.rs @@ -6,10 +6,7 @@ use clap::Parser; use log::info; use reflexo_typst::features::WITH_COMPILING_STATUS_FEATURE; use reflexo_typst::path::PathClean; -use reflexo_typst::{ - CompileDriver, CompileEnv, CompileExporter, CompileReporter, ConsoleDiagReporter, FeatureSet, - TypstSystemWorld, -}; +use reflexo_typst::{CompileDriver, CompileEnv, FeatureSet, TypstSystemWorld}; use tokio::io::AsyncBufReadExt; use typst_ts_dev_server::{ http::run_http, utils::async_continue, CompileCorpusArgs, CompileSubCommands, Opts, @@ -72,12 +69,12 @@ fn compile_corpus(args: CompileCorpusArgs) { let world = typst_ts_cli::compile::create_driver(compile_args.compile.clone()).universe; - let driver = CompileExporter::new(std::marker::PhantomData); + // let driver = CompileExporter::new(std::marker::PhantomData); - let mut driver = CompileReporter::<_, TypstSystemWorld>::new(driver); - driver.set_generic_reporter(ConsoleDiagReporter::default()); + // let mut driver = CompileReporter::<_, TypstSystemWorld>::new(driver); + // driver.set_generic_reporter(ConsoleDiagReporter::default()); - let mut driver = CompileDriver::new(driver, world); + let mut driver = CompileDriver::new(todo!(), world); // enable compiling status let feat_set = FeatureSet::default().configure(&WITH_COMPILING_STATUS_FEATURE, true); @@ -88,15 +85,18 @@ fn compile_corpus(args: CompileCorpusArgs) { let exporter = typst_ts_cli::export::prepare_exporters(&compile_args, Some(&entry)); - let exporter_layer = &mut driver.compiler.compiler; + // let exporter_layer = &mut driver.compiler.compiler; + + // exporter_layer.set_exporter(exporter); + // driver + // .universe + // .increment_revision(|verse| verse.set_entry_file(entry.as_path().into())) + // .unwrap(); - exporter_layer.set_exporter(exporter); - driver - .universe - .increment_revision(|verse| verse.set_entry_file(entry.as_path().into())) - .unwrap(); + // let _ = driver.compile(&mut + // CompileEnv::default().configure_shared(feat_set.clone())); - let _ = driver.compile(&mut CompileEnv::default().configure_shared(feat_set.clone())); + todo!() }; // get all corpus in workspace_path diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index c5dd28f49..dcbf39cde 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -4,56 +4,57 @@ use std::path::Path; use std::sync::Arc; use reflexo_typst::config::{entry::EntryOpts, CompileOpts}; -use reflexo_typst::exporter_builtins::{FsPathExporter, GroupExporter}; use reflexo_typst::path::PathClean; use reflexo_typst::{ - CompileDriver, CompileExporter, Exporter, PdfDocExporter, PureCompiler, SvgModuleExporter, - TypstDocument, TypstPagedDocument, TypstSystemUniverse, TypstSystemWorld, TypstWorld, + CompileDriver, DynSystemComputation, PureCompiler, TypstDocument, TypstPagedDocument, + TypstSystemUniverse, TypstSystemWorld, TypstWorld, }; fn get_driver( workspace_dir: &Path, entry_file_path: &Path, - exporter: GroupExporter, -) -> CompileDriver>> { + exporter: DynSystemComputation, +) -> CompileDriver { let world = TypstSystemUniverse::new(CompileOpts { entry: EntryOpts::new_workspace(workspace_dir.into()), no_system_fonts: true, ..CompileOpts::default() }) .unwrap(); - let exporter = GroupExporter::new(vec![Box::new( - move |world: &dyn TypstWorld, doc: Arc| match doc.as_ref() { - TypstDocument::Paged(doc) => exporter.export(world, doc.clone()), - _ => unreachable!(), - }, - )]); + // let exporter = GroupExporter::new(vec![Box::new( + // move |world: &dyn TypstWorld, doc: Arc| match doc.as_ref() + // { TypstDocument::Paged(doc) => exporter.export(world, + // doc.clone()), _ => unreachable!(), + // }, + // )]); let world = world.with_entry_file(entry_file_path.to_owned()); - CompileDriver::new(CompileExporter::default().with_exporter(exporter), world) + CompileDriver::new(exporter, world) } -macro_rules! document_exporters { - ($($exporters:expr),*) => { - { - let document_exporters: Vec + Send + Sync>> = vec![ - $(Box::new($exporters)),* - ]; - GroupExporter::new(document_exporters) - } - }; -} - -fn artifact_ir_to_path>(path: P) -> FsPathExporter, SvgModuleExporter> { - FsPathExporter::new(path.as_ref().to_owned(), SvgModuleExporter::default()) -} - -fn doc_pdf_to_path>(path: P) -> FsPathExporter, PdfDocExporter> { - FsPathExporter::new(path.as_ref().to_owned(), PdfDocExporter::default()) -} +// macro_rules! document_exporters { +// ($($exporters:expr),*) => { +// { +// let document_exporters: Vec + Send + Sync>> = vec![ +// $(Box::new($exporters)),* +// ]; +// GroupExporter::new(document_exporters) +// } +// }; +// } + +// fn artifact_ir_to_path>(path: P) -> FsPathExporter, +// SvgModuleExporter> { FsPathExporter::new(path.as_ref().to_owned(), +// SvgModuleExporter::default()) } + +// fn doc_pdf_to_path>(path: P) -> FsPathExporter, +// PdfDocExporter> { FsPathExporter::new(path.as_ref().to_owned(), +// PdfDocExporter::default()) } pub struct ArtifactBundle { - pub driver: CompileDriver>>, + // >> + pub driver: CompileDriver, pub tir: std::path::PathBuf, pub pdf: std::path::PathBuf, } @@ -81,10 +82,11 @@ impl ArtifactCompiler { let mut driver = get_driver( &real_workspace_dir, &real_entry_file_path, - document_exporters![ - artifact_ir_to_path(sir_file_path.clone()), - doc_pdf_to_path(pdf_file_path.clone()) - ], + // document_exporters![ + // artifact_ir_to_path(sir_file_path.clone()), + // doc_pdf_to_path(pdf_file_path.clone()) + // ], + todo!(), ); driver.compile(&mut Default::default()).unwrap();