diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index 252e482..0000000 --- a/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[build] -rustflags = ["--cfg=web_sys_unstable_apis"] \ No newline at end of file diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..fa7af03 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: fenjalien diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2bfc866 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# 0.5.0 +- Update Typst version to 0.6.0 +- Attempt to fix bad canvas output +- Move compiler to a web worker +- Rework file reading +- Add support of reading packages outside of the vault +- Improve settings appearance (#7) +- Various bug fixes diff --git a/Cargo.lock b/Cargo.lock index f4f1dd1..18ad860 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,13 +10,19 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "arrayref" version = "0.3.7" @@ -25,9 +31,9 @@ checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" @@ -93,18 +99,18 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.2.1" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a6904aef64d73cf10ab17ebace7befb918b82164785cb89907993be7f83813" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" dependencies = [ "serde", ] [[package]] name = "bumpalo" -version = "3.12.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "bytemuck" @@ -150,14 +156,20 @@ checksum = "aeea139b89efab957972956e5d3e4efb66a6c261f726abf6911040cc8ef700f7" [[package]] name = "chrono" -version = "0.4.24" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ - "num-integer", + "android-tzdata", "num-traits", ] +[[package]] +name = "cobs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" + [[package]] name = "color_quant" version = "1.1.0" @@ -185,6 +197,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + [[package]] name = "crc32fast" version = "1.3.2" @@ -196,9 +218,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b015497079b9a9d69c02ad25de6c0a6edef051ea6360a327d0bd05802ef64ad" +checksum = "626ae34994d3d8d668f4269922248239db4ae42d538b14c398b74a52208e8086" dependencies = [ "csv-core", "itoa", @@ -223,13 +245,13 @@ checksum = "8d7439c3735f405729d52c3fbbe4de140eaf938a1fe47d227c27f8254d4302a5" [[package]] name = "displaydoc" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.23", ] [[package]] @@ -237,30 +259,29 @@ name = "ecow" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5c5051925c54d9a42c8652313b5358a7432eed209466b443ed5220431243a14" - -[[package]] -name = "elsa" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e0aca8dce8856e420195bd13b6a64de3334235ccc9214e824b86b12bf26283" dependencies = [ - "stable_deref_trait", + "serde", ] [[package]] name = "enum-ordinalize" -version = "3.1.12" +version = "3.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bb1df8b45ecb7ffa78dca1c17a438fb193eb083db0b1b494d2a61bcb5096a" +checksum = "e4f76552f53cefc9a7f64987c3701b99d982f7690606fd67de1d09712fbf52f1" dependencies = [ "num-bigint", "num-traits", "proc-macro2", "quote", - "rustc_version", - "syn 1.0.109", + "syn 2.0.23", ] +[[package]] +name = "equivalent" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" + [[package]] name = "fancy-regex" version = "0.7.1" @@ -271,6 +292,16 @@ dependencies = [ "regex", ] +[[package]] +name = "fast_image_resize" +version = "2.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc789a40040e11bbe4ba31ca319406805a12fe3f8d71314bbc4bd076602ad55a" +dependencies = [ + "num-traits", + "thiserror", +] + [[package]] name = "fdeflate" version = "0.3.0" @@ -282,12 +313,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "miniz_oxide 0.6.2", + "miniz_oxide", ] [[package]] @@ -316,9 +347,9 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -339,6 +370,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "hayagriva" version = "0.3.0" @@ -373,10 +410,122 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0cf92443ef10ecfc1b8b4b65a93e31d983f020a355699d83874b12a7c797ac3" [[package]] -name = "idna" -version = "0.3.0" +name = "icu_collections" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "ef8302d8dfd6044d3ddb3f807a5ef3d7bbca9a574959c6d6e4dc39aa7012d0d5" +dependencies = [ + "displaydoc", + "serde", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3003f85dccfc0e238ff567693248c59153a46f4e6125ba4020b973cef4d1d335" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_properties" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce0e1aa26851f16c9e04412a5911c86b7f8768dac8f8d4c5f1c568a7e5d7a434" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_provider", + "serde", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_provider" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc312a7b6148f7dfe098047ae2494d12d4034f48ade58d4f353000db376e305" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "postcard", + "serde", + "stable_deref_trait", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_adapters" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ae1e2bd0c41728b77e7c46e9afdec5e2127d1eedacc684724667d50c126bd3" +dependencies = [ + "icu_locid", + "icu_provider", + "tinystr", + "yoke", + "zerovec", +] + +[[package]] +name = "icu_provider_blob" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd364c9a01f791a4bc04a74cf2a1d01d9f6926a40fd5ae1c28004e1e70d8338b" +dependencies = [ + "icu_provider", + "postcard", + "serde", + "writeable", + "yoke", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b728b9421e93eff1d9f8681101b78fa745e0748c95c655c83f337044a7e10" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "icu_segmenter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3300a7b6bf187be98a57264ad094f11f2e062c2e8263132af010ff522ee5495" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid", + "icu_provider", + "num-traits", + "serde", + "utf8_iter", + "zerovec", +] + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -417,23 +566,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", ] [[package]] name = "isolang" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64fd6448ee8a45ce6e4365c58e4fa7d8740cba2ed70db3e9ab4879ebd93eaaa" +checksum = "f80f221db1bc708b71128757b9396727c04de86968081e18e89b0575e03be071" dependencies = [ "phf", ] [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" [[package]] name = "jpeg-decoder" @@ -443,9 +602,9 @@ checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" [[package]] name = "js-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -467,9 +626,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.142" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "libm" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "linked-hash-map" @@ -488,13 +653,16 @@ dependencies = [ ] [[package]] -name = "log" -version = "0.4.17" +name = "litemap" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "3a04a5b2b6f54acba899926491d0a6c59d98012938ca2ab5befb281c034e8f94" + +[[package]] +name = "log" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "memchr" @@ -511,15 +679,6 @@ dependencies = [ "libc", ] -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -569,6 +728,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -579,12 +739,12 @@ checksum = "e25be21376a772d15f97ae789845340a9651d3c4246ff5ebb6a2b35f9c37bd31" [[package]] name = "obsidian-typst" -version = "0.4.2" +version = "0.5.0" dependencies = [ "comemo", - "elsa", + "console_error_panic_hook", + "fast_image_resize", "js-sys", - "once_cell", "serde", "serde-wasm-bindgen", "siphasher", @@ -597,15 +757,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "paste" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" [[package]] name = "pdf-writer" @@ -620,24 +780,24 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "phf" -version = "0.10.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ "phf_shared", ] [[package]] name = "phf_shared" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" dependencies = [ "siphasher", ] @@ -650,9 +810,9 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pixglyph" @@ -665,15 +825,25 @@ dependencies = [ [[package]] name = "png" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaeebc51f9e7d2c150d3f3bfeb667f2aa985db5ef1e3d212847bdedb488beeaa" +checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11" dependencies = [ "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.7.1", + "miniz_oxide", +] + +[[package]] +name = "postcard" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfa512cd0d087cc9f99ad30a1bf64795b67871edbead083ffc3a4dfafa59aa00" +dependencies = [ + "cobs", + "serde", ] [[package]] @@ -684,9 +854,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" dependencies = [ "unicode-ident", ] @@ -702,9 +872,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -742,13 +912,13 @@ checksum = "3b42e27ef78c35d3998403c1d26f3efd9e135d3e5121b0a4845cc5cc27547f4f" [[package]] name = "regex" -version = "1.8.1" +version = "1.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.1", + "regex-syntax 0.7.2", ] [[package]] @@ -759,9 +929,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "resvg" @@ -808,20 +978,11 @@ dependencies = [ "xmlparser", ] -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" [[package]] name = "rustybuzz" @@ -841,9 +1002,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" [[package]] name = "same-file" @@ -854,17 +1015,11 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "semver" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" - [[package]] name = "serde" -version = "1.0.160" +version = "1.0.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "d01b7404f9d441d3ad40e6a636a7782c377d2abdbe4fa2440e2edcc2f4f10db8" dependencies = [ "serde_derive", ] @@ -882,20 +1037,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "5dd83d6dde2b6b2d466e14d9d1acce8816dedee94f735eac6395808b3483c6d6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.23", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" dependencies = [ "itoa", "ryu", @@ -904,9 +1059,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ "serde", ] @@ -917,7 +1072,7 @@ version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" dependencies = [ - "indexmap", + "indexmap 1.9.3", "ryu", "serde", "yaml-rust", @@ -1017,11 +1172,11 @@ checksum = "09eab8a83bff89ba2200bd4c59be45c7c787f988431b936099a5a266c957f2f9" [[package]] name = "svg2pdf" -version = "0.4.1" -source = "git+https://github.com/typst/svg2pdf#35f4bb87fb677473661c6d12919e01a6d64a716d" +version = "0.5.0" +source = "git+https://github.com/typst/svg2pdf#39daf9fc2ee84b62b0e3b174ff8c9017f655af6b" dependencies = [ "image", - "miniz_oxide 0.7.1", + "miniz_oxide", "pdf-writer", "usvg", ] @@ -1049,15 +1204,27 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-xid", +] + [[package]] name = "syntect" version = "5.0.0" @@ -1096,7 +1263,34 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.23", +] + +[[package]] +name = "time" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" +dependencies = [ + "itoa", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + +[[package]] +name = "time-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +dependencies = [ + "time-core", ] [[package]] @@ -1132,6 +1326,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ac3f5b6856e931e15e07b478e98c8045239829a65f9156d4fa7e7788197a5ef" dependencies = [ "displaydoc", + "serde", + "zerovec", ] [[package]] @@ -1151,9 +1347,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml" -version = "0.7.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" +checksum = "1ebafdf5ad1220cb59e7d17cf4d2c72015297b75b19a10472f99b89225089240" dependencies = [ "serde", "serde_spanned", @@ -1163,20 +1359,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.8" +version = "0.19.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +checksum = "266f016b7f039eec8a1a80dfe6156b633d208b9fccca5e4db1d6775b0c4e34a7" dependencies = [ - "indexmap", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -1185,10 +1381,11 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.38" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9cf6a813d3f40c88b0b6b6f29a5c95c6cdbf97c1f9cc53fb820200f5ad814d" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ + "cfg-if", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1196,20 +1393,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.23", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", ] @@ -1228,10 +1425,10 @@ checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" [[package]] name = "typst" -version = "0.4.0" -source = "git+https://github.com/typst/typst.git?tag=v0.4.0#f692a5efc62bf95f57d123895b7dce55d2eb9741" +version = "0.6.0" +source = "git+https://github.com/typst/typst.git?tag=v0.6.0#2dfd44fedd99ab9414c17f358179e1c37e953f30" dependencies = [ - "bitflags 2.2.1", + "bitflags 2.3.3", "bytemuck", "comemo", "ecow", @@ -1239,9 +1436,9 @@ dependencies = [ "fontdb", "if_chain", "image", - "indexmap", + "indexmap 1.9.3", "log", - "miniz_oxide 0.7.1", + "miniz_oxide", "once_cell", "pdf-writer", "pixglyph", @@ -1254,7 +1451,9 @@ dependencies = [ "stacker", "subsetter", "svg2pdf", + "time", "tiny-skia", + "toml", "tracing", "ttf-parser", "typst-macros", @@ -1269,8 +1468,8 @@ dependencies = [ [[package]] name = "typst-library" -version = "0.4.0" -source = "git+https://github.com/typst/typst.git?tag=v0.4.0#f692a5efc62bf95f57d123895b7dce55d2eb9741" +version = "0.6.0" +source = "git+https://github.com/typst/typst.git?tag=v0.6.0#2dfd44fedd99ab9414c17f358179e1c37e953f30" dependencies = [ "az", "chinese-number", @@ -1279,6 +1478,11 @@ dependencies = [ "ecow", "hayagriva", "hypher", + "icu_properties", + "icu_provider", + "icu_provider_adapters", + "icu_provider_blob", + "icu_segmenter", "kurbo", "lipsum", "log", @@ -1289,6 +1493,7 @@ dependencies = [ "serde_yaml", "smallvec", "syntect", + "time", "toml", "tracing", "ttf-parser", @@ -1298,18 +1503,17 @@ dependencies = [ "unicode-math-class", "unicode-script", "unicode-segmentation", - "xi-unicode", ] [[package]] name = "typst-macros" -version = "0.4.0" -source = "git+https://github.com/typst/typst.git?tag=v0.4.0#f692a5efc62bf95f57d123895b7dce55d2eb9741" +version = "0.6.0" +source = "git+https://github.com/typst/typst.git?tag=v0.6.0#2dfd44fedd99ab9414c17f358179e1c37e953f30" dependencies = [ "heck", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.23", ] [[package]] @@ -1356,9 +1560,9 @@ checksum = "2281c8c1d221438e373249e065ca4989c4c36952c211ff21a0ee91c44a3869e7" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "unicode-math-class" @@ -1393,6 +1597,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "unscanny" version = "0.1.0" @@ -1401,9 +1611,9 @@ checksum = "e9df2af067a7953e9c3831320f35c1cc0600c30d44d9f7a12b01db1cd88d6b47" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -1470,6 +1680,12 @@ dependencies = [ "svgtypes", ] +[[package]] +name = "utf8_iter" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a8922555b9500e3d865caed19330172cd67cbf82203f1a3311d8c305cc9f33" + [[package]] name = "version_check" version = "0.9.4" @@ -1488,9 +1704,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1498,24 +1714,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.23", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.36" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ "cfg-if", "js-sys", @@ -1525,9 +1741,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1535,28 +1751,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.23", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "web-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -1601,18 +1817,18 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winnow" -version = "0.4.1" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" dependencies = [ "memchr", ] [[package]] -name = "xi-unicode" -version = "0.3.0" +name = "writeable" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a67300977d3dc3f8034dae89778f502b6ba20b269527b3223ba59c0cf393bb8a" +checksum = "60e49e42bdb1d5dc76f4cd78102f8f0714d32edfa3efb82286eb0f0b1fc0da0f" [[package]] name = "xmlparser" @@ -1640,3 +1856,72 @@ checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ "linked-hash-map", ] + +[[package]] +name = "yoke" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848075a23a28f9773498ee9a0f2cf58fcbad4f8c0ccf84a210ab33c6ae495de" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af46c169923ed7516eef0aa32b56d2651b229f57458ebe46b49ddd6efef5b7a2" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df54d76c3251de27615dfcce21e636c172dafb2549cd7fd93e21c66f6ca6bea2" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eae7c1f7d4b8eafce526bc0771449ddc2f250881ae31c50d22c032b5a1c499" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "198f54134cd865f437820aa3b43d0ad518af4e68ee161b444cdd15d8e567c8ea" +dependencies = [ + "serde", + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "486558732d5dde10d0f8cb2936507c1bb21bc539d924c949baf5f36a58e51bac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] diff --git a/Cargo.toml b/Cargo.toml index e693305..c944fd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,23 +1,21 @@ [package] name = "obsidian-typst" -version = "0.4.2" +version = "0.5.0" authors = ["fenjalien"] edition = "2021" description = "Renders `typst` code blocks to images with Typst." readme = "README.md" +rust-version = "1.70" [lib] crate-type = ["cdylib"] [dependencies] # Everything to do with Typst -typst = { git = "https://github.com/typst/typst.git", tag = "v0.4.0" } -typst-library = { git = "https://github.com/typst/typst.git", tag = "v0.4.0" } +typst = { git = "https://github.com/typst/typst.git", tag = "v0.6.0" } +typst-library = { git = "https://github.com/typst/typst.git", tag = "v0.6.0" } comemo = "0.3" - -once_cell = "1.17.1" siphasher = "0.3.10" -elsa = "1.8.0" # Everything to do with wasm @@ -26,14 +24,14 @@ js-sys = "^0.3" wasm-bindgen-futures = "^0.4" serde = { version = "^1.0", features = ["derive"] } serde-wasm-bindgen = "^0.5" -web-sys = { version = "^0.3", features = ["console", "Window", "FontData", "Blob", "ImageData"] } +web-sys = { version = "^0.3", features = [ + "console", + "Window", + "FontData", + "Blob", + "ImageData", +] } +console_error_panic_hook = "0.1.7" - -# [patch.crates-io] -# web-sys = { git = "https://github.com/fenjalien/wasm-bindgen.git" } -# js-sys = { git = "https://github.com/fenjalien/wasm-bindgen.git" } -# wasm-bindgen-futures = { git = "https://github.com/fenjalien/wasm-bindgen.git" } -# wasm-bindgen = { git = "https://github.com/fenjalien/wasm-bindgen.git" } - -# [profile.release] -# debug = true +# Image handling +fast_image_resize = "2.7.3" diff --git a/README.md b/README.md index fd5724b..3d5ad4d 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,20 @@ Renders `typst` code blocks, and optionally math blocks, into images using [Typst](https://github.com/typst/typst) through the power of WASM! This is still very much in development, so suggestions and bugs are welcome! -## Things to NOTE +## Small Things to NOTE +- This plugin uses Typst 0.6.0 - Typst does not currently support exporting to HTML only PDFs and PNGs. So due to image scaling, the rendered views may look a bit terrible. If you know how to fix this PLEASE HELP. - File paths should be relative to the vault folder. - System fonts are not loaded by default as this takes about 20 seconds (on my machine). There is an option in settings to enable them (requires a reload of the plugin). +- You can not import on mobile as file reading is NOT supported on mobile, this is due to `SharedArrayBuffer`s not being available on mobile but is available for some reason on desktop. + +## Using Packages +The plugin supports only the reading of packages from the [`@preview`](https://github.com/typst/packages#downloads) and [`@local`](https://github.com/typst/packages#local-packages) namespaces. Please use the Typst cli to download your desired packages. This means the plugin accesses files outside of your vault but only to read them, it does not modify or create files outside of your vault. ## Math Block Usage -The plugin can render `typst` inside math blocks! By default this is off, to enable it set the "Override Math Blocks" setting or use the "Toggle Math Block Override" command. Math block types are conserved between Obsidian and Typst, `$...$` -> `$...$` and `$$...$$` -> `$ ... $`. +The plugin can render `typst` inside math blocks! By default this is off, to enable it set the "Override Math Blocks" setting or use the "Toggle math block override" command. Math block types are conserved between Obsidian and Typst, `$...$` -> `$...$` and `$$...$$` -> `$ ... $`. -From what I've experimented with, normal math blocks are okay with `typst` code but Typst is not happy with any Latex code. +From what I've experimented with, normal math blocks are okay with Typst but Typst is not happy with any Latex code. For styling and using imports with math blocks see the next section. @@ -23,10 +28,8 @@ Preamables are prepended to your `typst` code before compiling. There are three - `code`: Prepended to `typst` code only in code blocks. ## Known Issues -### "File Not Found" Error on First Load of Obsidian -When Obsidian first loads it sometimes tries to render before its files are resolved and cached. - -To fix, simply select then deselect everything in the file, or close and re-open the file. +### Runtime Error Unreachable or Recursive Use Of Object +These occur when the Typst compiler panics for any reason and means the compiler cannot be used again until it is restarted. There should be more information in the console log so please create an issue with this error! ## Example @@ -61,14 +64,20 @@ The first #count numbers of the sequence are: ## Installation -Until this plugin is submitted to the community plugins please install it by copying `main.js`, `styles.css`, and `manifest.json` from the releases tab to the folder `.obsidian/plugins/obsidian-typst` in your vault. +Install "Typst Renderer" from the community plugins tab in settings + +or + +Install it by copying `main.js`, `styles.css`, and `manifest.json` from the releases tab to the folder `.obsidian/plugins/obsidian-typst` in your vault. ## TODO / Goals (In no particular order) - [x] Better font loading - [x] Fix importing - [x] Fix Github Actions - [ ] Better error handling -- [ ] Fix output image scaling +- [x]? Fix output image scaling - [ ] Use HTML output - [x] Override default equation rendering - [ ] Custom editor for `.typ` files +- [ ] Mobile file reading +- [ ] Automate package downloading diff --git a/compiler.worker.ts b/compiler.worker.ts new file mode 100644 index 0000000..6ecba39 --- /dev/null +++ b/compiler.worker.ts @@ -0,0 +1,68 @@ +//@ts-ignore +import wasmBin from './pkg/obsidian_typst_bg.wasm' +import * as typst from './pkg' + +import { CompileCommand, WorkerRequest } from "types"; + +typst.initSync(wasmBin); + +let canUseSharedArrayBuffer = new Boolean(false); + +// let buffer: Int32Array; +let decoder = new TextDecoder() + +function requestData(path: string): string { + if (!canUseSharedArrayBuffer) { + throw "Cannot read files on mobile" + } + // @ts-expect-error + let buffer = new Int32Array(new SharedArrayBuffer(4, { maxByteLength: 1e8 })) + buffer[0] = 0; + postMessage({ buffer, path }) + const res = Atomics.wait(buffer, 0, 0); + if (buffer[0] == 0) { + return decoder.decode(Uint8Array.from(buffer.slice(1))) + } + + throw buffer[0] +} + +let compiler = new typst.SystemWorld("", requestData) +const compileAttempts = 5; + +// function compile(data: CompileCommand) { +// for (let i = 1; i <= compileAttempts; i += 1) { +// try { +// return compiler.compile(data.source, data.path, data.pixel_per_pt, data.fill, data.size, data.display) +// } catch (error) { +// if (i < compileAttempts && ((error.name == "RuntimeError" && error.message == "unreachable") || (error.name == "Uncaught Error"))) { +// console.warn("Typst compiler crashed, attempting to restart: ", i); +// console.log(data); + +// compiler.free() +// compiler = new typst.SystemWorld("", requestData) +// } else { +// console.log("name", error.name); +// console.log("message", error.message); + +// throw error; +// } +// } +// } +// } + + +onmessage = (ev: MessageEvent) => { + if (ev.data == true) { + canUseSharedArrayBuffer = ev.data + } else if ("source" in ev.data) { + const data: CompileCommand = ev.data; + postMessage(compiler.compile(data.source, data.path, data.pixel_per_pt, data.fill, data.size, data.display)) + + // postMessage(compile(ev.data)) + } else { + throw ev; + } +} + +console.log("Typst compiler worker loaded!"); diff --git a/esbuild.config.mjs b/esbuild.config.mjs index e148203..98bb03a 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -2,6 +2,8 @@ import esbuild from "esbuild"; import process from "process"; import builtins from "builtin-modules"; +import inlineWorkerPlugin from "esbuild-plugin-inline-worker"; + const banner = `/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD @@ -69,13 +71,16 @@ const context = await esbuild.context({ treeShaking: true, outfile: "main.js", plugins: [ - wasmPlugin + inlineWorkerPlugin({ format: "cjs", target: "es2018", plugins: [wasmPlugin] }) ] }) -if (prod) { - await context.rebuild(); - process.exit(0); -} else { - await context.watch(); -} \ No newline at end of file +await context.rebuild(); +process.exit(0) + +// if (prod) { +// await context.rebuild(); +// process.exit(0); +// } else { +// await context.watch(); +// } \ No newline at end of file diff --git a/main.ts b/main.ts index 3c27048..7a3892d 100644 --- a/main.ts +++ b/main.ts @@ -1,11 +1,10 @@ -import { App, HexString, Notice, Plugin, PluginSettingTab, Setting, Workspace, loadMathJax } from 'obsidian'; +import { App, renderMath, HexString, Platform, Plugin, PluginSettingTab, Setting, loadMathJax, normalizePath } from 'obsidian'; // @ts-ignore -import typst_wasm_bin from './pkg/obsidian_typst_bg.wasm' -import typstInit, * as typst from './pkg/obsidian_typst' -import TypstCanvasElement from 'typst-canvas-element'; +import Worker from "./compiler.worker.ts" -// temp.track() +import TypstCanvasElement from 'typst-canvas-element'; +import { WorkerRequest } from 'types.js'; interface TypstPluginSettings { noFill: boolean, @@ -27,85 +26,218 @@ const DEFAULT_SETTINGS: TypstPluginSettings = { search_system: false, override_math: false, preamable: { - shared: "#let pxToPt = (p) => if p == auto {p} else {p * DPR * (72/96) * 1pt}\n#set text(fill: white, size: pxToPt(SIZE))", - math: "#set page(width: pxToPt(WIDTH), height: pxToPt(HEIGHT), margin: 0pt)\n#set align(horizon)", - code: "#set page(width: auto, height: auto, margin: 1em)" + shared: "#set text(fill: white, size: SIZE)\n#set page(width: WIDTH, height: HEIGHT)", + math: "#set page(margin: 0pt)\n#set align(horizon)", + code: "#set page(margin: (y: 1em, x: 0pt))" } } export default class TypstPlugin extends Plugin { settings: TypstPluginSettings; - compiler: typst.SystemWorld; - files: Map; + + compilerWorker: Worker; + tex2chtml: any; - resizeObserver: ResizeObserver; + + prevCanvasHeight: number = 0; + textEncoder: TextEncoder + fs: any; async onload() { - await typstInit(typst_wasm_bin) + this.compilerWorker = new Worker(); + if (!Platform.isMobileApp) { + this.compilerWorker.postMessage(true); + this.fs = require("fs") + } + + this.textEncoder = new TextEncoder() await this.loadSettings() - let notice = new Notice("Loading fonts for Typst..."); - this.compiler = await new typst.SystemWorld("", (path: string) => this.get_file(path), this.settings.search_system); - notice.hide(); - notice = new Notice("Finished loading fonts for Typst", 5000); - this.registerEvent( - this.app.metadataCache.on("resolved", () => this.updateFileCache()) - ) - - TypstCanvasElement.compile = (a, b, c, d) => this.typstToSizedImage(a, b, c, d) - customElements.define("typst-canvas", TypstCanvasElement, { extends: "canvas" }) + TypstCanvasElement.compile = (a, b, c, d, e) => this.processThenCompileTypst(a, b, c, d, e) + if (customElements.get("typst-renderer") == undefined) { + customElements.define("typst-renderer", TypstCanvasElement, { extends: "canvas" }) + } await loadMathJax() + renderMath("", false); // @ts-expect-error this.tex2chtml = MathJax.tex2chtml this.overrideMathJax(this.settings.override_math) this.addCommand({ - id: "math-override", - name: "Toggle Math Block Override", + id: "toggle-math-override", + name: "Toggle math block override", callback: () => this.overrideMathJax(!this.settings.override_math) }) - this.addCommand({ - id: "update-files", - name: "Update Cached .typ Files", - callback: () => this.updateFileCache() - }) + this.addSettingTab(new TypstSettingTab(this.app, this)); - this.registerMarkdownCodeBlockProcessor("typst", (source, el, ctx) => { - el.appendChild(this.typstToCanvas(`${this.settings.preamable.code}\n${source}`, true)) + this.registerMarkdownCodeBlockProcessor("typst", async (source, el, ctx) => { + el.appendChild(this.createTypstCanvas("/" + ctx.sourcePath, `${this.settings.preamable.code}\n${source}`, true, false)) }) - console.log("loaded Typst"); + + console.log("loaded Typst Renderer"); } - typstToImage(source: string) { - return this.compiler.compile(source, this.settings.pixel_per_pt, `${this.settings.fill}${this.settings.noFill ? "00" : "ff"}`) + // async loadCompilerWorker() { + // this.compilerWorker. + // } + + async compileToTypst(path: string, source: string, size: number, display: boolean): Promise { + return await navigator.locks.request("typst renderer compiler", async (lock) => { + this.compilerWorker.postMessage({ + source, + path, + pixel_per_pt: this.settings.pixel_per_pt, + fill: `${this.settings.fill}${this.settings.noFill ? "00" : "ff"}`, + size, + display + }); + while (true) { + let result: ImageData | WorkerRequest = await new Promise((resolve, reject) => { + const listener = (ev: MessageEvent) => { + remove(); + resolve(ev.data); + } + const errorListener = (error: ErrorEvent) => { + remove(); + reject(error.message) + } + const remove = () => { + this.compilerWorker.removeEventListener("message", listener); + this.compilerWorker.removeEventListener("error", errorListener); + } + this.compilerWorker.addEventListener("message", listener); + this.compilerWorker.addEventListener("error", errorListener); + }) + + if (result instanceof ImageData) { + return result + } + // Cannot reach this point when in mobile app as the worker should + // not have a SharedArrayBuffer + await this.handleWorkerRequest(result) + } + }) } - typstToSizedImage(source: string, size: number, display: boolean, fontSize: number) { - const sizing = `#let (WIDTH, HEIGHT, SIZE, DPR) = (${display ? size : "auto"}, ${!display ? size : "auto"}, ${fontSize}, ${window.devicePixelRatio})` - return this.typstToImage( - `${sizing}\n${this.settings.preamable.shared}\n${source}` + async handleWorkerRequest({ buffer: wbuffer, path }: WorkerRequest) { + try { + let s = await ( + path.startsWith("@") + ? this.preparePackage(path) + : this.getFileString(path) + ); + if (s) { + + + let buffer = Int32Array.from(this.textEncoder.encode( + s + )); + if (wbuffer.byteLength < (buffer.byteLength + 4)) { + //@ts-expect-error + wbuffer.buffer.grow(buffer.byteLength + 4) + } + wbuffer.set(buffer, 1) + wbuffer[0] = 0 + } else { + wbuffer[0] = -2 + } + } catch (error) { + wbuffer[0] = -1 + throw error + } finally { + Atomics.notify(wbuffer, 0) + } + } + + async getFileString(path: string): Promise { + if (require("path").isAbsolute(path)) { + return await this.fs.promises.readFile(path, { encoding: "utf8" }) + } else { + return await this.app.vault.adapter.read(normalizePath(path)) + } + } + + async preparePackage(spec: string): Promise { + spec = spec.slice(1) + let subdir = "/typst/packages/" + spec + + let dir = normalizePath(this.getDataDir() + subdir) + if (this.fs.existsSync(dir)) { + return dir + } + + dir = normalizePath(this.getCacheDir() + subdir) + + if (this.fs.existsSync(dir)) { + return dir + } + } + + getDataDir() { + if (Platform.isLinux) { + if ("XDG_DATA_HOME" in process.env) { + return process.env["XDG_DATA_HOME"] + } else { + return process.env["HOME"] + "/.local/share" + } + } else if (Platform.isWin) { + return process.env["APPDATA"] + } else if (Platform.isMacOS) { + return process.env["HOME"] + "/Library/Application Support" + } + throw "Cannot find data directory on an unknown platform" + } + + getCacheDir() { + if (Platform.isLinux) { + if ("XDG_CACHE_HOME" in process.env) { + return process.env["XDG_DATA_HOME"] + } else { + return process.env["HOME"] + "/.cache" + } + } else if (Platform.isWin) { + return process.env["LOCALAPPDATA"] + } else if (Platform.isMacOS) { + return process.env["HOME"] + "/Library/Caches" + } + throw "Cannot find cache directory on an unknown platform" + } + + async processThenCompileTypst(path: string, source: string, size: number, display: boolean, fontSize: number) { + const dpr = window.devicePixelRatio; + const pxToPt = (px: number) => (px * dpr * (72 / 96)).toString() + "pt" + const sizing = `#let (WIDTH, HEIGHT, SIZE) = (${display ? pxToPt(size) : "auto"}, ${!display ? pxToPt(size) : "auto"}, ${pxToPt(fontSize)})` + return this.compileToTypst( + path, + `${sizing}\n${this.settings.preamable.shared}\n${source}`, + size, + display ) } - typstToCanvas(source: string, display: boolean) { + createTypstCanvas(path: string, source: string, display: boolean, math: boolean) { let canvas = new TypstCanvasElement(); canvas.source = source + canvas.path = path canvas.display = display + canvas.math = math return canvas } - typstMath2Html(source: string, r: { display: boolean }) { + createTypstMath(source: string, r: { display: boolean }) { const display = r.display; source = `${this.settings.preamable.math}\n${display ? `$ ${source} $` : `$${source}$`}` - return this.typstToCanvas(source, display) + + return this.createTypstCanvas("/586f8912-f3a8-4455-8a4a-3729469c2cc1.typ", source, display, true) } onunload() { - //@ts-expect-error + // @ts-expect-error MathJax.tex2chtml = this.tex2chtml + this.compilerWorker.terminate() } async overrideMathJax(value: boolean) { @@ -113,7 +245,7 @@ export default class TypstPlugin extends Plugin { await this.saveSettings(); if (this.settings.override_math) { // @ts-expect-error - MathJax.tex2chtml = (e, r) => this.typstMath2Html(e, r) + MathJax.tex2chtml = (e, r) => this.createTypstMath(e, r) } else { // @ts-expect-error MathJax.tex2chtml = this.tex2chtml @@ -127,23 +259,6 @@ export default class TypstPlugin extends Plugin { async saveSettings() { await this.saveData(this.settings); } - - get_file(path: string) { - if (this.files.has(path)) { - return this.files.get(path) - } - console.error(`'${path}' is a folder or does not exist`, this.files.keys()); - throw `'${path}' is a folder or does not exist` - } - - async updateFileCache() { - this.files = new Map() - for (const file of this.app.vault.getFiles()) { - if (file.extension == "typ") { - this.files.set(file.path, await this.app.vault.cachedRead(file)) - } - } - } } class TypstSettingTab extends PluginSettingTab { @@ -159,18 +274,7 @@ class TypstSettingTab extends PluginSettingTab { containerEl.empty(); - let fill_color = new Setting(containerEl) - .setName("Fill Color") - .setDisabled(this.plugin.settings.noFill) - .addColorPicker((picker) => { - picker.setValue(this.plugin.settings.fill) - .onChange( - async (value) => { - this.plugin.settings.fill = value; - await this.plugin.saveSettings(); - } - ) - }) + new Setting(containerEl) .setName("No Fill (Transparent)") .addToggle((toggle) => { @@ -183,6 +287,20 @@ class TypstSettingTab extends PluginSettingTab { } ) }); + + let fill_color = new Setting(containerEl) + .setName("Fill Color") + .setDisabled(this.plugin.settings.noFill) + .addColorPicker((picker) => { + picker.setValue(this.plugin.settings.fill) + .onChange( + async (value) => { + this.plugin.settings.fill = value; + await this.plugin.saveSettings(); + } + ) + }) + new Setting(containerEl) .setName("Pixel Per Point") .addSlider((slider) => @@ -193,7 +311,10 @@ class TypstSettingTab extends PluginSettingTab { this.plugin.settings.pixel_per_pt = value; await this.plugin.saveSettings(); } - )) + ) + .setDynamicTooltip() + ) + new Setting(containerEl) .setName("Search System Fonts") .setDesc(`Whether the plugin should search for system fonts. diff --git a/manifest.json b/manifest.json index a862104..786e4df 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "typst", "name": "Typst Renderer", - "version": "0.4.2", + "version": "0.5.0", "minAppVersion": "1.0.0", "description": "Renders `typst` code blocks and math blocks to images with Typst.", "author": "fenjalien", diff --git a/package-lock.json b/package-lock.json index 00bf202..e3aebaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,38 +1,42 @@ { "name": "obsidian-typst-plugin", - "version": "0.3.0", + "version": "0.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-typst-plugin", - "version": "0.3.0", + "version": "0.5.0", "license": "Apache-2.0", "dependencies": { - "@codemirror/language": "^6.6.0", - "@codemirror/state": "^6.2.0", - "@codemirror/view": "^6.10.0", - "@lezer/common": "^1.0.2", + "obsidian": "latest", "obsidian-typst": "file:pkg", - "temp": "^0.9.4" + "tslib": "^2" }, "devDependencies": { - "@types/node": "^16.11.6", - "@types/temp": "^0.9.1", - "@typescript-eslint/eslint-plugin": "5.29.0", - "@typescript-eslint/parser": "5.29.0", - "builtin-modules": "3.3.0", - "esbuild": "0.17.3", - "esbuild-plugin-wasm": "^1.0.0", - "obsidian": "latest", - "tslib": "2.4.0", - "typescript": "4.7.4" + "@types/node": "^20", + "@typescript-eslint/eslint-plugin": "^5", + "@typescript-eslint/parser": "^5", + "builtin-modules": "^3", + "esbuild": "^0.18", + "esbuild-plugin-inline-worker": "^0.1.1", + "typescript": "^5.1" + } + }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "peer": true, + "engines": { + "node": ">=0.10.0" } }, "node_modules/@codemirror/language": { - "version": "6.6.0", - "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.6.0.tgz", - "integrity": "sha512-cwUd6lzt3MfNYOobdjf14ZkLbJcnv4WtndYaoBkbor/vF+rCNguMPK0IRtvZJG4dsWiaWPcK8x1VijhvSxnstg==", + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.8.0.tgz", + "integrity": "sha512-r1paAyWOZkfY0RaYEZj3Kul+MiQTEbDvYqf8gPGaRvNneHXCmfSaAVFjwRUPlgxS8yflMxw2CTu6uCMp8R8A2g==", "dependencies": { "@codemirror/state": "^6.0.0", "@codemirror/view": "^6.0.0", @@ -43,14 +47,14 @@ } }, "node_modules/@codemirror/state": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.2.0.tgz", - "integrity": "sha512-69QXtcrsc3RYtOtd+GsvczJ319udtBf1PTrr2KbLWM/e2CXUPnh0Nz9AUo8WfhSQ7GeL8dPVNUmhQVgpmuaNGA==" + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.2.1.tgz", + "integrity": "sha512-RupHSZ8+OjNT38zU9fKH2sv+Dnlr8Eb8sl4NOnnqz95mCFTZUaiRP8Xv5MeeaG0px2b8Bnfe7YGwCV3nsBhbuw==" }, "node_modules/@codemirror/view": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.10.0.tgz", - "integrity": "sha512-Oea3rvE4JQLMmLsy2b54yxXQJgJM9xKpUQIpF/LGgKUTH2lA06GAmEtKKWn5OUnbW3jrH1hHeUd8DJEgePMOeQ==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.14.0.tgz", + "integrity": "sha512-I263FPs4In42MNmrdwN2DfmYPFMVMXgT7o/mxdGp4jv5LPs8i0FOxzmxF5yeeQdYSTztb2ZhmPIu0ahveInVTg==", "dependencies": { "@codemirror/state": "^6.1.4", "style-mod": "^4.0.0", @@ -58,9 +62,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.3.tgz", - "integrity": "sha512-1Mlz934GvbgdDmt26rTLmf03cAgLg5HyOgJN+ZGCeP3Q9ynYTNMn2/LQxIl7Uy+o4K6Rfi2OuLsr12JQQR8gNg==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.11.tgz", + "integrity": "sha512-q4qlUf5ucwbUJZXF5tEQ8LF7y0Nk4P58hOsGk3ucY0oCwgQqAnqXVbUuahCddVHfrxmpyewRpiTHwVHIETYu7Q==", "cpu": [ "arm" ], @@ -74,9 +78,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.3.tgz", - "integrity": "sha512-XvJsYo3dO3Pi4kpalkyMvfQsjxPWHYjoX4MDiB/FUM4YMfWcXa5l4VCwFWVYI1+92yxqjuqrhNg0CZg3gSouyQ==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.18.11.tgz", + "integrity": "sha512-snieiq75Z1z5LJX9cduSAjUr7vEI1OdlzFPMw0HH5YI7qQHDd3qs+WZoMrWYDsfRJSq36lIA6mfZBkvL46KoIw==", "cpu": [ "arm64" ], @@ -90,9 +94,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.3.tgz", - "integrity": "sha512-nuV2CmLS07Gqh5/GrZLuqkU9Bm6H6vcCspM+zjp9TdQlxJtIe+qqEXQChmfc7nWdyr/yz3h45Utk1tUn8Cz5+A==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.18.11.tgz", + "integrity": "sha512-iPuoxQEV34+hTF6FT7om+Qwziv1U519lEOvekXO9zaMMlT9+XneAhKL32DW3H7okrCOBQ44BMihE8dclbZtTuw==", "cpu": [ "x64" ], @@ -106,9 +110,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.3.tgz", - "integrity": "sha512-01Hxaaat6m0Xp9AXGM8mjFtqqwDjzlMP0eQq9zll9U85ttVALGCGDuEvra5Feu/NbP5AEP1MaopPwzsTcUq1cw==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.11.tgz", + "integrity": "sha512-Gm0QkI3k402OpfMKyQEEMG0RuW2LQsSmI6OeO4El2ojJMoF5NLYb3qMIjvbG/lbMeLOGiW6ooU8xqc+S0fgz2w==", "cpu": [ "arm64" ], @@ -122,9 +126,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.3.tgz", - "integrity": "sha512-Eo2gq0Q/er2muf8Z83X21UFoB7EU6/m3GNKvrhACJkjVThd0uA+8RfKpfNhuMCl1bKRfBzKOk6xaYKQZ4lZqvA==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.18.11.tgz", + "integrity": "sha512-N15Vzy0YNHu6cfyDOjiyfJlRJCB/ngKOAvoBf1qybG3eOq0SL2Lutzz9N7DYUbb7Q23XtHPn6lMDF6uWbGv9Fw==", "cpu": [ "x64" ], @@ -138,9 +142,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.3.tgz", - "integrity": "sha512-CN62ESxaquP61n1ZjQP/jZte8CE09M6kNn3baos2SeUfdVBkWN5n6vGp2iKyb/bm/x4JQzEvJgRHLGd5F5b81w==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.11.tgz", + "integrity": "sha512-atEyuq6a3omEY5qAh5jIORWk8MzFnCpSTUruBgeyN9jZq1K/QI9uke0ATi3MHu4L8c59CnIi4+1jDKMuqmR71A==", "cpu": [ "arm64" ], @@ -154,9 +158,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.3.tgz", - "integrity": "sha512-feq+K8TxIznZE+zhdVurF3WNJ/Sa35dQNYbaqM/wsCbWdzXr5lyq+AaTUSER2cUR+SXPnd/EY75EPRjf4s1SLg==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.18.11.tgz", + "integrity": "sha512-XtuPrEfBj/YYYnAAB7KcorzzpGTvOr/dTtXPGesRfmflqhA4LMF0Gh/n5+a9JBzPuJ+CGk17CA++Hmr1F/gI0Q==", "cpu": [ "x64" ], @@ -170,9 +174,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.3.tgz", - "integrity": "sha512-CLP3EgyNuPcg2cshbwkqYy5bbAgK+VhyfMU7oIYyn+x4Y67xb5C5ylxsNUjRmr8BX+MW3YhVNm6Lq6FKtRTWHQ==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.18.11.tgz", + "integrity": "sha512-Idipz+Taso/toi2ETugShXjQ3S59b6m62KmLHkJlSq/cBejixmIydqrtM2XTvNCywFl3VC7SreSf6NV0i6sRyg==", "cpu": [ "arm" ], @@ -186,9 +190,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.3.tgz", - "integrity": "sha512-JHeZXD4auLYBnrKn6JYJ0o5nWJI9PhChA/Nt0G4MvLaMrvXuWnY93R3a7PiXeJQphpL1nYsaMcoV2QtuvRnF/g==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.18.11.tgz", + "integrity": "sha512-c6Vh2WS9VFKxKZ2TvJdA7gdy0n6eSy+yunBvv4aqNCEhSWVor1TU43wNRp2YLO9Vng2G+W94aRz+ILDSwAiYog==", "cpu": [ "arm64" ], @@ -202,9 +206,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.3.tgz", - "integrity": "sha512-FyXlD2ZjZqTFh0sOQxFDiWG1uQUEOLbEh9gKN/7pFxck5Vw0qjWSDqbn6C10GAa1rXJpwsntHcmLqydY9ST9ZA==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.18.11.tgz", + "integrity": "sha512-S3hkIF6KUqRh9n1Q0dSyYcWmcVa9Cg+mSoZEfFuzoYXXsk6196qndrM+ZiHNwpZKi3XOXpShZZ+9dfN5ykqjjw==", "cpu": [ "ia32" ], @@ -218,9 +222,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.3.tgz", - "integrity": "sha512-OrDGMvDBI2g7s04J8dh8/I7eSO+/E7nMDT2Z5IruBfUO/RiigF1OF6xoH33Dn4W/OwAWSUf1s2nXamb28ZklTA==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.18.11.tgz", + "integrity": "sha512-MRESANOoObQINBA+RMZW+Z0TJWpibtE7cPFnahzyQHDCA9X9LOmGh68MVimZlM9J8n5Ia8lU773te6O3ILW8kw==", "cpu": [ "loong64" ], @@ -234,9 +238,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.3.tgz", - "integrity": "sha512-DcnUpXnVCJvmv0TzuLwKBC2nsQHle8EIiAJiJ+PipEVC16wHXaPEKP0EqN8WnBe0TPvMITOUlP2aiL5YMld+CQ==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.18.11.tgz", + "integrity": "sha512-qVyPIZrXNMOLYegtD1u8EBccCrBVshxMrn5MkuFc3mEVsw7CCQHaqZ4jm9hbn4gWY95XFnb7i4SsT3eflxZsUg==", "cpu": [ "mips64el" ], @@ -250,9 +254,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.3.tgz", - "integrity": "sha512-BDYf/l1WVhWE+FHAW3FzZPtVlk9QsrwsxGzABmN4g8bTjmhazsId3h127pliDRRu5674k1Y2RWejbpN46N9ZhQ==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.18.11.tgz", + "integrity": "sha512-T3yd8vJXfPirZaUOoA9D2ZjxZX4Gr3QuC3GztBJA6PklLotc/7sXTOuuRkhE9W/5JvJP/K9b99ayPNAD+R+4qQ==", "cpu": [ "ppc64" ], @@ -266,9 +270,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.3.tgz", - "integrity": "sha512-WViAxWYMRIi+prTJTyV1wnqd2mS2cPqJlN85oscVhXdb/ZTFJdrpaqm/uDsZPGKHtbg5TuRX/ymKdOSk41YZow==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.18.11.tgz", + "integrity": "sha512-evUoRPWiwuFk++snjH9e2cAjF5VVSTj+Dnf+rkO/Q20tRqv+644279TZlPK8nUGunjPAtQRCj1jQkDAvL6rm2w==", "cpu": [ "riscv64" ], @@ -282,9 +286,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.3.tgz", - "integrity": "sha512-Iw8lkNHUC4oGP1O/KhumcVy77u2s6+KUjieUqzEU3XuWJqZ+AY7uVMrrCbAiwWTkpQHkr00BuXH5RpC6Sb/7Ug==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.18.11.tgz", + "integrity": "sha512-/SlRJ15XR6i93gRWquRxYCfhTeC5PdqEapKoLbX63PLCmAkXZHY2uQm2l9bN0oPHBsOw2IswRZctMYS0MijFcg==", "cpu": [ "s390x" ], @@ -298,9 +302,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.3.tgz", - "integrity": "sha512-0AGkWQMzeoeAtXQRNB3s4J1/T2XbigM2/Mn2yU1tQSmQRmHIZdkGbVq2A3aDdNslPyhb9/lH0S5GMTZ4xsjBqg==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.18.11.tgz", + "integrity": "sha512-xcncej+wF16WEmIwPtCHi0qmx1FweBqgsRtEL1mSHLFR6/mb3GEZfLQnx+pUDfRDEM4DQF8dpXIW7eDOZl1IbA==", "cpu": [ "x64" ], @@ -314,9 +318,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.3.tgz", - "integrity": "sha512-4+rR/WHOxIVh53UIQIICryjdoKdHsFZFD4zLSonJ9RRw7bhKzVyXbnRPsWSfwybYqw9sB7ots/SYyufL1mBpEg==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.18.11.tgz", + "integrity": "sha512-aSjMHj/F7BuS1CptSXNg6S3M4F3bLp5wfFPIJM+Km2NfIVfFKhdmfHF9frhiCLIGVzDziggqWll0B+9AUbud/Q==", "cpu": [ "x64" ], @@ -330,9 +334,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.3.tgz", - "integrity": "sha512-cVpWnkx9IYg99EjGxa5Gc0XmqumtAwK3aoz7O4Dii2vko+qXbkHoujWA68cqXjhh6TsLaQelfDO4MVnyr+ODeA==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.18.11.tgz", + "integrity": "sha512-tNBq+6XIBZtht0xJGv7IBB5XaSyvYPCm1PxJ33zLQONdZoLVM0bgGqUrXnJyiEguD9LU4AHiu+GCXy/Hm9LsdQ==", "cpu": [ "x64" ], @@ -346,9 +350,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.3.tgz", - "integrity": "sha512-RxmhKLbTCDAY2xOfrww6ieIZkZF+KBqG7S2Ako2SljKXRFi+0863PspK74QQ7JpmWwncChY25JTJSbVBYGQk2Q==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.18.11.tgz", + "integrity": "sha512-kxfbDOrH4dHuAAOhr7D7EqaYf+W45LsAOOhAet99EyuxxQmjbk8M9N4ezHcEiCYPaiW8Dj3K26Z2V17Gt6p3ng==", "cpu": [ "x64" ], @@ -362,9 +366,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.3.tgz", - "integrity": "sha512-0r36VeEJ4efwmofxVJRXDjVRP2jTmv877zc+i+Pc7MNsIr38NfsjkQj23AfF7l0WbB+RQ7VUb+LDiqC/KY/M/A==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.18.11.tgz", + "integrity": "sha512-Sh0dDRyk1Xi348idbal7lZyfSkjhJsdFeuC13zqdipsvMetlGiFQNdO+Yfp6f6B4FbyQm7qsk16yaZk25LChzg==", "cpu": [ "arm64" ], @@ -378,9 +382,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.3.tgz", - "integrity": "sha512-wgO6rc7uGStH22nur4aLFcq7Wh86bE9cOFmfTr/yxN3BXvDEdCSXyKkO+U5JIt53eTOgC47v9k/C1bITWL/Teg==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.18.11.tgz", + "integrity": "sha512-o9JUIKF1j0rqJTFbIoF4bXj6rvrTZYOrfRcGyL0Vm5uJ/j5CkBD/51tpdxe9lXEDouhRgdr/BYzUrDOvrWwJpg==", "cpu": [ "ia32" ], @@ -394,9 +398,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.3.tgz", - "integrity": "sha512-FdVl64OIuiKjgXBjwZaJLKp0eaEckifbhn10dXWhysMJkWblg3OEEGKSIyhiD5RSgAya8WzP3DNkngtIg3Nt7g==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.18.11.tgz", + "integrity": "sha512-rQI4cjLHd2hGsM1LqgDI7oOCYbQ6IBOVsX9ejuRMSze0GqXUG2ekwiKkiBU1pRGSeCqFFHxTrcEydB2Hyoz9CA==", "cpu": [ "x64" ], @@ -414,7 +418,6 @@ "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", "dev": true, - "peer": true, "dependencies": { "eslint-visitor-keys": "^3.3.0" }, @@ -426,25 +429,24 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.4.1.tgz", - "integrity": "sha512-BISJ6ZE4xQsuL/FmsyRaiffpq977bMlsKfGHTQrOGFErfByxIe6iZTxPf/00Zon9b9a7iUykfQwejN3s2ZW/Bw==", + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz", + "integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==", "dev": true, - "peer": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, "node_modules/@eslint/eslintrc": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.1.tgz", - "integrity": "sha512-eFRmABvW2E5Ho6f5fHLqgena46rOj7r7OKHYfLElqcBfGFHHpjBhivyi5+jOEQuSpdc/1phIZJlbC2te+tZNIw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.0.tgz", + "integrity": "sha512-Lj7DECXqIVCqnqjjHMPna4vn6GJcMgul/wuS0je9OZ9gsL0zzDpKPVtcG1HaDVc+9y+qgXneTeUMbCqXJNpH1A==", "dev": true, "peer": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.5.0", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -460,9 +462,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.36.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.36.0.tgz", - "integrity": "sha512-lxJ9R5ygVm8ZWgYdUweoq5ownDlJ4upvoWmO4eLxBYHdMo+vZ/Rx0EN6MbKWDJOSUGrqJy2Gt+Dyv/VKml0fjg==", + "version": "8.44.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.44.0.tgz", + "integrity": "sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw==", "dev": true, "peer": true, "engines": { @@ -470,9 +472,9 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", "dev": true, "peer": true, "dependencies": { @@ -506,22 +508,22 @@ "peer": true }, "node_modules/@lezer/common": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.2.tgz", - "integrity": "sha512-SVgiGtMnMnW3ActR8SXgsDhw7a0w0ChHSYAyAUxxrOiJ1OqYWEKk/xJd84tTSPo1mo6DXLObAJALNnd0Hrv7Ng==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.3.tgz", + "integrity": "sha512-JH4wAXCgUOcCGNekQPLhVeUtIqjH0yPBs7vvUdSjyQama9618IOKFJwkv2kcqdhF0my8hQEgCTEJU0GIgnahvA==" }, "node_modules/@lezer/highlight": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.1.4.tgz", - "integrity": "sha512-IECkFmw2l7sFcYXrV8iT9GeY4W0fU4CxX0WMwhmhMIVjoDdD1Hr6q3G2NqVtLg/yVe5n7i4menG3tJ2r4eCrPQ==", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.1.6.tgz", + "integrity": "sha512-cmSJYa2us+r3SePpRCjN5ymCqCPv+zyXmDl0ciWtVaNiORT/MxM7ZgOMQZADD0o51qOaOg24qc/zBViOIwAjJg==", "dependencies": { "@lezer/common": "^1.0.0" } }, "node_modules/@lezer/lr": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.3.4.tgz", - "integrity": "sha512-7o+e4og/QoC/6btozDPJqnzBhUaD1fMfmvnEKQO1wRRiTse1WxaJ3OMEXZJnkgT6HCcTVOctSoXK9jGJw2oe9g==", + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.3.9.tgz", + "integrity": "sha512-XPz6dzuTHlnsbA5M2DZgjflNQ+9Hi5Swhic0RULdp3oOs3rh6bqGZolosVqN/fQIT8uNiepzINJDnS39oweTHQ==", "dependencies": { "@lezer/common": "^1.0.0" } @@ -565,60 +567,55 @@ "version": "0.0.108", "resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-0.0.108.tgz", "integrity": "sha512-3FGFcus0P7C2UOGCNUVENqObEb4SFk+S8Dnxq7K6aIsLVs/vDtlangl3PEO0ykaKXyK56swVF6Nho7VsA44uhw==", - "dev": true, "dependencies": { "@types/tern": "*" } }, "node_modules/@types/estree": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz", - "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==", - "dev": true + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz", + "integrity": "sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==" }, "node_modules/@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "dev": true }, "node_modules/@types/node": { - "version": "16.18.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.19.tgz", - "integrity": "sha512-Qd2EhjbjOKZuHMn+IJc2EUYwdkJw9kgsZ3k2zdyi2uIBH0hU00Yd9T5rpMq6KRiFvpscpXUQRjJSaJHH29ei8A==", + "version": "20.4.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.0.tgz", + "integrity": "sha512-jfT7iTf/4kOQ9S7CHV9BIyRaQqHu67mOjsIQBC3BKZvzvUB6zLxEwJ6sBE3ozcvP8kF6Uk5PXN0Q+c0dfhGX0g==", "dev": true }, - "node_modules/@types/temp": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@types/temp/-/temp-0.9.1.tgz", - "integrity": "sha512-yDQ8Y+oQi9V7VkexwE6NBSVyNuyNFeGI275yWXASc2DjmxNicMi9O50KxDpNlST1kBbV9jKYBHGXhgNYFMPqtA==", - "dev": true, - "dependencies": { - "@types/node": "*" - } + "node_modules/@types/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", + "dev": true }, "node_modules/@types/tern": { "version": "0.23.4", "resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.4.tgz", "integrity": "sha512-JAUw1iXGO1qaWwEOzxTKJZ/5JxVeON9kvGZ/osgZaJImBnyjyn0cjovPsf6FNLmyGY8Vw9DoXZCMlfMkMwHRWg==", - "dev": true, "dependencies": { "@types/estree": "*" } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.29.0.tgz", - "integrity": "sha512-kgTsISt9pM53yRFQmLZ4npj99yGl3x3Pl7z4eA66OuTzAGC4bQB5H5fuLwPnqTKU3yyrrg4MIhjF17UYnL4c0w==", + "version": "5.61.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.61.0.tgz", + "integrity": "sha512-A5l/eUAug103qtkwccSCxn8ZRwT+7RXWkFECdA4Cvl1dOlDUgTpAOfSEElZn2uSUxhdDpnCdetrf0jvU4qrL+g==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.29.0", - "@typescript-eslint/type-utils": "5.29.0", - "@typescript-eslint/utils": "5.29.0", + "@eslint-community/regexpp": "^4.4.0", + "@typescript-eslint/scope-manager": "5.61.0", + "@typescript-eslint/type-utils": "5.61.0", + "@typescript-eslint/utils": "5.61.0", "debug": "^4.3.4", - "functional-red-black-tree": "^1.0.1", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "regexpp": "^3.2.0", + "natural-compare-lite": "^1.4.0", "semver": "^7.3.7", "tsutils": "^3.21.0" }, @@ -640,14 +637,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.29.0.tgz", - "integrity": "sha512-ruKWTv+x0OOxbzIw9nW5oWlUopvP/IQDjB5ZqmTglLIoDTctLlAJpAQFpNPJP/ZI7hTT9sARBosEfaKbcFuECw==", + "version": "5.61.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.61.0.tgz", + "integrity": "sha512-yGr4Sgyh8uO6fSi9hw3jAFXNBHbCtKKFMdX2IkT3ZqpKmtAq3lHS4ixB/COFuAIJpwl9/AqF7j72ZDWYKmIfvg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.29.0", - "@typescript-eslint/types": "5.29.0", - "@typescript-eslint/typescript-estree": "5.29.0", + "@typescript-eslint/scope-manager": "5.61.0", + "@typescript-eslint/types": "5.61.0", + "@typescript-eslint/typescript-estree": "5.61.0", "debug": "^4.3.4" }, "engines": { @@ -667,13 +664,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.29.0.tgz", - "integrity": "sha512-etbXUT0FygFi2ihcxDZjz21LtC+Eps9V2xVx09zFoN44RRHPrkMflidGMI+2dUs821zR1tDS6Oc9IXxIjOUZwA==", + "version": "5.61.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.61.0.tgz", + "integrity": "sha512-W8VoMjoSg7f7nqAROEmTt6LoBpn81AegP7uKhhW5KzYlehs8VV0ZW0fIDVbcZRcaP3aPSW+JZFua+ysQN+m/Nw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.29.0", - "@typescript-eslint/visitor-keys": "5.29.0" + "@typescript-eslint/types": "5.61.0", + "@typescript-eslint/visitor-keys": "5.61.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -684,12 +681,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.29.0.tgz", - "integrity": "sha512-JK6bAaaiJozbox3K220VRfCzLa9n0ib/J+FHIwnaV3Enw/TO267qe0pM1b1QrrEuy6xun374XEAsRlA86JJnyg==", + "version": "5.61.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.61.0.tgz", + "integrity": "sha512-kk8u//r+oVK2Aj3ph/26XdH0pbAkC2RiSjUYhKD+PExemG4XSjpGFeyZ/QM8lBOa7O8aGOU+/yEbMJgQv/DnCg==", "dev": true, "dependencies": { - "@typescript-eslint/utils": "5.29.0", + "@typescript-eslint/typescript-estree": "5.61.0", + "@typescript-eslint/utils": "5.61.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -710,9 +708,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.29.0.tgz", - "integrity": "sha512-X99VbqvAXOMdVyfFmksMy3u8p8yoRGITgU1joBJPzeYa0rhdf5ok9S56/itRoUSh99fiDoMtarSIJXo7H/SnOg==", + "version": "5.61.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.61.0.tgz", + "integrity": "sha512-ldyueo58KjngXpzloHUog/h9REmHl59G1b3a5Sng1GfBo14BkS3ZbMEb3693gnP1k//97lh7bKsp6/V/0v1veQ==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -723,13 +721,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.29.0.tgz", - "integrity": "sha512-mQvSUJ/JjGBdvo+1LwC+GY2XmSYjK1nAaVw2emp/E61wEVYEyibRHCqm1I1vEKbXCpUKuW4G7u9ZCaZhJbLoNQ==", + "version": "5.61.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.61.0.tgz", + "integrity": "sha512-Fud90PxONnnLZ36oR5ClJBLTLfU4pIWBmnvGwTbEa2cXIqj70AEDEmOmpkFComjBZ/037ueKrOdHuYmSFVD7Rw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.29.0", - "@typescript-eslint/visitor-keys": "5.29.0", + "@typescript-eslint/types": "5.61.0", + "@typescript-eslint/visitor-keys": "5.61.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -750,17 +748,19 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.29.0.tgz", - "integrity": "sha512-3Eos6uP1nyLOBayc/VUdKZikV90HahXE5Dx9L5YlSd/7ylQPXhLk1BYb29SDgnBnTp+jmSZUU0QxUiyHgW4p7A==", + "version": "5.61.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.61.0.tgz", + "integrity": "sha512-mV6O+6VgQmVE6+xzlA91xifndPW9ElFW8vbSF0xCT/czPXVhwDewKila1jOyRwa9AE19zKnrr7Cg5S3pJVrTWQ==", "dev": true, "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.29.0", - "@typescript-eslint/types": "5.29.0", - "@typescript-eslint/typescript-estree": "5.29.0", + "@types/semver": "^7.3.12", + "@typescript-eslint/scope-manager": "5.61.0", + "@typescript-eslint/types": "5.61.0", + "@typescript-eslint/typescript-estree": "5.61.0", "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0" + "semver": "^7.3.7" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -774,12 +774,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.29.0.tgz", - "integrity": "sha512-Hpb/mCWsjILvikMQoZIE3voc9wtQcS0A9FUw3h8bhr9UxBdtI/tw1ZDZUOXHXLOVMedKCH5NxyzATwnU78bWCQ==", + "version": "5.61.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.61.0.tgz", + "integrity": "sha512-50XQ5VdbWrX06mQXhy93WywSFZZGsv3EOjq+lqp6WC2t+j3mb6A9xYVdrRxafvK88vg9k9u+CT4l6D8PEatjKg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.29.0", + "@typescript-eslint/types": "5.61.0", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -791,9 +791,9 @@ } }, "node_modules/acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "dev": true, "peer": true, "bin": { @@ -957,6 +957,12 @@ "dev": true, "peer": true }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1027,9 +1033,9 @@ } }, "node_modules/esbuild": { - "version": "0.17.3", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.3.tgz", - "integrity": "sha512-9n3AsBRe6sIyOc6kmoXg2ypCLgf3eZSraWFRpnkto+svt8cZNuKTkb1bhQcitBcvIqjNiK7K0J3KPmwGSfkA8g==", + "version": "0.18.11", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.11.tgz", + "integrity": "sha512-i8u6mQF0JKJUlGR3OdFLKldJQMMs8OqM9Cc3UCi9XXziJ9WERM5bfkHaEAy0YAvPRMgqSW55W7xYn84XtEFTtA==", "dev": true, "hasInstallScript": true, "bin": { @@ -1039,41 +1045,38 @@ "node": ">=12" }, "optionalDependencies": { - "@esbuild/android-arm": "0.17.3", - "@esbuild/android-arm64": "0.17.3", - "@esbuild/android-x64": "0.17.3", - "@esbuild/darwin-arm64": "0.17.3", - "@esbuild/darwin-x64": "0.17.3", - "@esbuild/freebsd-arm64": "0.17.3", - "@esbuild/freebsd-x64": "0.17.3", - "@esbuild/linux-arm": "0.17.3", - "@esbuild/linux-arm64": "0.17.3", - "@esbuild/linux-ia32": "0.17.3", - "@esbuild/linux-loong64": "0.17.3", - "@esbuild/linux-mips64el": "0.17.3", - "@esbuild/linux-ppc64": "0.17.3", - "@esbuild/linux-riscv64": "0.17.3", - "@esbuild/linux-s390x": "0.17.3", - "@esbuild/linux-x64": "0.17.3", - "@esbuild/netbsd-x64": "0.17.3", - "@esbuild/openbsd-x64": "0.17.3", - "@esbuild/sunos-x64": "0.17.3", - "@esbuild/win32-arm64": "0.17.3", - "@esbuild/win32-ia32": "0.17.3", - "@esbuild/win32-x64": "0.17.3" + "@esbuild/android-arm": "0.18.11", + "@esbuild/android-arm64": "0.18.11", + "@esbuild/android-x64": "0.18.11", + "@esbuild/darwin-arm64": "0.18.11", + "@esbuild/darwin-x64": "0.18.11", + "@esbuild/freebsd-arm64": "0.18.11", + "@esbuild/freebsd-x64": "0.18.11", + "@esbuild/linux-arm": "0.18.11", + "@esbuild/linux-arm64": "0.18.11", + "@esbuild/linux-ia32": "0.18.11", + "@esbuild/linux-loong64": "0.18.11", + "@esbuild/linux-mips64el": "0.18.11", + "@esbuild/linux-ppc64": "0.18.11", + "@esbuild/linux-riscv64": "0.18.11", + "@esbuild/linux-s390x": "0.18.11", + "@esbuild/linux-x64": "0.18.11", + "@esbuild/netbsd-x64": "0.18.11", + "@esbuild/openbsd-x64": "0.18.11", + "@esbuild/sunos-x64": "0.18.11", + "@esbuild/win32-arm64": "0.18.11", + "@esbuild/win32-ia32": "0.18.11", + "@esbuild/win32-x64": "0.18.11" } }, - "node_modules/esbuild-plugin-wasm": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esbuild-plugin-wasm/-/esbuild-plugin-wasm-1.0.0.tgz", - "integrity": "sha512-iXIf3hwfqorExG66/eNr3U8JakIZuge70nMNQtinvxbzdljQ/RjvwaBiGPqF/DvuIumUApbe3zj2kqHLVyc7uQ==", + "node_modules/esbuild-plugin-inline-worker": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/esbuild-plugin-inline-worker/-/esbuild-plugin-inline-worker-0.1.1.tgz", + "integrity": "sha512-VmFqsQKxUlbM51C1y5bRiMeyc1x2yTdMXhKB6S//++g9aCBg8TfGsbKxl5ZDkCGquqLY+RmEk93TBNd0i35dPA==", "dev": true, - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "type": "individual", - "url": "https://ko-fi.com/tschrock" + "dependencies": { + "esbuild": "latest", + "find-cache-dir": "^3.3.1" } }, "node_modules/escape-string-regexp": { @@ -1090,17 +1093,17 @@ } }, "node_modules/eslint": { - "version": "8.36.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.36.0.tgz", - "integrity": "sha512-Y956lmS7vDqomxlaaQAHVmeb4tNMp2FWIvU/RnU5BD3IKMD/MJPr76xdyr68P8tV1iNMvN2mRK0yy3c+UjL+bw==", + "version": "8.44.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.44.0.tgz", + "integrity": "sha512-0wpHoUbDUHgNCyvFB5aXLiQVfK9B0at6gUvzy83k4kAsQ/u769TQDX6iKC+aO4upIHO9WSaA3QoXYQDHbNwf1A==", "dev": true, "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.0.1", - "@eslint/js": "8.36.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint/eslintrc": "^2.1.0", + "@eslint/js": "8.44.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", @@ -1109,9 +1112,9 @@ "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.5.0", + "eslint-scope": "^7.2.0", + "eslint-visitor-keys": "^3.4.1", + "espree": "^9.6.0", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -1119,20 +1122,19 @@ "find-up": "^5.0.0", "glob-parent": "^6.0.2", "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", + "graphemer": "^1.4.0", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" @@ -1160,46 +1162,22 @@ "node": ">=8.0.0" } }, - "node_modules/eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^2.0.0" - }, - "engines": { - "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=5" - } - }, - "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true, - "engines": { - "node": ">=10" - } - }, "node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.0.tgz", + "integrity": "sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==", "dev": true, "peer": true, "dependencies": { @@ -1208,6 +1186,9 @@ }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/estraverse": { @@ -1221,15 +1202,15 @@ } }, "node_modules/espree": { - "version": "9.5.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.0.tgz", - "integrity": "sha512-JPbJGhKc47++oo4JkEoTe2wjy4fmMwvFpgJT9cQzmfXKp22Dr6Hf1tdCteLz1h0P3t+mGvWZ+4Uankvh8+c6zw==", + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.0.tgz", + "integrity": "sha512-1FH/IiruXZ84tpUlm0aCUEwMl2Ho5ilqVh0VvQXw+byAz/4SAciyHLlfmL5WYqsvD38oymdUwBss0LtK8m4s/A==", "dev": true, "peer": true, "dependencies": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1309,9 +1290,9 @@ "peer": true }, "node_modules/fast-glob": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", - "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.0.tgz", + "integrity": "sha512-ChDuvbOypPuNjO8yIDf36x7BlZX1smcUMTTcyoIjycexOxd6DFsKsg21qVBzEmr3G7fUKIRy2/psii+CIUt7FA==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -1384,6 +1365,23 @@ "node": ">=8" } }, + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "dev": true, + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -1427,12 +1425,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, - "node_modules/functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", - "dev": true - }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -1501,12 +1493,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", - "dev": true, - "peer": true + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true }, "node_modules/has-flag": { "version": "4.0.0", @@ -1615,17 +1606,6 @@ "dev": true, "peer": true }, - "node_modules/js-sdsl": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", - "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", - "dev": true, - "peer": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/js-sdsl" - } - }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -1702,6 +1682,30 @@ "node": ">=10" } }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -1758,7 +1762,6 @@ "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", - "dev": true, "engines": { "node": "*" } @@ -1776,11 +1779,16 @@ "dev": true, "peer": true }, + "node_modules/natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "node_modules/obsidian": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.1.1.tgz", - "integrity": "sha512-GcxhsHNkPEkwHEjeyitfYNBcQuYGeAHFs1pEpZIv0CnzSfui8p8bPLm2YKLgcg20B764770B1sYGtxCvk9ptxg==", - "dev": true, + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.2.8.tgz", + "integrity": "sha512-HrC+feA8o0tXspj4lEAqxb1btwLwHD2oHXSwbbN+CdRHURqbCkuIDLld+nkuyJ1w1c9uvVDRVk8BoeOnWheOrQ==", "dependencies": { "@types/codemirror": "0.0.108", "moment": "2.29.4" @@ -1803,18 +1811,18 @@ } }, "node_modules/optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", "dev": true, "peer": true, "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "type-check": "^0.4.0" }, "engines": { "node": ">= 0.8.0" @@ -1852,6 +1860,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -1870,7 +1887,6 @@ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, - "peer": true, "engines": { "node": ">=8" } @@ -1914,6 +1930,70 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -1954,18 +2034,6 @@ } ] }, - "node_modules/regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -2026,9 +2094,9 @@ } }, "node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.3.tgz", + "integrity": "sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -2099,9 +2167,9 @@ } }, "node_modules/style-mod": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.0.2.tgz", - "integrity": "sha512-C4myMmRTO8iaC5Gg+N1ftK2WT4eXUTMAa+HEFPPrfVeO/NtqLTtAmV1HbqnuGtLwCek44Ra76fdGUkSqjiMPcQ==" + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.0.3.tgz", + "integrity": "sha512-78Jv8kYJdjbvRwwijtCevYADfsI0lGzYJe4mMFdceO8l75DFFDoqBhR1jVDicDRRaX4//g1u9wKeo+ztc2h1Rw==" }, "node_modules/supports-color": { "version": "7.2.0", @@ -2159,10 +2227,9 @@ } }, "node_modules/tslib": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", - "dev": true + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz", + "integrity": "sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA==" }, "node_modules/tsutils": { "version": "3.21.0", @@ -2212,16 +2279,16 @@ } }, "node_modules/typescript": { - "version": "4.7.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", - "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/uri-js": { @@ -2235,9 +2302,9 @@ } }, "node_modules/w3c-keyname": { - "version": "2.2.6", - "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.6.tgz", - "integrity": "sha512-f+fciywl1SJEniZHD6H+kUO8gOnwIr7f4ijKA6+ZvJFjeGi1r4PDLl53Ayud9O/rk64RqgoQine0feoeOU0kXg==" + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==" }, "node_modules/which": { "version": "2.0.2", @@ -2255,16 +2322,6 @@ "node": ">= 8" } }, - "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index b677b7c..66c943b 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "obsidian-typst-plugin", - "version": "0.4.2", + "version": "0.5.0", "description": "Renders `typst` code blocks to images with Typst.", "main": "main.js", "scripts": { "wasm": "wasm-pack build --target web", - "dev": "wasm-pack build --target web --dev && node esbuild.config.mjs", + "dev": "node esbuild.config.mjs", + "wasm-dev": "wasm-pack build --target web --dev && node esbuild.config.mjs", "wasm-build": "wasm-pack build --target web && tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", "version": "node version-bump.mjs && git add manifest.json versions.json" @@ -14,23 +15,17 @@ "author": "fenjalien", "license": "Apache-2.0", "devDependencies": { - "@types/node": "^16.11.6", - "@types/temp": "^0.9.1", - "@typescript-eslint/eslint-plugin": "5.29.0", - "@typescript-eslint/parser": "5.29.0", - "builtin-modules": "3.3.0", - "esbuild": "0.17.3", - "esbuild-plugin-wasm": "^1.0.0", - "obsidian": "latest", - "tslib": "2.4.0", - "typescript": "4.7.4" + "@types/node": "^20", + "@typescript-eslint/eslint-plugin": "^5", + "@typescript-eslint/parser": "^5", + "builtin-modules": "^3", + "esbuild": "^0.18", + "esbuild-plugin-inline-worker": "^0.1.1", + "typescript": "^5.1" }, "dependencies": { - "@codemirror/language": "^6.6.0", - "@codemirror/state": "^6.2.0", - "@codemirror/view": "^6.10.0", - "@lezer/common": "^1.0.2", + "obsidian": "latest", "obsidian-typst": "file:pkg", - "temp": "^0.9.4" + "tslib": "^2" } } diff --git a/src/fonts.rs b/src/fonts.rs new file mode 100644 index 0000000..3875074 --- /dev/null +++ b/src/fonts.rs @@ -0,0 +1,49 @@ +use typst::{ + font::{Font, FontBook}, + util::Bytes, +}; + +/// Searches for fonts. +pub struct FontSearcher { + /// Metadata about all discovered fonts. + pub book: FontBook, + /// Slots that the fonts are loaded into. + pub fonts: Vec, +} + +impl FontSearcher { + pub fn new() -> Self { + Self { + book: FontBook::new(), + fonts: Vec::new(), + } + } + + pub fn add_embedded(&mut self) { + let mut process = |bytes: &'static [u8]| { + let buffer = Bytes::from_static(bytes); + for font in Font::iter(buffer) { + self.book.push(font.info().clone()); + self.fonts.push(font); + } + }; + + macro_rules! add { + ($filename:literal) => { + process(include_bytes!(concat!("../assets/fonts/", $filename))); + }; + } + + // Embed default fonts. + add!("LinLibertine_R.ttf"); + add!("LinLibertine_RB.ttf"); + add!("LinLibertine_RBI.ttf"); + add!("LinLibertine_RI.ttf"); + add!("NewCMMath-Book.otf"); + add!("NewCMMath-Regular.otf"); + add!("DejaVuSansMono.ttf"); + add!("DejaVuSansMono-Bold.ttf"); + add!("DejaVuSansMono-Oblique.ttf"); + add!("DejaVuSansMono-BoldOblique.ttf"); + } +} diff --git a/src/lib.rs b/src/lib.rs index ba3b316..6113963 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,299 +1,279 @@ use comemo::Prehashed; -use elsa::FrozenVec; -use once_cell::unsync::OnceCell; -use siphasher::sip128::{Hasher128, SipHasher}; +use fast_image_resize as fr; use std::{ - cell::{RefCell, RefMut}, + cell::{OnceCell, RefCell, RefMut}, collections::HashMap, - hash::Hash, + num::NonZeroU32, path::{Path, PathBuf}, str::FromStr, }; use typst::{ - diag::{FileError, FileResult}, - eval::Library, - font::{Font, FontBook, FontInfo}, + diag::{EcoString, FileError, FileResult, PackageError, PackageResult}, + eval::{Datetime, Library}, + file::{FileId, PackageSpec}, + font::{Font, FontBook}, geom::{Color, RgbaColor}, - syntax::{Source, SourceId}, - util::{Buffer, PathExt}, + syntax::Source, + util::{Bytes, PathExt}, World, }; use wasm_bindgen::{prelude::*, Clamped}; -use wasm_bindgen_futures::JsFuture; -use web_sys::{console, Blob, FontData, ImageData}; +use web_sys::ImageData; -#[wasm_bindgen] -extern "C" { - fn alert(s: &str); -} +mod fonts; +mod paths; -#[wasm_bindgen(module = "fs")] -extern "C" { - #[wasm_bindgen(catch)] - fn readFileSync(path: &str) -> Result; -} +use crate::fonts::FontSearcher; +use crate::paths::{PathHash, PathSlot}; /// A world that provides access to the operating system. #[wasm_bindgen] pub struct SystemWorld { + /// The root relative to which absolute paths are resolved. root: PathBuf, + /// The input source. + main: FileId, + /// Typst's standard library. library: Prehashed, + /// Metadata about discovered fonts. book: Prehashed, - fonts: Vec, - hashes: RefCell>, + /// Storage of fonts + fonts: Vec, + /// Maps package-path combinations to canonical hashes. All package-path + /// combinations that point to thes same file are mapped to the same hash. To + /// be used in conjunction with `paths`. + hashes: RefCell>>, + /// Maps canonical path hashes to source files and buffers. paths: RefCell>, - sources: FrozenVec>, - main: SourceId, - js_read_file: js_sys::Function, + /// The current date if requested. This is stored here to ensure it is + /// always the same within one compilation. Reset between compilations. + today: OnceCell>, + + packages: RefCell>>, + + resizer: fr::Resizer, + + js_request_data: js_sys::Function, } #[wasm_bindgen] impl SystemWorld { #[wasm_bindgen(constructor)] - pub async fn new( - root: String, - js_read_file: &js_sys::Function, - search_system: bool, - ) -> Result { + pub fn new(root: String, js_read_file: &js_sys::Function) -> SystemWorld { + console_error_panic_hook::set_once(); let mut searcher = FontSearcher::new(); - if search_system { - searcher.search_system().await?; - } else { - searcher.add_embedded(); - } + searcher.add_embedded(); - Ok(Self { + Self { root: PathBuf::from(root), + main: FileId::detached(), library: Prehashed::new(typst_library::build()), book: Prehashed::new(searcher.book), fonts: searcher.fonts, hashes: RefCell::default(), paths: RefCell::default(), - sources: FrozenVec::new(), - main: SourceId::detached(), - js_read_file: js_read_file.clone(), - }) + today: OnceCell::new(), + packages: RefCell::default(), + resizer: fr::Resizer::default(), + js_request_data: js_read_file.clone(), + } + } + + fn reset(&mut self) { + self.hashes.borrow_mut().clear(); + self.paths.borrow_mut().clear(); + self.today.take(); } pub fn compile( &mut self, - source: String, + text: String, + path: String, pixel_per_pt: f32, fill: String, + size: u32, + display: bool, ) -> Result { - self.sources.as_mut().clear(); - self.hashes.borrow_mut().clear(); - self.paths.borrow_mut().clear(); + self.reset(); + + // Insert the main path slot + let system_path = PathBuf::from(path); + let hash = PathHash::new(&text); + self.main = FileId::new(None, &system_path); + self.hashes.borrow_mut().insert(self.main, Ok(hash)); + self.paths.borrow_mut().insert( + hash, + PathSlot { + id: self.main, + system_path, + buffer: OnceCell::new(), + source: Ok(Source::new(self.main, text)), + }, + ); - self.main = self.insert("".as_ref(), source); match typst::compile(self) { Ok(document) => { - let render = typst::export::render( + let mut pixmap = typst::export::render( &document.pages[0], pixel_per_pt, Color::Rgba(RgbaColor::from_str(&fill)?), ); - Ok(ImageData::new_with_u8_clamped_array_and_sh( - Clamped(render.data()), - render.width(), - render.height(), - )?) + + let width = pixmap.width(); + let height = pixmap.height(); + // Create src image + let mut src_image = fr::Image::from_slice_u8( + NonZeroU32::new(width).unwrap(), + NonZeroU32::new(height).unwrap(), + pixmap.data_mut(), + fr::PixelType::U8x4, + ) + .unwrap(); + + // Multiple RGB channels of source image by alpha channel + let alpha_mul_div = fr::MulDiv::default(); + alpha_mul_div + .multiply_alpha_inplace(&mut src_image.view_mut()) + .unwrap(); + + let dst_width = NonZeroU32::new(if display { + size + } else { + ((size as f32 / height as f32) * width as f32) as u32 + }) + .unwrap_or(NonZeroU32::MIN); + let dst_height = NonZeroU32::new(if display { + ((size as f32 / width as f32) * height as f32) as u32 + } else { + size + }) + .unwrap_or(NonZeroU32::MIN); + + // Create container for data of destination image + let mut dst_image = fr::Image::new(dst_width, dst_height, src_image.pixel_type()); + // Get mutable view of destination image data + let mut dst_view = dst_image.view_mut(); + + // Resize source image into buffer of destination image + self.resizer + .resize(&src_image.view(), &mut dst_view) + .unwrap(); + + alpha_mul_div.divide_alpha_inplace(&mut dst_view).unwrap(); + + ImageData::new_with_u8_clamped_array_and_sh( + Clamped(dst_image.buffer()), + dst_width.get(), + dst_height.get(), + ) } - Err(errors) => Err(format!("{:?}", *errors).into()), + Err(errors) => Err(format!( + "{:?}", + errors + .into_iter() + .map(|e| e.message) + .collect::>() + ) + .into()), } } } impl World for SystemWorld { - fn root(&self) -> &Path { - &self.root - } - fn library(&self) -> &Prehashed { &self.library } - fn main(&self) -> &Source { - self.source(self.main) - } - - fn resolve(&self, path: &Path) -> FileResult { - let path = self.root.join(path); - let path = path.as_path(); - self.slot(path)? - .source - .get_or_init(|| { - let buf = self.read_file(path)?; - let text = String::from_utf8(buf)?; - Ok(self.insert(path, text)) - }) - .clone() - } - - fn source(&self, id: SourceId) -> &Source { - &self.sources[id.into_u16() as usize] - } - fn book(&self) -> &Prehashed { &self.book } - fn font(&self, id: usize) -> Option { - let slot = &self.fonts[id]; - slot.font - .get_or_init(|| Font::new(slot.buffer.clone(), slot.index)) - .clone() + fn main(&self) -> Source { + self.source(self.main).unwrap() } - fn file(&self, path: &Path) -> FileResult { - let path = self.root.join(path); - let path = path.as_path(); - self.slot(path)? - .buffer - .get_or_init(|| self.read_file(path).map(Buffer::from)) - .clone() + fn source(&self, id: FileId) -> FileResult { + self.slot(id)?.source() + } + + fn file(&self, id: FileId) -> FileResult { + self.slot(id)?.file() + } + + fn font(&self, index: usize) -> Option { + Some(self.fonts[index].clone()) + } + + fn today(&self, _: Option) -> Option { + None } } impl SystemWorld { - fn slot(&self, path: &Path) -> FileResult> { - let mut hashes = self.hashes.borrow_mut(); - let hash = match hashes.get(path).cloned() { - Some(hash) => hash, - None => { - let hash = PathHash::new(Buffer::from(self.read_file(path)?)); - if let Ok(canon) = path.canonicalize() { - hashes.insert(canon.normalize(), hash); - } - hashes.insert(path.into(), hash); - hash - } - }; + fn read_file(&self, path: &Path) -> FileResult { + let f = |_e: JsValue| FileError::Other; + Ok(self + .js_request_data + .call1(&JsValue::NULL, &path.to_str().unwrap().into()) + .map_err(f)? + .as_string() + .unwrap()) + } - Ok(std::cell::RefMut::map(self.paths.borrow_mut(), |paths| { - paths.entry(hash).or_default() + fn prepare_package(&self, spec: &PackageSpec) -> PackageResult { + let f = |e: JsValue| { + if let Some(num) = e.as_f64() { + if num == -2.0 { + return PackageError::NotFound(spec.clone()); + } + } + PackageError::Other + }; + self.packages + .borrow_mut() + .entry(spec.clone()) + .or_insert_with(|| { + Ok(self + .js_request_data + .call1( + &JsValue::NULL, + &format!("@{}/{}-{}", spec.namespace, spec.name, spec.version).into(), + ) + .map_err(f)? + .as_string() + .unwrap() + .into()) + }) + .clone() + } + + fn slot(&self, id: FileId) -> FileResult> { + let mut system_path = PathBuf::new(); + let mut text = String::new(); + let hash = self + .hashes + .borrow_mut() + .entry(id) + .or_insert_with(|| { + let root = match id.package() { + Some(spec) => self.prepare_package(spec)?, + None => self.root.clone(), + }; + + system_path = root.join_rooted(id.path()).ok_or(FileError::AccessDenied)?; + text = self.read_file(&system_path)?; + + Ok(PathHash::new(&text)) + }) + .clone()?; + + Ok(RefMut::map(self.paths.borrow_mut(), |paths| { + paths.entry(hash).or_insert_with(|| PathSlot { + id, + source: Ok(Source::new(id, text)), + buffer: OnceCell::new(), + system_path, + }) })) } - - fn insert(&self, path: &Path, text: String) -> SourceId { - let id = SourceId::from_u16(self.sources.len() as u16); - let source = Source::new(id, path, text); - self.sources.push(Box::new(source)); - id - } - - fn read_file(&self, path: &Path) -> FileResult> { - let f1 = |e: JsValue| { - console::error_1(&e); - FileError::Other - }; - Ok(self - .js_read_file - .call1(&JsValue::NULL, &path.to_str().unwrap().into()) - .map_err(f1)? - .as_string() - .unwrap() - .into_bytes()) - } -} - -/// Holds details about the location of a font and lazily the font itself. -struct FontSlot { - buffer: Buffer, - index: u32, - font: OnceCell>, -} - -/// A hash that is the same for all paths pointing to the same entity. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -struct PathHash(u128); - -impl PathHash { - fn new(handle: Buffer) -> Self { - // let handle = Buffer::from(read(path)?); - let mut state = SipHasher::new(); - handle.hash(&mut state); - Self(state.finish128().as_u128()) - } -} - -/// Holds canonical data for all paths pointing to the same entity. -#[derive(Default)] -struct PathSlot { - source: OnceCell>, - buffer: OnceCell>, -} - -struct FontSearcher { - book: FontBook, - fonts: Vec, -} - -impl FontSearcher { - fn new() -> Self { - Self { - book: FontBook::new(), - fonts: vec![], - } - } - - fn add_embedded(&mut self) { - let mut add = |bytes: &'static [u8]| { - let buffer = Buffer::from_static(bytes); - for (i, font) in Font::iter(buffer.clone()).enumerate() { - self.book.push(font.info().clone()); - self.fonts.push(FontSlot { - buffer: buffer.clone(), - index: i as u32, - font: OnceCell::from(Some(font)), - }); - } - }; - - // Embed default fonts. - add(include_bytes!("../assets/fonts/LinLibertine_R.ttf")); - add(include_bytes!("../assets/fonts/LinLibertine_RB.ttf")); - add(include_bytes!("../assets/fonts/LinLibertine_RBI.ttf")); - add(include_bytes!("../assets/fonts/LinLibertine_RI.ttf")); - add(include_bytes!("../assets/fonts/NewCMMath-Book.otf")); - add(include_bytes!("../assets/fonts/NewCMMath-Regular.otf")); - add(include_bytes!("../assets/fonts/DejaVuSansMono.ttf")); - add(include_bytes!("../assets/fonts/DejaVuSansMono-Bold.ttf")); - add(include_bytes!("../assets/fonts/DejaVuSansMono-Oblique.ttf")); - add(include_bytes!( - "../assets/fonts/DejaVuSansMono-BoldOblique.ttf" - )); - } - - async fn search_system(&mut self) -> Result<(), JsValue> { - if let Some(window) = web_sys::window() { - for fontdata in JsFuture::from(window.query_local_fonts()?) - .await? - .dyn_into::()? - .to_vec() - { - let buffer = Buffer::from( - js_sys::Uint8Array::new( - &JsFuture::from( - JsFuture::from(fontdata.dyn_into::()?.blob()) - .await? - .dyn_into::()? - .array_buffer(), - ) - .await?, - ) - .to_vec(), - ); - for (i, info) in FontInfo::iter(buffer.as_slice()).enumerate() { - self.book.push(info); - self.fonts.push(FontSlot { - buffer: buffer.clone(), - index: i as u32, - font: OnceCell::new(), - }) - } - } - } - Ok(()) - } } diff --git a/src/paths.rs b/src/paths.rs new file mode 100644 index 0000000..b34e86c --- /dev/null +++ b/src/paths.rs @@ -0,0 +1,56 @@ +use std::{cell::OnceCell, hash::Hash, path::PathBuf}; + +use siphasher::sip128::{Hasher128, SipHasher13}; +use typst::{diag::FileResult, file::FileId, syntax::Source, util::Bytes}; + +/// Holds canonical data for all pahts pointing to the same entity. +/// +/// Both fields can be populated if the file is both imported and read(). +pub struct PathSlot { + /// The slot's canonical file id. + pub id: FileId, + /// The slot's path on the system. + pub system_path: PathBuf, + /// The loaded buffer for a path hash. + pub buffer: OnceCell>, + /// The lazily loaded source file for a path hash. + pub source: FileResult, +} + +impl PathSlot { + pub fn source(&self) -> FileResult { + self.source.clone() + } + + pub fn file(&self) -> FileResult { + self.buffer + .get_or_init(|| Ok(Bytes::from(self.source()?.text().as_bytes()))) + .clone() + } + // pub fn source(&self) -> FileResult { + // self.source + // .get_or_init(|| { + // Ok(Source::new( + // self.id, + // String::from_utf8(self.buffer.clone()?.to_vec())?, + // )) + // }) + // .clone() + // } + + // pub fn file(&self) -> FileResult { + // self.buffer.clone() + // } +} + +/// A hash that is the same for all paths pointing to the same entity. +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +pub struct PathHash(u128); + +impl PathHash { + pub fn new(source: &str) -> Self { + let mut state = SipHasher13::new(); + source.hash(&mut state); + Self(state.finish128().as_u128()) + } +} diff --git a/styles.css b/styles.css index e30dc71..55e9342 100644 --- a/styles.css +++ b/styles.css @@ -1 +1,15 @@ -/* styles */ \ No newline at end of file +/* styles */ +textarea { + width: 100%; + resize: vertical; +} + +.setting-item:has(textarea) { + flex-direction: column; + gap: 0.5em; + align-items: stretch; +} + +.is-disabled { + display: none; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 2d6fbdf..12a65f1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,7 @@ "moduleResolution": "node", "importHelpers": true, "isolatedModules": true, - "strictNullChecks": true, + "strictNullChecks": true, "lib": [ "DOM", "ES5", @@ -21,4 +21,4 @@ "include": [ "**/*.ts" ] -} +} \ No newline at end of file diff --git a/types.d.ts b/types.d.ts new file mode 100644 index 0000000..718344c --- /dev/null +++ b/types.d.ts @@ -0,0 +1,13 @@ +export interface CompileCommand { + source: string; + path: string; + pixel_per_pt: number; + fill: string; + size: number; + display: boolean; +} + +export interface WorkerRequest { + buffer: Int32Array, + path: string +} \ No newline at end of file diff --git a/typst-canvas-element.ts b/typst-canvas-element.ts index 0c46c54..290508c 100644 --- a/typst-canvas-element.ts +++ b/typst-canvas-element.ts @@ -1,17 +1,31 @@ export default class TypstCanvasElement extends HTMLCanvasElement { - static compile: (source: string, size: number, display: boolean, fontSize: number) => ImageData; + static compile: (path: string, source: string, size: number, display: boolean, fontSize: number) => Promise; + static nextId = 0; + static prevHeight = 0; + id: string + abortController: AbortController source: string + path: string display: boolean resizeObserver: ResizeObserver size: number + math: boolean - connectedCallback() { + async connectedCallback() { if (!this.isConnected) { - console.log("called before connection"); + console.warn("Typst Renderer: Canvas element has been called before connection"); return; } - this.draw() + + // if (this.display && this.math) { + this.height = TypstCanvasElement.prevHeight; + // } + + this.id = "TypstCanvasElement-" + TypstCanvasElement.nextId.toString() + TypstCanvasElement.nextId += 1 + this.abortController = new AbortController() + if (this.display) { this.resizeObserver = new ResizeObserver((entries) => { if (entries[0]?.contentBoxSize[0].inlineSize !== this.size) { @@ -20,43 +34,58 @@ export default class TypstCanvasElement extends HTMLCanvasElement { }) this.resizeObserver.observe(this.parentElement!.parentElement!) } + await this.draw() } disconnectedCallback() { - if (this.display) { + TypstCanvasElement.prevHeight = this.height + if (this.display && this.resizeObserver != undefined) { this.resizeObserver.disconnect() } } - draw() { - - let fontSize = parseFloat(this.getCssPropertyValue("--font-text-size")) - this.size = this.display ? this.parentElement!.parentElement!.innerWidth : parseFloat(this.getCssPropertyValue("--line-height-normal")) * fontSize - // console.log(size, this.parentElement); - - - if (this.display) { - this.style.width = "100%" - } else { - this.style.verticalAlign = "bottom" - this.style.height = `${this.size}px` - } - - let image: ImageData; - let ctx = this.getContext("2d")!; + async draw() { + this.abortController.abort() + this.abortController = new AbortController() try { - image = TypstCanvasElement.compile(this.source, this.size, this.display, fontSize) + await navigator.locks.request(this.id, { signal: this.abortController.signal }, async () => { + let fontSize = parseFloat(this.getCssPropertyValue("--font-text-size")) + this.size = this.display ? this.parentElement!.parentElement!.innerWidth : parseFloat(this.getCssPropertyValue("--line-height-normal")) * fontSize + + // resizeObserver can trigger before the element gets disconnected which can cause the size to be 0 + // which causes a NaN. size can also sometimes be -ve so wait for resize to draw it again + if (this.size <= 0) { + return; + } + + let image: ImageData; + let ctx = this.getContext("2d")!; + try { + image = + await TypstCanvasElement.compile(this.path, this.source, this.size, this.display, fontSize) + } catch (error) { + console.error(error); + this.outerText = error + return + } + + if (this.display) { + this.style.width = "100%" + this.style.height = "" + } else { + this.style.verticalAlign = "bottom" + this.style.height = `${this.size}px` + } + this.width = image.width + this.height = image.height + + ctx.imageSmoothingEnabled = true + ctx.imageSmoothingQuality = "high" + ctx.putImageData(image, 0, 0); + }) + } catch (error) { - console.error(error); - this.outerText = error return } - - this.width = image.width - this.height = image.height - - ctx.imageSmoothingEnabled = true - ctx.imageSmoothingQuality = "high" - ctx.putImageData(image, 0, 0); } } \ No newline at end of file diff --git a/versions.json b/versions.json index cb4131c..014641f 100644 --- a/versions.json +++ b/versions.json @@ -1,4 +1,5 @@ { + "0.5.0": "1.0.0", "0.4.2": "1.0.0", "0.4.1": "1.0.0", "0.4.0": "1.0.0",