From f39f921179b7def1dc27fc35c247db50bdeecee9 Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Fri, 29 Mar 2024 15:50:40 +0100 Subject: [PATCH 01/17] refactor: robust whitespace handling (#83) * feature: robust JSX whitespace handling * cleanup * refactor(js-macro): align whitespacing handling with js version ref: https://github.com/lingui/js-lingui/pull/1897 !BREAKING CHANGE --- Cargo.lock | 723 +++++++++++++++----------------- Cargo.toml | 3 +- src/ast_utils.rs | 1 + src/builder.rs | 16 +- src/js_macro_folder.rs | 4 +- src/jsx_visitor.rs | 46 +- src/lib.rs | 4 +- src/macro_utils.rs | 2 +- src/normalize_witespaces_js.rs | 39 -- src/normalize_witespaces_jsx.rs | 117 ------ src/tests/common/mod.rs | 1 - src/tests/js_t.rs | 38 +- src/tests/jsx.rs | 51 ++- src/tests/jsx_icu.rs | 4 +- 14 files changed, 457 insertions(+), 592 deletions(-) delete mode 100644 src/normalize_witespaces_js.rs delete mode 100644 src/normalize_witespaces_jsx.rs diff --git a/Cargo.lock b/Cargo.lock index 4b170aa..c138eb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.17.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -29,9 +29,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom", "once_cell", @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -58,9 +58,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "ast_node" @@ -71,7 +71,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] @@ -93,9 +93,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.66" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -106,12 +106,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.7" @@ -135,9 +129,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bitvec" @@ -153,9 +147,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -173,29 +167,29 @@ dependencies = [ [[package]] name = "bytecheck_derive" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ "proc-macro2", "quote", - "syn 1.0.105", + "syn 1.0.109", ] [[package]] name = "camino" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.2" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" dependencies = [ "serde", ] @@ -208,7 +202,21 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.17", + "semver 1.0.22", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.22", "serde", "serde_json", "thiserror", @@ -216,9 +224,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.77" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" [[package]] name = "cfg-if" @@ -228,9 +236,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -246,20 +254,20 @@ dependencies = [ ] [[package]] -name = "ctor" -version = "0.1.26" +name = "data-encoding" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" -dependencies = [ - "quote", - "syn 1.0.105", -] +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] -name = "data-encoding" -version = "2.3.3" +name = "debugid" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" +dependencies = [ + "serde", + "uuid", +] [[package]] name = "diff" @@ -285,9 +293,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "equivalent" @@ -297,39 +305,25 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.1" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", "libc", + "windows-sys", ] [[package]] name = "fastrand" -version = "1.8.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -342,7 +336,7 @@ checksum = "3a0b11eeb173ce52f84ebd943d42e58813a2ebb78a6a3ff0a243b71c5199cd7b" dependencies = [ "proc-macro2", "swc_macros_common", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] @@ -353,9 +347,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -363,9 +357,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -374,15 +368,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.2" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hashbrown" @@ -410,9 +404,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -435,9 +429,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -451,58 +445,37 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" [[package]] name = "indexmap" -version = "2.2.2" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", "hashbrown 0.14.3", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" -dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "is-macro" -version = "0.3.0" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4467ed1321b310c2625c5aa6c1b1ffc5de4d9e42668cf697a08fb033ee8265e" +checksum = "59a85abdc13717906baccb5a1e435556ce0df215f242892f721dff62bf25288f" dependencies = [ "Inflector", - "pmutil", "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] name = "is_ci" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "lazy_static" @@ -512,9 +485,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.142" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "lingui_macro_plugin" @@ -526,21 +499,20 @@ dependencies = [ "serde", "serde_json", "sha2", - "swc_common", "swc_core", ] [[package]] name = "linux-raw-sys" -version = "0.3.4" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -548,12 +520,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "matchers" @@ -561,7 +530,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -598,23 +567,23 @@ checksum = "6b5bc45b761bcf1b5e6e6c4128cd93b84c218721a8d9b894aa0aff4ed180174c" dependencies = [ "proc-macro2", "quote", - "syn 1.0.105", + "syn 1.0.109", ] [[package]] name = "miniz_oxide" -version = "0.5.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] [[package]] name = "new_debug_unreachable" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "nu-ansi-term" @@ -628,9 +597,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -640,56 +609,46 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.14.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi 0.3.9", "libc", ] [[package]] name = "object" -version = "0.29.0" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "output_vt100" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" -dependencies = [ - "winapi", -] +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "overload" @@ -715,22 +674,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.5" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall", "smallvec", - "windows-sys 0.42.0", + "windows-targets 0.48.5", ] [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "phf" @@ -762,7 +721,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] @@ -776,38 +735,25 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" - -[[package]] -name = "pmutil" -version = "0.6.1" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", -] +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pretty_assertions" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" dependencies = [ - "ctor", "diff", - "output_vt100", "yansi", ] [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -838,14 +784,14 @@ checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", "quote", - "syn 1.0.105", + "syn 1.0.109", ] [[package]] name = "quote" -version = "1.0.29" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -873,31 +819,23 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.8.1" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.1", + "regex-automata 0.4.6", + "regex-syntax 0.8.2", ] [[package]] @@ -906,32 +844,43 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax 0.6.28", + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.2", ] [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "relative-path" -version = "1.7.2" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df32d82cedd1499386877b062ebe8721f806de80b08d183c70184ef17dd1d42" +checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" [[package]] name = "rend" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" dependencies = [ "bytecheck", ] @@ -955,20 +904,20 @@ dependencies = [ [[package]] name = "rkyv_derive" -version = "0.7.41" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1c672430eb41556291981f45ca900a0239ad007242d1cb4b4167af842db666" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" dependencies = [ "proc-macro2", "quote", - "syn 1.0.105", + "syn 1.0.109", ] [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -987,16 +936,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.14" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1007,9 +955,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "scoped-tls" @@ -1019,9 +967,9 @@ checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "seahash" @@ -1040,9 +988,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" dependencies = [ "serde", ] @@ -1055,29 +1003,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.150" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e326c9ec8042f1b5da33252c8a37e9ffbd2c9bef0155215b6e6c80c790e05f91" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.150" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a3df25b0713732468deadad63ab9da1f1fd75a48a15024b50363f128db627e" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.105", + "syn 2.0.53", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -1097,9 +1045,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] @@ -1112,9 +1060,9 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "smallvec" @@ -1135,23 +1083,23 @@ dependencies = [ [[package]] name = "smawk" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "sourcemap" -version = "6.2.0" +version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c46fdc1838ff49cf692226f5c2b0f5b7538f556863d0eca602984714667ac6e7" +checksum = "e4cbf65ca7dc576cf50e21f8d0712d96d4fcfd797389744b7b222a85cdf5bd90" dependencies = [ - "base64 0.13.1", + "data-encoding", + "debugid", "if_chain", - "lazy_static", - "regex", "rustc_version", "serde", "serde_json", + "unicode-id", "url", ] @@ -1183,7 +1131,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] @@ -1230,9 +1178,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.33.15" +version = "0.33.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3792c10fa5d3e93a705b31f13fdea4a6e68c3c20d4351e84ed1741b7864399cd" +checksum = "317d2fcdbb1bc9ecfd0bfc67468d675a5159a6fd1863abf41c8c5b7b7adcab03" dependencies = [ "anyhow", "ast_node", @@ -1262,9 +1210,9 @@ dependencies = [ [[package]] name = "swc_core" -version = "0.87.28" +version = "0.90.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b3e389aed344d9d738f7e0901a1778a8402f10e459556c6d3a7a5b4501bf4cf" +checksum = "85e13f646052009efc019e13e148b22fe4ab108d4e0471aa06dabef49579a1f6" dependencies = [ "once_cell", "swc_atoms", @@ -1283,11 +1231,11 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.110.17" +version = "0.112.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79401a45da704f4fb2552c5bf86ee2198e8636b121cb81f8036848a300edd53b" +checksum = "70656acd47c91918635f1e8589963428cb3170975b71d786c79fb7a25605f687" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.5.0", "bytecheck", "is-macro", "num-bigint", @@ -1302,9 +1250,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.146.55" +version = "0.148.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa20d5c61563c5ec9ba469a7701512f4d6bc29790718cd198f43e61148e8aff2" +checksum = "2afcce205914b8451880fc5ef63dae9bac3dc7b71917921ede64f8e7fd8447a1" dependencies = [ "memchr", "num-bigint", @@ -1328,14 +1276,14 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] name = "swc_ecma_parser" -version = "0.141.37" +version = "0.143.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4d17401dd95048a6a62b777d533c0999dabdd531ef9d667e22f8ae2a2a0d294" +checksum = "4b919bb9ae5e1c8c54fb109f7e94b4a00185bd255c1238ba823e8102601e2133" dependencies = [ "either", "new_debug_unreachable", @@ -1355,9 +1303,9 @@ dependencies = [ [[package]] name = "swc_ecma_testing" -version = "0.22.17" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b73fd79980ad3182437a62dc0413bcd00e6157a7fcf5a64a86fa264ec6672ba" +checksum = "7c5704ef494b1805bc4566ff566b964bc1e9d3fb0f0e046ad6392b09a54de844" dependencies = [ "anyhow", "hex", @@ -1368,12 +1316,12 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.135.12" +version = "0.137.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f0efec63cc56f3f2b93d1367d16e684d1c6f4a6cb85436db2c91448867df2b" +checksum = "69e9a23d6af398b6efd17bbdad2cfa580102f6c560611f85c63b48f76ffe8f0c" dependencies = [ "better_scoped_tls", - "bitflags 2.3.3", + "bitflags 2.5.0", "indexmap", "once_cell", "phf", @@ -1391,13 +1339,13 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_testing" -version = "0.138.12" +version = "0.140.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecfd5d3bdcb529c4db2ac27fac59a9e1ce66975543d34f9ce60e7ee2cbc73f78" +checksum = "e9a51288aebf6894f8643c44ad08ed1d9c81b8bfce47195c13f9ff994b77a946" dependencies = [ "ansi_term", "anyhow", - "base64 0.21.7", + "base64", "hex", "serde", "serde_json", @@ -1417,9 +1365,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.125.4" +version = "0.127.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cead1083e46b0f072a82938f16d366014468f7510350957765bb4d013496890" +checksum = "e751404ec9bfeaa2900909fa175d854a4b7dec18420e475cc3195b9052803c46" dependencies = [ "indexmap", "num_cpus", @@ -1435,9 +1383,9 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.96.17" +version = "0.98.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d0100c383fb08b6f34911ab6f925950416a5d14404c1cd520d59fb8dfbb3bf" +checksum = "93692bdcdbb63db8f5e10fea5d202b5487cb27eb443aec424f4335c88f9864af" dependencies = [ "num-bigint", "swc_atoms", @@ -1455,14 +1403,14 @@ checksum = "695a1d8b461033d32429b5befbf0ad4d7a2c4d6ba9cd5ba4e0645c615839e8e4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] name = "swc_error_reporters" -version = "0.17.14" +version = "0.17.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be42e786ee9bda3f72f7d7de791e1d7b49ab7f86ed54fdc5808681ae04406080" +checksum = "3329e73f159a3d38d4cd5f606a0918eeff39f5bbdbdafd9b6fecb290d2e9a32d" dependencies = [ "anyhow", "miette", @@ -1479,7 +1427,7 @@ checksum = "50176cfc1cbc8bb22f41c6fe9d1ec53fbe057001219b5954961b8ad0f336fce9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] @@ -1499,14 +1447,14 @@ checksum = "3232db481484070637b20a155c064096c0ea1ba04fa2247b89b618661b3574f4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] name = "swc_plugin_proxy" -version = "0.39.17" +version = "0.41.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f00d9e79d36925854ce4de73acf397a6882a0dccb5b248d1ec48202ac3f72ad" +checksum = "012e5996e3fe64805342b6e31a79d826402bbe4eed35be6a9366e54e41f5d75d" dependencies = [ "better_scoped_tls", "rkyv", @@ -1524,14 +1472,14 @@ checksum = "ff9719b6085dd2824fd61938a881937be14b08f95e2d27c64c825a9f65e052ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] name = "swc_visit" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b27078d8571abe23aa52ef608dd1df89096a37d867cf691cbb4f4c392322b7c9" +checksum = "3f5b3e8d1269a7cb95358fed3412645d9c15aa0eb1f4ca003a25a38ef2f30f1b" dependencies = [ "either", "swc_visit_macros", @@ -1539,23 +1487,22 @@ dependencies = [ [[package]] name = "swc_visit_macros" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8bb05975506741555ea4d10c3a3bdb0e2357cd58e1a4a4332b8ebb4b44c34d" +checksum = "33fc817055fe127b4285dc85058596768bfde7537ae37da82c67815557f03e33" dependencies = [ "Inflector", - "pmutil", "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] name = "syn" -version = "1.0.105" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -1564,9 +1511,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.23" +version = "2.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" dependencies = [ "proc-macro2", "quote", @@ -1581,23 +1528,21 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.6.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ - "autocfg", "cfg-if", "fastrand", - "redox_syscall 0.3.5", "rustix", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "termcolor" -version = "1.1.3" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -1614,12 +1559,12 @@ dependencies = [ [[package]] name = "testing" -version = "0.35.16" +version = "0.35.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42599f638bd2b48c2892cf330862aca433c86286ae776d75c5074ba3b4935ed8" +checksum = "761d1719907168f43b49b438bdb58c41608f4af5eac0995e2a8bb16c522656c5" dependencies = [ "ansi_term", - "cargo_metadata", + "cargo_metadata 0.15.4", "difference", "once_cell", "pretty_assertions", @@ -1646,7 +1591,7 @@ dependencies = [ "quote", "regex", "relative-path", - "syn 2.0.23", + "syn 2.0.53", ] [[package]] @@ -1662,30 +1607,31 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.105", + "syn 2.0.53", ] [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ + "cfg-if", "once_cell", ] @@ -1700,17 +1646,16 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1718,20 +1663,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.105", + "syn 2.0.53", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -1739,20 +1684,20 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -1768,64 +1713,60 @@ dependencies = [ [[package]] name = "typed-arena" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0685c84d5d54d1c26f7d3eb96cd41550adb97baed141a761cf335d3d33bcd0ae" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-id" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d70b6494226b36008c8366c288d77190b3fad2eb4c10533139c1c1f461127f1a" +checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f" [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-linebreak" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" -dependencies = [ - "hashbrown 0.12.3", - "regex", -] +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "url" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -1834,9 +1775,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.3.3" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" [[package]] name = "valuable" @@ -1846,11 +1787,13 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vergen" -version = "8.2.4" +version = "8.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbc5ad0d9d26b2c49a5ab7da76c3e79d3ee37e7821799f8223fcb8f2f391a2e7" +checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" dependencies = [ "anyhow", + "cargo_metadata 0.18.1", + "regex", "rustversion", ] @@ -1884,9 +1827,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -1899,126 +1842,126 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets 0.52.4", ] [[package]] -name = "windows-sys" -version = "0.48.0" +name = "windows-targets" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows-targets", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "wyz" diff --git a/Cargo.toml b/Cargo.toml index 638203a..1c47f31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,7 @@ serde = "1" serde_json = "1.0.95" regex = "1.7.3" once_cell = "1.17.1" -swc_common = "=0.33.15" -swc_core = { version = "0.87.28", features = [ +swc_core = { version = "0.90.3", features = [ "ecma_plugin_transform", "ecma_utils", "ecma_visit", diff --git a/src/ast_utils.rs b/src/ast_utils.rs index a90cfdc..a5ea976 100644 --- a/src/ast_utils.rs +++ b/src/ast_utils.rs @@ -149,6 +149,7 @@ pub fn create_key_value_prop(key: &str, value: Box) -> PropOrSpread { pub fn create_import(source: JsWord, specifier: Ident) -> ModuleItem { ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { span: DUMMY_SP, + phase: ImportPhase::default(), specifiers: vec![ ImportSpecifier::Named(ImportNamedSpecifier { span: DUMMY_SP, diff --git a/src/builder.rs b/src/builder.rs index 3b85b00..df53929 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -6,10 +6,6 @@ use swc_core::{ }, }; -use crate::{ - normalize_witespaces_js::normalize_whitespaces_js, - normalize_witespaces_jsx::normalize_whitespaces_jsx, -}; use crate::tokens::{IcuChoice, CaseOrOffset, MsgToken}; fn dedup_values(mut v: Vec) -> Vec { @@ -55,7 +51,7 @@ pub struct MessageBuilder { } impl MessageBuilder { - pub fn parse(tokens: Vec, jsx: bool) -> MessageBuilderResult { + pub fn parse(tokens: Vec) -> MessageBuilderResult { let mut builder = MessageBuilder { message: String::new(), components_stack: Vec::new(), @@ -65,15 +61,11 @@ impl MessageBuilder { }; builder.from_tokens(tokens); - builder.to_args(jsx) + builder.to_args() } - pub fn to_args(mut self, jsx: bool) -> MessageBuilderResult { - let message_str = if jsx { - normalize_whitespaces_jsx(&self.message) - } else { - normalize_whitespaces_js(&self.message) - }; + pub fn to_args(mut self) -> MessageBuilderResult { + let message_str = self.message; let message = Box::new(Expr::Lit(Lit::Str(Str { span: DUMMY_SP, diff --git a/src/js_macro_folder.rs b/src/js_macro_folder.rs index 75fbbdf..de8598c 100644 --- a/src/js_macro_folder.rs +++ b/src/js_macro_folder.rs @@ -24,7 +24,7 @@ impl<'a> JsMacroFolder<'a> { } fn create_message_descriptor_from_tokens(&mut self, tokens: Vec) -> Expr { - let parsed = MessageBuilder::parse(tokens, false); + let parsed = MessageBuilder::parse(tokens); let mut props: Vec = vec![ create_key_value_prop("id", generate_message_id(&parsed.message_str, "").into()), @@ -98,7 +98,7 @@ impl<'a> JsMacroFolder<'a> { if let Some(prop) = message_prop { let tokens = self.ctx.try_tokenize_expr(&prop.value).unwrap_or_else(|| Vec::new()); - let parsed = MessageBuilder::parse(tokens, false); + let parsed = MessageBuilder::parse(tokens); if !id_prop.is_some() { new_props.push( diff --git a/src/jsx_visitor.rs b/src/jsx_visitor.rs index bf99954..e2c697b 100644 --- a/src/jsx_visitor.rs +++ b/src/jsx_visitor.rs @@ -32,6 +32,49 @@ static WORD_OPTION: Lazy = Lazy::new(|| Regex::new(r"_(\w+)").unwrap()); // const pluralRuleRe = /(_[\d\w]+|zero|one|two|few|many|other)/ // const jsx2icuExactChoice = (value: string) => value.replace(/_(\d+)/, "=$1").replace(/_(\w+)/, "$1") +// taken from babel repo -> packages/babel-types/src/utils/react/cleanJSXElementLiteralChild.ts +fn clean_jsx_element_literal_child(value: &str) -> String { + let lines: Vec<&str> = value.split('\n').collect(); + let mut last_non_empty_line = 0; + + for (i, line) in lines.iter().enumerate() { + if line.trim().len() > 0 { + last_non_empty_line = i; + } + } + + let mut result = String::new(); + + for (i, line) in lines.iter().enumerate() { + let is_first_line = i == 0; + let is_last_line = i == lines.len() - 1; + let is_last_non_empty_line = i == last_non_empty_line; + + // replace rendered whitespace tabs with spaces + let mut trimmed_line = line.replace("\t", " "); + + // trim whitespace touching a newline + if !is_first_line { + trimmed_line = trimmed_line.trim_start().to_string(); + } + + // trim whitespace touching an endline + if !is_last_line { + trimmed_line = trimmed_line.trim_end().to_string(); + } + + if !trimmed_line.is_empty() { + if !is_last_non_empty_line { + trimmed_line.push(' '); + } + + result.push_str(&trimmed_line); + } + } + + result +} + fn is_allowed_plural_option(key: &str) -> Option { if PLURAL_OPTIONS_WHITELIST.is_match(key) { let key = NUM_OPTION.replace(key, "=$1"); @@ -174,8 +217,9 @@ impl<'a> Visit for TransJSXVisitor<'a> { } fn visit_jsx_text(&mut self, el: &JSXText) { + self.tokens.push( - MsgToken::String(el.value.to_string()) + MsgToken::String(clean_jsx_element_literal_child(&el.raw.to_string())) ); } diff --git a/src/lib.rs b/src/lib.rs index 3944009..9b72f2f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,6 @@ use swc_core::{ }; mod tests; -mod normalize_witespaces_jsx; -mod normalize_witespaces_js; mod builder; mod tokens; mod ast_utils; @@ -58,7 +56,7 @@ impl LinguiMacroFolder { el.visit_children_with(&mut trans_visitor); } - let parsed = MessageBuilder::parse(trans_visitor.tokens, true); + let parsed = MessageBuilder::parse(trans_visitor.tokens); let id_attr = get_jsx_attr(&el.opening, "id"); let context_attr_val = get_jsx_attr(&el.opening, "context") diff --git a/src/macro_utils.rs b/src/macro_utils.rs index 0ae65f0..ade55e8 100644 --- a/src/macro_utils.rs +++ b/src/macro_utils.rs @@ -110,7 +110,7 @@ impl MacroCtx { let mut tokens: Vec = Vec::with_capacity(tpl.quasis.len()); for (i, tpl_element) in tpl.quasis.iter().enumerate() { - tokens.push(MsgToken::String(tpl_element.raw.to_string())); + tokens.push(MsgToken::String(tpl_element.cooked.as_ref().unwrap_or(&tpl_element.raw).to_string())); if let Some(exp) = tpl.exprs.get(i) { if let Expr::Call(call) = exp.as_ref() { diff --git a/src/normalize_witespaces_js.rs b/src/normalize_witespaces_js.rs deleted file mode 100644 index b080e48..0000000 --- a/src/normalize_witespaces_js.rs +++ /dev/null @@ -1,39 +0,0 @@ -use regex::{Regex}; -use once_cell::sync::Lazy; - -static KEEP_SPACE_RE: Lazy = Lazy::new(|| Regex::new(r"(?:\\(?:\r\n|\r|\n))+\s+").unwrap()); -static KEEP_NEW_LINE_RE: Lazy = Lazy::new(|| Regex::new(r"(?:\r\n|\r|\n)+\s+").unwrap()); - -// JS code for the reference: -// const keepSpaceRe = /(?:\\(?:\r\n|\r|\n))+\s+/g -// const keepNewLineRe = /(?:\r\n|\r|\n)+\s+/g -// -// function normalizeWhitespace(text: string): string { -// return text -// .replace(keepSpaceRe, " ") -// .replace(keepNewLineRe, "\n") -// .trim() -// } - -pub fn normalize_whitespaces_js(str: &str) -> String { - let str = KEEP_SPACE_RE.replace_all(&str, " "); - let str = KEEP_NEW_LINE_RE.replace_all(&str, "\n") - .trim().to_string(); - - return str -} - -#[cfg(test)] -mod tests { - use super::{*}; - - #[test] - fn test_normalize_whitespaces_js() { - assert_eq!( - normalize_whitespaces_js( - r#"Multiline - string"# - ), - "Multiline\nstring") - } -} \ No newline at end of file diff --git a/src/normalize_witespaces_jsx.rs b/src/normalize_witespaces_jsx.rs deleted file mode 100644 index 7e91d60..0000000 --- a/src/normalize_witespaces_jsx.rs +++ /dev/null @@ -1,117 +0,0 @@ -use regex::{Regex}; -use once_cell::sync::Lazy; - -// replace whitespace before/after newline with single space -static KEEP_SPACE_RE: Lazy = Lazy::new(|| Regex::new(r"\s*(?:\r\n|\r|\n)+\s*").unwrap()); -// remove whitespace before/after tag or expression -static STRIP_AROUND_TAGS: Lazy = Lazy::new(|| Regex::new(r"([>}])(?:\r\n|\r|\n)+\s*|(?:\r\n|\r|\n)+\s*([<{])").unwrap()); -static TRAILING_IN_EXPRESSIONS: Lazy = Lazy::new(|| Regex::new(r"(\s+})").unwrap()); -static LEADING_IN_EXPRESSIONS: Lazy = Lazy::new(|| Regex::new(r"(\{\s+)").unwrap()); -static KEEP_ESCAPED_NEWLINES_RE: Lazy = Lazy::new(|| Regex::new(r"\\n").unwrap()); - -// JS code for the reference: -// // replace whitespace before/after newline with single space -// const keepSpaceRe = /\s*(?:\r\n|\r|\n)+\s*/g -// // remove whitespace before/after tag or expression -// const stripAroundTagsRe = /(?:([>}])(?:\r\n|\r|\n)+\s*|(?:\r\n|\r|\n)+\s*(?=[<{]))/g -// -// function normalizeWhitespace(text) { -// return ( -// text -// .replace(stripAroundTagsRe, "$1") -// .replace(keepSpaceRe, " ") -// // keep escaped newlines -// .replace(/\\n/g, "\n") -// .replace(/\\s/g, " ") -// // we remove trailing whitespace inside Plural -// .replace(/(\s+})/gm, "}") -// // we remove leading whitespace inside Plural -// .replace(/({\s+)/gm, "{") -// .trim() -// ) -// } - -pub fn normalize_whitespaces_jsx(str: &str) -> String { - let str = STRIP_AROUND_TAGS.replace_all(&str, "$1$2"); - let str = KEEP_SPACE_RE.replace_all(&str, " "); - - let str = KEEP_ESCAPED_NEWLINES_RE.replace_all(&str, "\n"); - // we remove trailing whitespace inside Plural - let str = TRAILING_IN_EXPRESSIONS.replace_all(&str, "}"); - // we remove leading whitespace inside Plural - let str = LEADING_IN_EXPRESSIONS.replace_all(&str, "{"); - - return str.trim().to_string() -} - -#[cfg(test)] -mod tests { - use super::{*}; - - #[test] - fn test_normalize_whitespaces() { - assert_eq!( - normalize_whitespaces_jsx( - r#" - Hello World!
-

- My name is {{" "}}\s - {{name}} -

- "# - ), - r#"Hello World!

My name is {{" "}}\s{{name}}

"#) - } - - #[test] - fn test_normalize_whitespaces2() { - assert_eq!( - normalize_whitespaces_jsx( - r#" - Property {0}, - function {1}, - array {2}, - constant {3}, - object {4}, - everything {5} - "# - ), - r#"Property {0}, function {1}, array {2}, constant {3}, object {4}, everything {5}"#) - } - - #[test] - fn remove_trailing_in_icu() { - assert_eq!( - normalize_whitespaces_jsx( - r#"{count, plural, one { - - <0># slot added - - } other { - - <1># slots added - - }} -"# - ), - r#"{count, plural, one {<0># slot added} other {<1># slots added}}"#) - } - - #[test] - fn remove_leading_in_icu() { - assert_eq!( - normalize_whitespaces_jsx( - r#"{count, plural, one { - - One hello - - } other { - - Other hello - - }} -"# - ), - r#"{count, plural, one {One hello} other {Other hello}}"#) - } -} diff --git a/src/tests/common/mod.rs b/src/tests/common/mod.rs index b342575..e000f8d 100644 --- a/src/tests/common/mod.rs +++ b/src/tests/common/mod.rs @@ -40,4 +40,3 @@ macro_rules! to { ); } } - diff --git a/src/tests/js_t.rs b/src/tests/js_t.rs index dc22595..b83fd61 100644 --- a/src/tests/js_t.rs +++ b/src/tests/js_t.rs @@ -156,12 +156,46 @@ to!( r#" import { i18n } from "@lingui/core"; i18n._({ - id: "EfogM+", - message: "Multiline\nstring" + id: "amQF7O", + message: "Multiline\n string" }); "# ); +to!( + js_continuation_character, + r#" + import { t } from '@lingui/macro'; + t`Multiline\ + string`; + "#, + r#" + import { i18n } from "@lingui/core"; + i18n._({ + id: "d1nA7b", + message: "Multiline string" + }); + "# +); +to!( + unicode_characters_interpreted, + r#" + import { t } from '@lingui/macro'; + t`Message \u0020`; + t`Bienvenue\xA0!` + "#, + r#" + import { i18n } from "@lingui/core"; + i18n._({ + id: "dZXeyN", + message: "Message " + }); + i18n._({ + id: "9K3RGd", + message: "Bienvenue !" + }); + "# +); to!( js_support_message_descriptor_in_t_fn, r#" diff --git a/src/tests/jsx.rs b/src/tests/jsx.rs index d486e8a..4c97963 100644 --- a/src/tests/jsx.rs +++ b/src/tests/jsx.rs @@ -173,7 +173,7 @@ to!( r#" import { Trans } from "@lingui/react"; - This should work \xa0"} id={"K/1Xpr"} + This should work  "} id={"K/1Xpr"} components={{ 0: , }} @@ -276,36 +276,20 @@ to!( "# ); -to!( - keep_forced_newlines, - r#" - import { Trans } from "@lingui/macro"; - - Keep forced{"\\n"} - newlines! - - "#, - - r#" - import { Trans } from "@lingui/react"; - ; - "# -); - to!( keep_multiple_forced_newlines, r#" import { Trans } from "@lingui/macro"; - Keep multiple{"\\n"} - forced{"\\n"} + Keep multiple{"\n"} + forced{"\n"} newlines! "#, r#" import { Trans } from "@lingui/react"; - ; + ; "# ); @@ -389,7 +373,34 @@ to!( />; "# ); +to!( + strip_whitespaces_in_jsxtext_but_keep_in_jsx_expression_containers, + r#" + import { Trans } from "@lingui/macro"; + + {"Wonderful framework "} + Next.js + {" say hi. And "} + Next.js + {" say hi."} + + "#, + + r#" + import { Trans } from "@lingui/react"; + Next.js say hi. And <1>Next.js say hi." + } + id={"3YVd0H"} + components={{ + 0: , + 1: , + }} + />; + "# +); // { // name: "production - import_type_doesn't_interference_on_normal_import", // production: true, diff --git a/src/tests/jsx_icu.rs b/src/tests/jsx_icu.rs index bae4b85..58bdacb 100644 --- a/src/tests/jsx_icu.rs +++ b/src/tests/jsx_icu.rs @@ -347,13 +347,13 @@ to!( offset="1" _0=" #st" one=" #nd" - other='#rd' + other=' #rd' />; "#, r#" import { Trans } from "@lingui/react"; - ; "# From d00c6a7f89d33d80434a5bb74fb600a34497448d Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Fri, 5 Apr 2024 11:30:40 +0200 Subject: [PATCH 02/17] feature: split js / jsx macro (#86) --- src/lib.rs | 2 +- src/tests/imports.rs | 17 ++++++----- src/tests/js_icu.rs | 14 ++++----- src/tests/js_t.rs | 47 +++++++++++++++++++++--------- src/tests/jsx.rs | 58 ++++++++++++++++++++++--------------- src/tests/jsx_icu.rs | 14 ++++----- src/tests/runtime_config.rs | 3 +- 7 files changed, 94 insertions(+), 61 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9b72f2f..44a6e78 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -137,7 +137,7 @@ impl<'a> Fold for LinguiMacroFolder { n.retain(|m| { if let ModuleItem::ModuleDecl(ModuleDecl::Import(imp)) = m { // drop macro imports - if &imp.src.value == "@lingui/macro" { + if &imp.src.value == "@lingui/macro" || &imp.src.value == "@lingui/core/macro" || &imp.src.value == "@lingui/react/macro" { self.has_lingui_macro_imports = true; self.ctx.register_macro_import(imp); insert_index = index; diff --git a/src/tests/imports.rs b/src/tests/imports.rs index b841916..2e17c38 100644 --- a/src/tests/imports.rs +++ b/src/tests/imports.rs @@ -3,7 +3,8 @@ use crate::{to}; to!( should_not_add_extra_imports, r#" - import { t, Plural } from "@lingui/macro"; + import { t } from "@lingui/core/macro"; + import { Plural } from "@lingui/react/macro"; import { i18n } from "@lingui/core"; import { Trans } from "@lingui/react"; @@ -32,7 +33,7 @@ to!( to!( jsx_should_process_only_elements_imported_from_macro, r#" - import { Plural } from "@lingui/macro"; + import { Plural } from "@lingui/react/macro"; import { Select } from "./my-select-cmp"; ;Refresh inbox; const exp2 = Refresh inbox; const exp3 =
Refresh inbox
; @@ -16,11 +16,22 @@ const exp3 =
; "# ); +to!( + jsx_should_suppor_legacy_import, + r#" +import { Trans } from "@lingui/macro"; +const exp2 = Refresh inbox; + "#, + r#" +import { Trans } from "@lingui/react"; +const exp2 = ; + "# +); to!( jsx_with_custom_id, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; const exp2 = Refresh inbox; "#, r#" @@ -32,7 +43,7 @@ to!( to!( jsx_with_context, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; const exp1 = Refresh inbox; const exp2 = Refresh inbox; "#, @@ -46,7 +57,7 @@ to!( to!( jsx_preserve_reserved_attrs, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; const exp2 = v}>Refresh inbox; "#, r#" @@ -58,7 +69,7 @@ to!( to!( jsx_expressions_are_converted_to_positional_arguments, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; Property {props.name}, function {random()}, @@ -87,7 +98,7 @@ to!( to!( jsx_components_interpolation, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; Hello World!

@@ -116,7 +127,7 @@ to!( to!( jsx_values_dedup, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; Hello {foo} and {foo}{" "} {bar} @@ -135,7 +146,7 @@ to!( to!( jsx_template_literal_in_children, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; {`Hello ${foo} and ${bar}`} "#, r#" @@ -150,7 +161,7 @@ to!( to!( quoted_jsx_attributes_are_handled, r#" - import { Trans } from '@lingui/macro'; + import { Trans } from "@lingui/react/macro"; Speak "friend"!; Speak "friend"!; "#, @@ -165,7 +176,7 @@ to!( to!( html_attributes_are_handled, r#" - import { Trans } from '@lingui/macro'; + import { Trans } from "@lingui/react/macro"; This should work   ; @@ -184,7 +195,7 @@ to!( to!( use_decoded_html_entities, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; & "#, r#" @@ -197,7 +208,7 @@ to!( to!( elements_inside_expression_container, r#" - import { Trans } from '@lingui/macro'; + import { Trans } from "@lingui/react/macro"; {Component inside expression container}; "#, r#" @@ -214,7 +225,7 @@ to!( to!( elements_without_children, r#" - import { Trans } from '@lingui/macro'; + import { Trans } from "@lingui/react/macro"; {
}
; "#, @@ -230,7 +241,7 @@ to!( // to!( // jsx_spread_child_is_noop, // r#" -// import { Trans } from '@lingui/macro'; +// import { Trans } from "@lingui/react/macro"; // {...spread} // "#, // r#" @@ -242,7 +253,7 @@ to!( to!( strip_whitespace_around_arguments, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; Strip whitespace around arguments: ' {name} @@ -260,7 +271,7 @@ to!( to!( strip_whitespace_around_tags_but_keep_forced_spaces, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; Strip whitespace around tags, but keep{" "} forced spaces @@ -279,7 +290,7 @@ to!( to!( keep_multiple_forced_newlines, r#" - import { Trans } from "@lingui/macro"; + import { Trans } from "@lingui/react/macro"; Keep multiple{"\n"} forced{"\n"} @@ -296,7 +307,8 @@ to!( to!( use_js_macro_in_jsx_attrs, r#" - import { t, Trans } from '@lingui/macro'; + import { t } from '@lingui/core/macro'; + import { Trans } from '@lingui/react/macro'; Read
more "#, r#" @@ -317,7 +329,7 @@ to!( to!( use_js_plural_in_jsx_attrs, r#" - import { plural } from '@lingui/macro'; + import { plural } from '@lingui/core/macro'; Hello {/* and I cannot stress this enough */} World; "#, r#" @@ -353,7 +365,7 @@ to!( production, production_only_essential_props_are_kept, r#" - import { Trans } from '@lingui/macro'; + import { Trans } from "@lingui/react/macro"; {"Wonderful framework "} Next.js @@ -407,7 +419,7 @@ to!( // useTypescriptPreset: true, // input: ` // import { withI18nProps } from '@lingui/react' -// import { Trans } from '@lingui/macro'; +// import { Trans } from "@lingui/react/macro"; // Hello World // `, // expected: ` diff --git a/src/tests/jsx_icu.rs b/src/tests/jsx_icu.rs index 58bdacb..4b81e9d 100644 --- a/src/tests/jsx_icu.rs +++ b/src/tests/jsx_icu.rs @@ -3,7 +3,7 @@ use crate::{to}; to!( jsx_icu, r#" -import { Plural } from "@lingui/macro"; +import { Plural } from "@lingui/react/macro"; const ex1 = You have{" "} @@ -192,7 +192,7 @@ import { Trans, Plural } from '@lingui/macro'; to!( jsx_plural_with_offset_and_exact_matches, r#" - import { Plural } from "@lingui/macro"; + import { Plural } from "@lingui/react/macro"; Refresh inbox; From 78ba33d45643f8deb7daace005be2c8cffb88470 Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Thu, 18 Apr 2024 15:29:16 +0200 Subject: [PATCH 03/17] chore: sync next (#92) --- Cargo.lock | 707 ++++++++++-------- Cargo.toml | 4 +- README.md | 3 +- examples/{nextjs-13 => nextjs}/.gitignore | 0 examples/{nextjs-13 => nextjs}/README.md | 0 .../{nextjs-13 => nextjs}/lingui.config.js | 0 .../locales/cs/messages.po | 0 .../locales/en/messages.po | 0 examples/{nextjs-13 => nextjs}/next.config.js | 9 +- examples/{nextjs-13 => nextjs}/package.json | 15 +- .../{nextjs-13 => nextjs}/public/favicon.ico | Bin examples/{nextjs-13 => nextjs}/src/i18n.ts | 0 .../{nextjs-13 => nextjs}/src/pages/_app.tsx | 0 .../{nextjs-13 => nextjs}/src/pages/index.tsx | 0 .../src/styles/globals.css | 0 examples/{nextjs-13 => nextjs}/tsconfig.json | 0 examples/{nextjs-13 => nextjs}/yarn.lock | 264 +++---- package.json | 3 +- 18 files changed, 561 insertions(+), 444 deletions(-) rename examples/{nextjs-13 => nextjs}/.gitignore (100%) rename examples/{nextjs-13 => nextjs}/README.md (100%) rename examples/{nextjs-13 => nextjs}/lingui.config.js (100%) rename examples/{nextjs-13 => nextjs}/locales/cs/messages.po (100%) rename examples/{nextjs-13 => nextjs}/locales/en/messages.po (100%) rename examples/{nextjs-13 => nextjs}/next.config.js (51%) rename examples/{nextjs-13 => nextjs}/package.json (62%) rename examples/{nextjs-13 => nextjs}/public/favicon.ico (100%) rename examples/{nextjs-13 => nextjs}/src/i18n.ts (100%) rename examples/{nextjs-13 => nextjs}/src/pages/_app.tsx (100%) rename examples/{nextjs-13 => nextjs}/src/pages/index.tsx (100%) rename examples/{nextjs-13 => nextjs}/src/styles/globals.css (100%) rename examples/{nextjs-13 => nextjs}/tsconfig.json (100%) rename examples/{nextjs-13 => nextjs}/yarn.lock (92%) diff --git a/Cargo.lock b/Cargo.lock index c138eb6..ffb46bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.21.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ "gimli", ] @@ -29,9 +29,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.8" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ "getrandom", "once_cell", @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" dependencies = [ "memchr", ] @@ -58,9 +58,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "ast_node" @@ -71,7 +71,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -93,9 +93,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" dependencies = [ "addr2line", "cc", @@ -112,6 +112,15 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64-simd" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "781dd20c3aff0bd194fe7d2a977dd92f21c173891f3a03b677359e5fa457e5d5" +dependencies = [ + "simd-abstraction", +] + [[package]] name = "better_scoped_tls" version = "0.1.1" @@ -147,9 +156,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.4" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ "generic-array", ] @@ -167,29 +176,35 @@ dependencies = [ [[package]] name = "bytecheck_derive" -version = "0.6.12" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 1.0.105", ] +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + [[package]] name = "camino" -version = "1.1.6" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.7" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" dependencies = [ "serde", ] @@ -202,21 +217,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.22", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "cargo_metadata" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" -dependencies = [ - "camino", - "cargo-platform", - "semver 1.0.22", + "semver 1.0.17", "serde", "serde_json", "thiserror", @@ -224,9 +225,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.90" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" [[package]] name = "cfg-if" @@ -236,9 +237,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" dependencies = [ "libc", ] @@ -253,11 +254,21 @@ dependencies = [ "typenum", ] +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn 1.0.105", +] + [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" [[package]] name = "debugid" @@ -293,9 +304,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "equivalent" @@ -305,25 +316,39 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" dependencies = [ + "cc", "libc", - "windows-sys", ] [[package]] name = "fastrand" -version = "2.0.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] [[package]] name = "form_urlencoded" -version = "1.2.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -336,7 +361,7 @@ checksum = "3a0b11eeb173ce52f84ebd943d42e58813a2ebb78a6a3ff0a243b71c5199cd7b" dependencies = [ "proc-macro2", "swc_macros_common", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -347,9 +372,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "generic-array" -version = "0.14.7" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -357,9 +382,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -368,15 +393,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" [[package]] name = "glob" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "hashbrown" @@ -404,9 +429,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "hex" @@ -416,22 +441,23 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hstr" -version = "0.2.7" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17fafeca18cf0927e23ea44d7a5189c10536279dfe9094e0dfa953053fbb5377" +checksum = "96274be293b8877e61974a607105d09c84caebe9620b47774aa8a6b942042dd4" dependencies = [ + "hashbrown 0.14.3", "new_debug_unreachable", "once_cell", "phf", "rustc-hash", - "smallvec", + "triomphe", ] [[package]] name = "idna" -version = "0.5.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -445,14 +471,34 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" dependencies = [ "equivalent", "hashbrown 0.14.3", ] +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "is-macro" version = "0.3.5" @@ -462,20 +508,20 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] name = "is_ci" -version = "1.2.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" +checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "lazy_static" @@ -485,13 +531,13 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "lingui_macro_plugin" -version = "4.0.6" +version = "4.0.7" dependencies = [ "data-encoding", "once_cell", @@ -504,15 +550,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ "autocfg", "scopeguard", @@ -520,9 +566,12 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] [[package]] name = "matchers" @@ -530,7 +579,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] @@ -567,23 +616,23 @@ checksum = "6b5bc45b761bcf1b5e6e6c4128cd93b84c218721a8d9b894aa0aff4ed180174c" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 1.0.105", ] [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" dependencies = [ "adler", ] [[package]] name = "new_debug_unreachable" -version = "1.0.6" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" [[package]] name = "nu-ansi-term" @@ -597,9 +646,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ "autocfg", "num-integer", @@ -609,37 +658,38 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.46" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ + "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi 0.1.19", "libc", ] [[package]] name = "object" -version = "0.32.2" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "memchr", ] @@ -650,6 +700,21 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "output_vt100" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" +dependencies = [ + "winapi", +] + +[[package]] +name = "outref" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f222829ae9293e33a9f5e9f440c6760a3d450a64affe1846486b140db81c1f4" + [[package]] name = "overload" version = "0.1.1" @@ -674,22 +739,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", - "windows-targets 0.48.5", + "windows-sys 0.42.0", ] [[package]] name = "percent-encoding" -version = "2.3.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "phf" @@ -721,7 +786,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -735,25 +800,27 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pretty_assertions" -version = "1.4.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" dependencies = [ + "ctor", "diff", + "output_vt100", "yansi", ] [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -784,14 +851,14 @@ checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 1.0.105", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -819,23 +886,31 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.10.3" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.6", - "regex-syntax 0.8.2", + "regex-syntax 0.7.1", ] [[package]] @@ -844,55 +919,45 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.6.28", ] [[package]] name = "regex-syntax" -version = "0.6.29" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "relative-path" -version = "1.9.2" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" +checksum = "0df32d82cedd1499386877b062ebe8721f806de80b08d183c70184ef17dd1d42" [[package]] name = "rend" -version = "0.4.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" dependencies = [ "bytecheck", ] [[package]] name = "rkyv" -version = "0.7.42" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" dependencies = [ "bitvec", "bytecheck", + "bytes", "hashbrown 0.12.3", "ptr_meta", "rend", @@ -910,14 +975,14 @@ checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 1.0.105", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] name = "rustc-hash" @@ -936,15 +1001,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.37.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" dependencies = [ - "bitflags 2.5.0", + "bitflags 1.3.2", "errno", + "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -955,9 +1021,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "scoped-tls" @@ -967,9 +1033,9 @@ checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" -version = "1.2.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "seahash" @@ -988,9 +1054,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" dependencies = [ "serde", ] @@ -1003,29 +1069,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -1045,13 +1111,22 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.7" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" dependencies = [ "lazy_static", ] +[[package]] +name = "simd-abstraction" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cadb29c57caadc51ff8346233b5cec1d240b68ce55cf1afc764818791876987" +dependencies = [ + "outref", +] + [[package]] name = "simdutf8" version = "0.1.4" @@ -1060,9 +1135,9 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" [[package]] name = "siphasher" -version = "0.3.11" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "smallvec" @@ -1083,26 +1158,35 @@ dependencies = [ [[package]] name = "smawk" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" +checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" [[package]] name = "sourcemap" -version = "6.4.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4cbf65ca7dc576cf50e21f8d0712d96d4fcfd797389744b7b222a85cdf5bd90" +checksum = "208d40b9e8cad9f93613778ea295ed8f3c2b1824217c6cfc7219d3f6f45b96d4" dependencies = [ + "base64-simd", + "bitvec", "data-encoding", "debugid", "if_chain", + "rustc-hash", "rustc_version", "serde", "serde_json", - "unicode-id", + "unicode-id-start", "url", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "stacker" version = "0.1.15" @@ -1131,7 +1215,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1164,9 +1248,9 @@ dependencies = [ [[package]] name = "swc_atoms" -version = "0.6.5" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d538eaaa6f085161d088a04cf0a3a5a52c5a7f2b3bd9b83f73f058b0ed357c0" +checksum = "bb6567e4e67485b3e7662b486f1565bdae54bd5b9d6b16b2ba1a9babb1e42125" dependencies = [ "bytecheck", "hstr", @@ -1178,9 +1262,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.33.20" +version = "0.33.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317d2fcdbb1bc9ecfd0bfc67468d675a5159a6fd1863abf41c8c5b7b7adcab03" +checksum = "a529796c240cd87da18d26d63f9de4c7ad3680cf0a04b95f0c37f4c4f0a0da63" dependencies = [ "anyhow", "ast_node", @@ -1210,9 +1294,9 @@ dependencies = [ [[package]] name = "swc_core" -version = "0.90.23" +version = "0.90.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e13f646052009efc019e13e148b22fe4ab108d4e0471aa06dabef49579a1f6" +checksum = "2b9e641c348c1e8b0e01430b4706b777ecb0873323b423a8e8e5515093583e43" dependencies = [ "once_cell", "swc_atoms", @@ -1231,9 +1315,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.112.6" +version = "0.112.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70656acd47c91918635f1e8589963428cb3170975b71d786c79fb7a25605f687" +checksum = "d1d5c33c22ad50e8e34b3080a6fb133316d2eaa7d00400fc5018151f5ca44c5a" dependencies = [ "bitflags 2.5.0", "bytecheck", @@ -1245,14 +1329,14 @@ dependencies = [ "string_enum", "swc_atoms", "swc_common", - "unicode-id", + "unicode-id-start", ] [[package]] name = "swc_ecma_codegen" -version = "0.148.12" +version = "0.148.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2afcce205914b8451880fc5ef63dae9bac3dc7b71917921ede64f8e7fd8447a1" +checksum = "7188b2848402ce983f6c618a829b4ceb18d21eed7986782a7b7028cc234ede6b" dependencies = [ "memchr", "num-bigint", @@ -1276,14 +1360,14 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] name = "swc_ecma_parser" -version = "0.143.10" +version = "0.143.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b919bb9ae5e1c8c54fb109f7e94b4a00185bd255c1238ba823e8102601e2133" +checksum = "40b7faa481ac015b330f1c4bc8df2c9947242020e23ccdb10bc7a8ef84342509" dependencies = [ "either", "new_debug_unreachable", @@ -1316,9 +1400,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.137.16" +version = "0.137.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69e9a23d6af398b6efd17bbdad2cfa580102f6c560611f85c63b48f76ffe8f0c" +checksum = "660badfe2eed8b6213ec9dcd71aa0786f8fb46ffa012e0313bcba1fe4a9a5c73" dependencies = [ "better_scoped_tls", "bitflags 2.5.0", @@ -1339,9 +1423,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_testing" -version = "0.140.16" +version = "0.140.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9a51288aebf6894f8643c44ad08ed1d9c81b8bfce47195c13f9ff994b77a946" +checksum = "7c0ea6f85b7bf04391a172d7a369e49865effa77ec3a6cd0e969a274cfcb982d" dependencies = [ "ansi_term", "anyhow", @@ -1365,9 +1449,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.127.13" +version = "0.127.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e751404ec9bfeaa2900909fa175d854a4b7dec18420e475cc3195b9052803c46" +checksum = "15d40abfc4f3a7bfdf54d11ac705cc9dd0836c48bf085b359143b4d40b50cb31" dependencies = [ "indexmap", "num_cpus", @@ -1403,7 +1487,7 @@ checksum = "695a1d8b461033d32429b5befbf0ad4d7a2c4d6ba9cd5ba4e0645c615839e8e4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1427,7 +1511,7 @@ checksum = "50176cfc1cbc8bb22f41c6fe9d1ec53fbe057001219b5954961b8ad0f336fce9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1447,14 +1531,14 @@ checksum = "3232db481484070637b20a155c064096c0ea1ba04fa2247b89b618661b3574f4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] name = "swc_plugin_proxy" -version = "0.41.6" +version = "0.41.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "012e5996e3fe64805342b6e31a79d826402bbe4eed35be6a9366e54e41f5d75d" +checksum = "7e09ebf5da9eb13f431ebfb916cd3378a87ffae927ba896261ebc9dc094457ae" dependencies = [ "better_scoped_tls", "rkyv", @@ -1472,14 +1556,14 @@ checksum = "ff9719b6085dd2824fd61938a881937be14b08f95e2d27c64c825a9f65e052ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] name = "swc_visit" -version = "0.5.10" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f5b3e8d1269a7cb95358fed3412645d9c15aa0eb1f4ca003a25a38ef2f30f1b" +checksum = "0263be55289abfe9c877ffef83d877b5bdfac036ffe2de793f48f5e47e41dbae" dependencies = [ "either", "swc_visit_macros", @@ -1495,14 +1579,14 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] name = "syn" -version = "1.0.109" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" dependencies = [ "proc-macro2", "quote", @@ -1511,9 +1595,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.53" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -1528,21 +1612,23 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if", "fastrand", + "redox_syscall 0.3.5", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.4.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] @@ -1559,12 +1645,12 @@ dependencies = [ [[package]] name = "testing" -version = "0.35.21" +version = "0.35.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "761d1719907168f43b49b438bdb58c41608f4af5eac0995e2a8bb16c522656c5" +checksum = "689e2661712768726869f62945ccbe5d76ab3a3957b88221275bebe22a0761c8" dependencies = [ "ansi_term", - "cargo_metadata 0.15.4", + "cargo_metadata", "difference", "once_cell", "pretty_assertions", @@ -1591,7 +1677,7 @@ dependencies = [ "quote", "regex", "relative-path", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1607,31 +1693,30 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 1.0.105", ] [[package]] name = "thread_local" -version = "1.1.8" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" dependencies = [ - "cfg-if", "once_cell", ] @@ -1646,9 +1731,9 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tracing" @@ -1669,7 +1754,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1711,62 +1796,82 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "triomphe" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" +dependencies = [ + "serde", + "stable_deref_trait", +] + [[package]] name = "typed-arena" -version = "2.0.2" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" +checksum = "0685c84d5d54d1c26f7d3eb96cd41550adb97baed141a761cf335d3d33bcd0ae" [[package]] name = "typenum" -version = "1.17.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-id" -version = "0.3.4" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d70b6494226b36008c8366c288d77190b3fad2eb4c10533139c1c1f461127f1a" + +[[package]] +name = "unicode-id-start" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f" +checksum = "b8f73150333cb58412db36f2aca8f2875b013049705cc77b94ded70a1ab1f5da" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "unicode-linebreak" -version = "0.1.5" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" +checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" +dependencies = [ + "hashbrown 0.12.3", + "regex", +] [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "url" -version = "2.5.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -1775,9 +1880,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.8.0" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" [[package]] name = "valuable" @@ -1787,13 +1892,11 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vergen" -version = "8.3.1" +version = "8.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" +checksum = "bbc5ad0d9d26b2c49a5ab7da76c3e79d3ee37e7821799f8223fcb8f2f391a2e7" dependencies = [ "anyhow", - "cargo_metadata 0.18.1", - "regex", "rustversion", ] @@ -1827,9 +1930,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi", ] @@ -1842,126 +1945,126 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows-targets 0.52.4", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] -name = "windows-targets" -version = "0.48.5" +name = "windows-sys" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "wyz" diff --git a/Cargo.toml b/Cargo.toml index 1c47f31..3cc9b32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lingui_macro_plugin" -version = "4.0.6" +version = "4.0.7" edition = "2021" [lib] @@ -22,7 +22,7 @@ serde = "1" serde_json = "1.0.95" regex = "1.7.3" once_cell = "1.17.1" -swc_core = { version = "0.90.3", features = [ +swc_core = { version = "0.90.35", features = [ "ecma_plugin_transform", "ecma_utils", "ecma_visit", diff --git a/README.md b/README.md index 54b95de..5898d57 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,8 @@ So you need to select an appropriate version of the plugin to match compatible ` | `4.0.3` | `0.78.28` | `@swc/core@1.3.63` ~ `@swc/core@1.3.67`
`next@v13.4.8 ~ next@v13.4.10-canary.0` | | `4.0.4` | `0.79.x` | `@swc/core@1.3.68` ~ `@swc/core@1.3.80`
`next@v13.4.10-canary.1` ~ | | `4.0.5` | `0.87.x` | broken due incorrect version of `swc_common` | -| `4.0.6` | `0.87.x` | `@swc/core@1.3.81 ~ @swc/core@1.3.105`
`~ next@v14.1.0` | +| `4.0.6` | `0.87.x` | `@swc/core@1.3.81 ~ @swc/core@1.3.105`
`~ next@v14.1.0` | +| `4.0.7` | `0.90.35` | `@swc/core@1.4.0 ~`
`next@14.1.1-canary.52 ~`
`@rspack/core@0.6.0 ~` | This table may become outdated. If you don't see a particular version of `@swc/core` or `next` check the compatibility by referring to the upstream's [Selecting the version](https://swc.rs/docs/plugin/selecting-swc-core) article. This will help you select the appropriate plugin version for your project. diff --git a/examples/nextjs-13/.gitignore b/examples/nextjs/.gitignore similarity index 100% rename from examples/nextjs-13/.gitignore rename to examples/nextjs/.gitignore diff --git a/examples/nextjs-13/README.md b/examples/nextjs/README.md similarity index 100% rename from examples/nextjs-13/README.md rename to examples/nextjs/README.md diff --git a/examples/nextjs-13/lingui.config.js b/examples/nextjs/lingui.config.js similarity index 100% rename from examples/nextjs-13/lingui.config.js rename to examples/nextjs/lingui.config.js diff --git a/examples/nextjs-13/locales/cs/messages.po b/examples/nextjs/locales/cs/messages.po similarity index 100% rename from examples/nextjs-13/locales/cs/messages.po rename to examples/nextjs/locales/cs/messages.po diff --git a/examples/nextjs-13/locales/en/messages.po b/examples/nextjs/locales/en/messages.po similarity index 100% rename from examples/nextjs-13/locales/en/messages.po rename to examples/nextjs/locales/en/messages.po diff --git a/examples/nextjs-13/next.config.js b/examples/nextjs/next.config.js similarity index 51% rename from examples/nextjs-13/next.config.js rename to examples/nextjs/next.config.js index 91bd25f..cb05bac 100644 --- a/examples/nextjs-13/next.config.js +++ b/examples/nextjs/next.config.js @@ -1,3 +1,10 @@ +const path = require('node:path'); + +const plugin = process.env.USE_LOCAL_PLUGIN_BINARY + ? path.join(__dirname, '../../target/wasm32-wasi/release/lingui_macro_plugin.wasm') + : '@lingui/swc-plugin'; + + /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, @@ -7,7 +14,7 @@ const nextConfig = { }, experimental: { swcPlugins: [ - ['@lingui/swc-plugin', {}], + [plugin, {}], ], }, }; diff --git a/examples/nextjs-13/package.json b/examples/nextjs/package.json similarity index 62% rename from examples/nextjs-13/package.json rename to examples/nextjs/package.json index 45a04ea..99c2f8a 100644 --- a/examples/nextjs-13/package.json +++ b/examples/nextjs/package.json @@ -4,28 +4,29 @@ "private": true, "scripts": { "dev": "next dev", + "dev:local-binary": "USE_LOCAL_PLUGIN_BINARY=true next dev", "build": "next build", + "build:local-binary": "USE_LOCAL_PLUGIN_BINARY=true next build", "start": "next start", "lint": "next lint", "lingui:extract": "lingui extract" }, "dependencies": { - "@lingui/core": "^4.7.0", - "@lingui/react": "^4.7.0", - "@next/font": "14.1.0", + "@lingui/core": "^4.10.0", + "@lingui/react": "^4.10.0", "@types/node": "18.11.18", "@types/react": "18.0.26", "@types/react-dom": "18.0.10", "make-plural": "^7.2.0", - "next": "14.1.0", + "next": "14.2.2", "react": "18.2.0", "react-dom": "18.2.0", "typescript": "4.9.4" }, "devDependencies": { - "@lingui/cli": "^4.7.0", - "@lingui/loader": "^4.7.0", - "@lingui/macro": "^4.7.0", + "@lingui/cli": "^4.10.0", + "@lingui/loader": "^4.10.0", + "@lingui/macro": "^4.10.0", "@lingui/swc-plugin": "4.0.6" } } diff --git a/examples/nextjs-13/public/favicon.ico b/examples/nextjs/public/favicon.ico similarity index 100% rename from examples/nextjs-13/public/favicon.ico rename to examples/nextjs/public/favicon.ico diff --git a/examples/nextjs-13/src/i18n.ts b/examples/nextjs/src/i18n.ts similarity index 100% rename from examples/nextjs-13/src/i18n.ts rename to examples/nextjs/src/i18n.ts diff --git a/examples/nextjs-13/src/pages/_app.tsx b/examples/nextjs/src/pages/_app.tsx similarity index 100% rename from examples/nextjs-13/src/pages/_app.tsx rename to examples/nextjs/src/pages/_app.tsx diff --git a/examples/nextjs-13/src/pages/index.tsx b/examples/nextjs/src/pages/index.tsx similarity index 100% rename from examples/nextjs-13/src/pages/index.tsx rename to examples/nextjs/src/pages/index.tsx diff --git a/examples/nextjs-13/src/styles/globals.css b/examples/nextjs/src/styles/globals.css similarity index 100% rename from examples/nextjs-13/src/styles/globals.css rename to examples/nextjs/src/styles/globals.css diff --git a/examples/nextjs-13/tsconfig.json b/examples/nextjs/tsconfig.json similarity index 100% rename from examples/nextjs-13/tsconfig.json rename to examples/nextjs/tsconfig.json diff --git a/examples/nextjs-13/yarn.lock b/examples/nextjs/yarn.lock similarity index 92% rename from examples/nextjs-13/yarn.lock rename to examples/nextjs/yarn.lock index b114fd6..11523bc 100644 --- a/examples/nextjs-13/yarn.lock +++ b/examples/nextjs/yarn.lock @@ -397,33 +397,33 @@ "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" -"@lingui/babel-plugin-extract-messages@4.7.0": - version "4.7.0" - resolved "https://registry.yarnpkg.com/@lingui/babel-plugin-extract-messages/-/babel-plugin-extract-messages-4.7.0.tgz#cd1de537750eabf3aaa4855966f903fff6186405" - integrity sha512-CROHpjSqLy71aGDskl5wFk47cCuEAsY1etAt6tDkq0iuHwpSebJpzSN58gQJybRTCqYA+3PTkqCADoeSvcTwRA== +"@lingui/babel-plugin-extract-messages@4.10.0": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@lingui/babel-plugin-extract-messages/-/babel-plugin-extract-messages-4.10.0.tgz#208f0c3dccc8c7ead189a8875ad83c523903a794" + integrity sha512-vhLQLfi1ISSo5vDFDyUoPgjBP6Cy2+7rrQWj9vU4GUEtvxUWNnr0EvrLnRBHjVU4mdrpQi/n7DH5PXuMbveVhA== -"@lingui/cli@4.7.0", "@lingui/cli@^4.7.0": - version "4.7.0" - resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-4.7.0.tgz#3ea0b203271f38f78b7eb6f0f7f72def586f4977" - integrity sha512-XGKGZOE5RF+Q74vCRP5gmiAidhwEbzSPsaZWYIAEuG8Oleo1saXAJJm5iKpoiOOTxl6ME9xp0nfIMmL2NCA1Dw== +"@lingui/cli@4.10.0", "@lingui/cli@^4.10.0": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-4.10.0.tgz#128d1a073b4940977950b59ee2f51e808d0de964" + integrity sha512-gG0Qnv1ExUlN4t/5wMYX9fXD8QilQn6n+gPwmDbWPDPX7zubW8OJADU2PNSSPDsCIzNGW7Hfx/zPwaocn3V8Lw== dependencies: "@babel/core" "^7.21.0" "@babel/generator" "^7.21.1" "@babel/parser" "^7.21.2" "@babel/runtime" "^7.21.0" "@babel/types" "^7.21.2" - "@lingui/babel-plugin-extract-messages" "4.7.0" - "@lingui/conf" "4.7.0" - "@lingui/core" "4.7.0" - "@lingui/format-po" "4.7.0" - "@lingui/message-utils" "4.7.0" + "@lingui/babel-plugin-extract-messages" "4.10.0" + "@lingui/conf" "4.10.0" + "@lingui/core" "4.10.0" + "@lingui/format-po" "4.10.0" + "@lingui/message-utils" "4.10.0" babel-plugin-macros "^3.0.1" chalk "^4.1.0" chokidar "3.5.1" cli-table "0.3.6" commander "^10.0.0" convert-source-map "^2.0.0" - date-fns "^2.16.1" + date-fns "^3.6.0" esbuild "^0.17.10" glob "^7.1.4" inquirer "^7.3.3" @@ -437,10 +437,10 @@ ramda "^0.27.1" source-map "^0.8.0-beta.0" -"@lingui/conf@4.7.0": - version "4.7.0" - resolved "https://registry.yarnpkg.com/@lingui/conf/-/conf-4.7.0.tgz#c088346fa61da698e5f68617501913291cee47fd" - integrity sha512-j5prZL9PEFfQU7jtXrNIAGWB89KQkjEdYENwwdZyWQ9ZJkp8tcNqcYMTtqcU7vMh2lOJdu4WVuvjvnOHMO9RHQ== +"@lingui/conf@4.10.0": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@lingui/conf/-/conf-4.10.0.tgz#f8ebe7bc115051b82bb5823ecb9222fbe28a82c2" + integrity sha512-jHeuCMG25YWEWUQTl1QYz46/RJlQH+Nyx4Qt4uI9OiSXMJ5MiaHopj+Oi9qdI1q2iY0P1RhdwRegBcdET+yF8w== dependencies: "@babel/runtime" "^7.20.13" chalk "^4.1.0" @@ -449,60 +449,60 @@ jiti "^1.17.1" lodash.get "^4.4.2" -"@lingui/core@4.7.0", "@lingui/core@^4.7.0": - version "4.7.0" - resolved "https://registry.yarnpkg.com/@lingui/core/-/core-4.7.0.tgz#27957dd9ed599cedb5bebb2248b4254502e89e2e" - integrity sha512-lr6CMDRztFgS5qna9pLA/MPZRgujN9SCIoQ1LvGZem94U4Qc7ptSwAG1LIET9b3qxRXJm5XOTrq0HefN2Qm1IA== +"@lingui/core@4.10.0", "@lingui/core@^4.10.0": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@lingui/core/-/core-4.10.0.tgz#7944cd49e3f6778f7a7be98f7ab64ccb0ec53b5f" + integrity sha512-KfwkghuCVFt3AxZlAIotTvIcopIpHj4prwG9v6iyrksLXoxKPQMBXutYGl/EIZE1KYQZdR6rjAaoilMl0pSGKA== dependencies: "@babel/runtime" "^7.20.13" - "@lingui/message-utils" "4.7.0" + "@lingui/message-utils" "4.10.0" unraw "^3.0.0" -"@lingui/format-po@4.7.0": - version "4.7.0" - resolved "https://registry.yarnpkg.com/@lingui/format-po/-/format-po-4.7.0.tgz#6d050dba6a5f8da4d3e8ba28836ff4748f26aa64" - integrity sha512-ptUp9nRt6mB9o82O61WzF8c2My/nfMv4cFt+L1oe5XA/+WLDEoOD2eEhu2PLd+/V6rtnnhqQjp3DzoQZ2I/HfA== +"@lingui/format-po@4.10.0": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@lingui/format-po/-/format-po-4.10.0.tgz#f86fbd093f832373ccd129effec31b1047771dc9" + integrity sha512-BhyC5Xmx9yJXFlNAUBboTT+k21sT8EkBW9uPRLaekkCUfYSj6hX+0lz/CJBurIUH/PDZJFucvzYaIIAFnEI4+Q== dependencies: - "@lingui/conf" "4.7.0" - "@lingui/message-utils" "4.7.0" - date-fns "^2.29.3" + "@lingui/conf" "4.10.0" + "@lingui/message-utils" "4.10.0" + date-fns "^3.6.0" pofile "^1.1.4" -"@lingui/loader@^4.7.0": - version "4.7.0" - resolved "https://registry.yarnpkg.com/@lingui/loader/-/loader-4.7.0.tgz#1c45a5a99b28b830823b0b44a6588485942cde0e" - integrity sha512-j3yVbwMMHTBMBs1dikvES/W2V6nKKwnOTnj5dkgMDYRwKLSUPdLU2m1BcG8eIQh6EyPbHgOFosUzVF1tB75TeA== +"@lingui/loader@^4.10.0": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@lingui/loader/-/loader-4.10.0.tgz#7aa49d59da48676cad63e1d8b07b917f01c69242" + integrity sha512-XT7NSwj0MGhOTPEforaghu4mRJLqNYzqovXi8fcbaNFqoexqBgmseNSC2MsKKUpp/tpOLDROjTcE3+XMlrVq3w== dependencies: "@babel/runtime" "^7.20.13" - "@lingui/cli" "4.7.0" - "@lingui/conf" "4.7.0" + "@lingui/cli" "4.10.0" + "@lingui/conf" "4.10.0" -"@lingui/macro@^4.7.0": - version "4.7.0" - resolved "https://registry.yarnpkg.com/@lingui/macro/-/macro-4.7.0.tgz#bbb0c79eece56f95204bc810b7e3585f7e632a4d" - integrity sha512-r2I99yudMJ0pbTySoVmN0l/U4fF7dgsVZZeEpF82jwLwS+ND9dkJswYXUOuF6RPr5oVi2NpkJ0M4ZejDfCAAoA== +"@lingui/macro@^4.10.0": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@lingui/macro/-/macro-4.10.0.tgz#c0c909d318acbb4b2d2792f6c7266fd22a7e9830" + integrity sha512-u+rSqCfQOHPyNwpdq+69LfoOBN6hiQJf0pNOB88kxdVammv4ul9lqnnJW0+hz4gh9POX1jhXjbLf2pStTH1q9w== dependencies: "@babel/runtime" "^7.20.13" "@babel/types" "^7.20.7" - "@lingui/conf" "4.7.0" - "@lingui/core" "4.7.0" - "@lingui/message-utils" "4.7.0" + "@lingui/conf" "4.10.0" + "@lingui/core" "4.10.0" + "@lingui/message-utils" "4.10.0" -"@lingui/message-utils@4.7.0": - version "4.7.0" - resolved "https://registry.yarnpkg.com/@lingui/message-utils/-/message-utils-4.7.0.tgz#48f72b924000fe70e4feb89a13b49cfc41a3a397" - integrity sha512-JrGdxORRzefOh9qAkQYJchh+ehnWlLK9/kOG9x6VkV9aekWLk8vCVbXBh4Q707sTcIgCki8KwT1yuBMwZ2YBEg== +"@lingui/message-utils@4.10.0": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@lingui/message-utils/-/message-utils-4.10.0.tgz#2d575c5f2808b275c56495343b78c0b47d4443e6" + integrity sha512-p9Z4L4//ef1jpwqUR0hnILPbbqhVOXkLktY/EsZ7LMmvn18yhq4FjCtGsrorclTcTdtl0l7bqW4iEpEqGW91Gw== dependencies: "@messageformat/parser" "^5.0.0" js-sha256 "^0.10.1" -"@lingui/react@^4.7.0": - version "4.7.0" - resolved "https://registry.yarnpkg.com/@lingui/react/-/react-4.7.0.tgz#521cc1e21fa9c3830caf962e03f8d2f44397f6be" - integrity sha512-a9SR+U6hobOL+/GPR11gObg9cOzQ4mcGhtUbXQx/WjlWDsau29oXna4vA5pRYiq58dpPXYrsg+ZENsXxNERCwA== +"@lingui/react@^4.10.0": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@lingui/react/-/react-4.10.0.tgz#56dce040659c94c1125640f8e399f68164b44ade" + integrity sha512-QBbgKnIEePbt2ktq/6AVi9q91TRbwvcdrruOMu3qqXBqcF4KMu7rf05M9tvk/cClTjImuOF+FI3k+MX6LGnnYQ== dependencies: "@babel/runtime" "^7.20.13" - "@lingui/core" "4.7.0" + "@lingui/core" "4.10.0" "@lingui/swc-plugin@4.0.6": version "4.0.6" @@ -516,71 +516,77 @@ dependencies: moo "^0.5.1" -"@next/env@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/env/-/env-14.1.0.tgz#43d92ebb53bc0ae43dcc64fb4d418f8f17d7a341" - integrity sha512-Py8zIo+02ht82brwwhTg36iogzFqGLPXlRGKQw5s+qP/kMNc4MAyDeEwBKDijk6zTIbegEgu8Qy7C1LboslQAw== - -"@next/font@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/font/-/font-14.1.0.tgz#6f6c4510e36dad505cf64403f92f235d2838d265" - integrity sha512-9hJ7bEYDI7UGQ1a++5zRD3F2VUu9NIaK5Hro/uL9bvFFs6b0Cy1OdLtLQHCIQE7sSMt8Rbu4VtcbnlubsseelA== - -"@next/swc-darwin-arm64@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.1.0.tgz#70a57c87ab1ae5aa963a3ba0f4e59e18f4ecea39" - integrity sha512-nUDn7TOGcIeyQni6lZHfzNoo9S0euXnu0jhsbMOmMJUBfgsnESdjN97kM7cBqQxZa8L/bM9om/S5/1dzCrW6wQ== - -"@next/swc-darwin-x64@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-14.1.0.tgz#0863a22feae1540e83c249384b539069fef054e9" - integrity sha512-1jgudN5haWxiAl3O1ljUS2GfupPmcftu2RYJqZiMJmmbBT5M1XDffjUtRUzP4W3cBHsrvkfOFdQ71hAreNQP6g== - -"@next/swc-linux-arm64-gnu@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.1.0.tgz#893da533d3fce4aec7116fe772d4f9b95232423c" - integrity sha512-RHo7Tcj+jllXUbK7xk2NyIDod3YcCPDZxj1WLIYxd709BQ7WuRYl3OWUNG+WUfqeQBds6kvZYlc42NJJTNi4tQ== - -"@next/swc-linux-arm64-musl@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.1.0.tgz#d81ddcf95916310b8b0e4ad32b637406564244c0" - integrity sha512-v6kP8sHYxjO8RwHmWMJSq7VZP2nYCkRVQ0qolh2l6xroe9QjbgV8siTbduED4u0hlk0+tjS6/Tuy4n5XCp+l6g== - -"@next/swc-linux-x64-gnu@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.1.0.tgz#18967f100ec19938354332dcb0268393cbacf581" - integrity sha512-zJ2pnoFYB1F4vmEVlb/eSe+VH679zT1VdXlZKX+pE66grOgjmKJHKacf82g/sWE4MQ4Rk2FMBCRnX+l6/TVYzQ== - -"@next/swc-linux-x64-musl@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.1.0.tgz#77077cd4ba8dda8f349dc7ceb6230e68ee3293cf" - integrity sha512-rbaIYFt2X9YZBSbH/CwGAjbBG2/MrACCVu2X0+kSykHzHnYH5FjHxwXLkcoJ10cX0aWCEynpu+rP76x0914atg== - -"@next/swc-win32-arm64-msvc@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.1.0.tgz#5f0b8cf955644104621e6d7cc923cad3a4c5365a" - integrity sha512-o1N5TsYc8f/HpGt39OUQpQ9AKIGApd3QLueu7hXk//2xq5Z9OxmV6sQfNp8C7qYmiOlHYODOGqNNa0e9jvchGQ== - -"@next/swc-win32-ia32-msvc@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.1.0.tgz#21f4de1293ac5e5a168a412b139db5d3420a89d0" - integrity sha512-XXIuB1DBRCFwNO6EEzCTMHT5pauwaSj4SWs7CYnME57eaReAKBXCnkUE80p/pAZcewm7hs+vGvNqDPacEXHVkw== - -"@next/swc-win32-x64-msvc@14.1.0": - version "14.1.0" - resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.1.0.tgz#e561fb330466d41807123d932b365cf3d33ceba2" - integrity sha512-9WEbVRRAqJ3YFVqEZIxUqkiO8l1nool1LmNxygr5HWF8AcSYsEpneUDhmjUVJEzO2A04+oPtZdombzzPPkTtgg== +"@next/env@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/env/-/env-14.2.2.tgz#6c36fe0b04a22ea78bd60a645ae77d53cd16d3ca" + integrity sha512-sk72qRfM1Q90XZWYRoJKu/UWlTgihrASiYw/scb15u+tyzcze3bOuJ/UV6TBOQEeUaxOkRqGeuGUdiiuxc5oqw== + +"@next/font@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/font/-/font-14.2.2.tgz#d0acf1cf664d23a4407356f029c84fc6ac28326b" + integrity sha512-I4GLq5ZsMJHO+WtV3gNhcspvZsbuteUmV56wC28hEsUbtlEawTI0EW4GNVJ8xdK6eRjua7unAt7zAXDgtOvxlw== + +"@next/swc-darwin-arm64@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.2.tgz#55e395b0db6dd5ea2dc92818260ff3a399f1a056" + integrity sha512-3iPgMhzbalizGwHNFUcGnDhFPSgVBHQ8aqSTAMxB5BvJG0oYrDf1WOJZlbXBgunOEj/8KMVbejEur/FpvFsgFQ== + +"@next/swc-darwin-x64@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.2.tgz#f96fb65510be798c03b0432129792c6ac8885bc8" + integrity sha512-x7Afi/jt0ZBRUZHTi49yyej4o8znfIMHO4RvThuoc0P+uli8Jd99y5GKjxoYunPKsXL09xBXEM1+OQy2xEL0Ag== + +"@next/swc-linux-arm64-gnu@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.2.tgz#443f0d4ab9d1aa4338e40f77ca4e182d60e88448" + integrity sha512-zbfPtkk7L41ODMJwSp5VbmPozPmMMQrzAc0HAUomVeVIIwlDGs/UCqLJvLNDt4jpWgc21SjjyIn762lNGrMaUA== + +"@next/swc-linux-arm64-musl@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.2.tgz#182c00b3d2f3ed4eaacdd385d07b230252c64de9" + integrity sha512-wPbS3pI/JU16rm3XdLvvTmlsmm1nd+sBa2ohXgBZcShX4TgOjD4R+RqHKlI1cjo/jDZKXt6OxmcU0Iys0OC/yg== + +"@next/swc-linux-x64-gnu@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.2.tgz#e826a08085dcc61685ff42884ad4032e71ac154f" + integrity sha512-NqWOHqqq8iC9tuHvZxjQ2tX+jWy2X9y8NX2mcB4sj2bIccuCxbIZrU/ThFPZZPauygajZuVQ6zediejQHwZHwQ== + +"@next/swc-linux-x64-musl@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.2.tgz#42f921ca6d93fdfb2b13de70cd8a44ba5526b318" + integrity sha512-lGepHhwb9sGhCcU7999+iK1ZZT+6rrIoVg40MP7DZski9GIZP80wORSbt5kJzh9v2x2ev2lxC6VgwMQT0PcgTA== + +"@next/swc-win32-arm64-msvc@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.2.tgz#9c8f60da8e3882c4c66f21747abf944a627d05ff" + integrity sha512-TZSh/48SfcLEQ4rD25VVn2kdIgUWmMflRX3OiyPwGNXn3NiyPqhqei/BaqCYXViIQ+6QsG9R0C8LftMqy8JPMA== + +"@next/swc-win32-ia32-msvc@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.2.tgz#fdb0b5f74e6dc0dcb34b7f7d24775ad034d915e8" + integrity sha512-M0tBVNMEBJN2ZNQWlcekMn6pvLria7Sa2Fai5znm7CCJz4pP3lrvlSxhKdkCerk0D9E0bqx5yAo3o2Q7RrD4gA== + +"@next/swc-win32-x64-msvc@14.2.2": + version "14.2.2" + resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.2.tgz#95cc0dad2c7ac5177fa6eeab070dccfa30532353" + integrity sha512-a/20E/wtTJZ3Ykv3f/8F0l7TtgQa2LWHU2oNB9bsu0VjqGuGGHmm/q6waoUNQYTVPYrrlxxaHjJcDV6aiSTt/w== "@sinclair/typebox@^0.25.16": version "0.25.24" resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.25.24.tgz#8c7688559979f7079aacaf31aa881c3aa410b718" integrity sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ== -"@swc/helpers@0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.2.tgz#85ea0c76450b61ad7d10a37050289eded783c27d" - integrity sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw== +"@swc/counter@^0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@swc/counter/-/counter-0.1.3.tgz#cc7463bd02949611c6329596fccd2b0ec782b0e9" + integrity sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ== + +"@swc/helpers@0.5.5": + version "0.5.5" + resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.5.tgz#12689df71bfc9b21c4f4ca00ae55f2f16c8b77c0" + integrity sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A== dependencies: + "@swc/counter" "^0.1.3" tslib "^2.4.0" "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": @@ -933,10 +939,10 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.1.tgz#841b532c45c758ee546a11d5bd7b7b473c8c30b9" integrity sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw== -date-fns@^2.16.1, date-fns@^2.29.3: - version "2.29.3" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8" - integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA== +date-fns@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-3.6.0.tgz#f20ca4fe94f8b754951b24240676e8618c0206bf" + integrity sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww== debug@^4.1.0: version "4.3.4" @@ -1360,28 +1366,28 @@ nanoid@^3.3.6: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g== -next@14.1.0: - version "14.1.0" - resolved "https://registry.yarnpkg.com/next/-/next-14.1.0.tgz#b31c0261ff9caa6b4a17c5af019ed77387174b69" - integrity sha512-wlzrsbfeSU48YQBjZhDzOwhWhGsy+uQycR8bHAOt1LY1bn3zZEcDyHQOEoN3aWzQ8LHCAJ1nqrWCc9XF2+O45Q== +next@14.2.2: + version "14.2.2" + resolved "https://registry.yarnpkg.com/next/-/next-14.2.2.tgz#707311b5e4bf973ada2305233f322bdd0cd9d579" + integrity sha512-oGwUaa2bCs47FbuxWMpOoXtBMPYpvTPgdZr3UAo+pu7Ns00z9otmYpoeV1HEiYL06AlRQQIA/ypK526KjJfaxg== dependencies: - "@next/env" "14.1.0" - "@swc/helpers" "0.5.2" + "@next/env" "14.2.2" + "@swc/helpers" "0.5.5" busboy "1.6.0" caniuse-lite "^1.0.30001579" graceful-fs "^4.2.11" postcss "8.4.31" styled-jsx "5.1.1" optionalDependencies: - "@next/swc-darwin-arm64" "14.1.0" - "@next/swc-darwin-x64" "14.1.0" - "@next/swc-linux-arm64-gnu" "14.1.0" - "@next/swc-linux-arm64-musl" "14.1.0" - "@next/swc-linux-x64-gnu" "14.1.0" - "@next/swc-linux-x64-musl" "14.1.0" - "@next/swc-win32-arm64-msvc" "14.1.0" - "@next/swc-win32-ia32-msvc" "14.1.0" - "@next/swc-win32-x64-msvc" "14.1.0" + "@next/swc-darwin-arm64" "14.2.2" + "@next/swc-darwin-x64" "14.2.2" + "@next/swc-linux-arm64-gnu" "14.2.2" + "@next/swc-linux-arm64-musl" "14.2.2" + "@next/swc-linux-x64-gnu" "14.2.2" + "@next/swc-linux-x64-musl" "14.2.2" + "@next/swc-win32-arm64-msvc" "14.2.2" + "@next/swc-win32-ia32-msvc" "14.2.2" + "@next/swc-win32-x64-msvc" "14.2.2" node-releases@^2.0.6: version "2.0.8" diff --git a/package.json b/package.json index 63ad0fb..06e704a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingui/swc-plugin", - "version": "4.0.6", + "version": "4.0.7", "description": "A SWC Plugin for LinguiJS", "author": { "name": "Timofei Iatsenko", @@ -28,7 +28,6 @@ "prepublishOnly": "cargo build-wasi --release" }, "files": [], - "packageManager": "yarn@3.3.1", "peerDependencies": { "@lingui/macro": "4" }, From 691c25a707aa0aca483c3526891df66658a2463a Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Tue, 9 Jul 2024 16:03:47 +0300 Subject: [PATCH 04/17] chore: version 5.0.0-next.0 (#97) --- Cargo.lock | 2 +- Cargo.toml | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ffb46bc..41105f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -537,7 +537,7 @@ checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "lingui_macro_plugin" -version = "4.0.7" +version = "5.0.0-next.0" dependencies = [ "data-encoding", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 3cc9b32..dd0ebff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lingui_macro_plugin" -version = "4.0.7" +version = "5.0.0-next.0" edition = "2021" [lib] diff --git a/package.json b/package.json index 06e704a..face07e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingui/swc-plugin", - "version": "4.0.7", + "version": "5.0.0-next.0", "description": "A SWC Plugin for LinguiJS", "author": { "name": "Timofei Iatsenko", From 254176305f1ee573eb5f709b744936f775e7662e Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Fri, 2 Aug 2024 13:36:31 +0200 Subject: [PATCH 05/17] fix trimming of nbsp in the jsx child --- src/jsx_visitor.rs | 7 +++++-- src/tests/jsx_icu.rs | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/jsx_visitor.rs b/src/jsx_visitor.rs index e2c697b..df8ed0f 100644 --- a/src/jsx_visitor.rs +++ b/src/jsx_visitor.rs @@ -32,6 +32,9 @@ static WORD_OPTION: Lazy = Lazy::new(|| Regex::new(r"_(\w+)").unwrap()); // const pluralRuleRe = /(_[\d\w]+|zero|one|two|few|many|other)/ // const jsx2icuExactChoice = (value: string) => value.replace(/_(\d+)/, "=$1").replace(/_(\w+)/, "$1") +static TRIM_START: Lazy = Lazy::new(|| Regex::new(r"^[ ]+").unwrap()); +static TRIM_END: Lazy = Lazy::new(|| Regex::new(r"[ ]+$").unwrap()); + // taken from babel repo -> packages/babel-types/src/utils/react/cleanJSXElementLiteralChild.ts fn clean_jsx_element_literal_child(value: &str) -> String { let lines: Vec<&str> = value.split('\n').collect(); @@ -55,12 +58,12 @@ fn clean_jsx_element_literal_child(value: &str) -> String { // trim whitespace touching a newline if !is_first_line { - trimmed_line = trimmed_line.trim_start().to_string(); + trimmed_line = TRIM_START.replace(&trimmed_line, "").to_string(); } // trim whitespace touching an endline if !is_last_line { - trimmed_line = trimmed_line.trim_end().to_string(); + trimmed_line = TRIM_END.replace(&trimmed_line, "").to_string();; } if !trimmed_line.is_empty() { diff --git a/src/tests/jsx_icu.rs b/src/tests/jsx_icu.rs index 4b81e9d..28c3774 100644 --- a/src/tests/jsx_icu.rs +++ b/src/tests/jsx_icu.rs @@ -389,3 +389,20 @@ to!( "# ); +to!( + multiple_new_lines_with_nbsp_endind, + r#" +import { Trans } from "@lingui/react/macro"; + + Line ending in non-breaking space.  + text in element +; + "#, + + r#" +import { Trans } from "@lingui/react"; +text in element"} id={"CJuEhi"} components={{ + 0: +}}/>; + "# +); From ceb449f6dc80195bbbe104df9ac3c5fa9628c2cd Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Thu, 18 Apr 2024 09:40:24 +0200 Subject: [PATCH 06/17] feature: use-lingui --- src/ast_utils.rs | 27 ++- src/js_macro_folder.rs | 5 +- src/lib.rs | 357 +++++++++++++++++++++++++++--------- src/macro_utils.rs | 130 +++++++------ src/options.rs | 28 ++- src/tests/imports.rs | 39 ++-- src/tests/js_icu.rs | 42 ++--- src/tests/js_t.rs | 62 +++---- src/tests/jsx.rs | 102 +++++------ src/tests/jsx_icu.rs | 66 ++++--- src/tests/mod.rs | 1 + src/tests/runtime_config.rs | 13 +- src/tests/use_lingui.rs | 254 +++++++++++++++++++++++++ 13 files changed, 805 insertions(+), 321 deletions(-) create mode 100644 src/tests/use_lingui.rs diff --git a/src/ast_utils.rs b/src/ast_utils.rs index a5ea976..582dd0c 100644 --- a/src/ast_utils.rs +++ b/src/ast_utils.rs @@ -18,6 +18,27 @@ pub fn get_jsx_attr<'a>(el: &'a JSXOpeningElement, name: &str) -> Option<&'a JSX return None; } +// get_local_ident_from_object_pat_prop(prop, "t") +// const {t} = useLingui() // => Ident("t") +// const {t: _} = useLingui() // => Ident("_") +pub fn get_local_ident_from_object_pat_prop(prop: &ObjectPatProp, imported_symbol: &str) -> Option { + return match prop { + ObjectPatProp::KeyValue(key_value) + if key_value.key.as_ident().is_some_and(|ident| ident.sym == imported_symbol.to_string()) => + { + Some(key_value.value.as_ident().unwrap().clone()) + } + ObjectPatProp::Assign(assign) + if assign.key.sym == imported_symbol.to_string() => + { + Some(assign.key.clone()) + } + _ => { + None + } + } +} + pub fn get_jsx_attr_value_as_string(val: &JSXAttrValue) -> Option { match val { // offset="5" @@ -146,15 +167,15 @@ pub fn create_key_value_prop(key: &str, value: Box) -> PropOrSpread { ))); } -pub fn create_import(source: JsWord, specifier: Ident) -> ModuleItem { +pub fn create_import(source: JsWord, imported: Ident, local: Ident) -> ModuleItem { ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { span: DUMMY_SP, phase: ImportPhase::default(), specifiers: vec![ ImportSpecifier::Named(ImportNamedSpecifier { span: DUMMY_SP, - local: specifier, - imported: None, + local, + imported: Some(ModuleExportName::Ident(imported)), is_type_only: false, }) ], diff --git a/src/js_macro_folder.rs b/src/js_macro_folder.rs index de8598c..a92ce61 100644 --- a/src/js_macro_folder.rs +++ b/src/js_macro_folder.rs @@ -63,9 +63,8 @@ impl<'a> JsMacroFolder<'a> { span: DUMMY_SP, obj: callee_obj.unwrap_or_else(|| { self.ctx.should_add_18n_import = true; - let (_, i18n_export) = &self.ctx.options.runtime_modules.i18n; - return Box::new(Ident::new(i18n_export.clone().into(), DUMMY_SP).into()); + return Box::new(self.ctx.runtime_idents.i18n.clone().into()); }), prop: MemberProp::Ident(Ident::new("_".into(), DUMMY_SP)), }).as_callee(), @@ -198,6 +197,6 @@ impl<'a> Fold for JsMacroFolder<'a> { ); } - expr + expr.fold_children_with(self) } } diff --git a/src/lib.rs b/src/lib.rs index 44a6e78..819210b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,35 +1,55 @@ +#![feature(is_some_and)] + use std::collections::HashSet; +use swc_core::common::DUMMY_SP; + +use swc_core::plugin::errors::HANDLER; use swc_core::{ ecma::{ - utils::quote_ident, ast::*, + utils::quote_ident, visit::{Fold, FoldWith, VisitWith}, }, plugin::{ - metadata::TransformPluginMetadataContextKind, - plugin_transform, + metadata::TransformPluginMetadataContextKind, plugin_transform, proxies::TransformPluginProgramMetadata, }, }; -mod tests; -mod builder; -mod tokens; mod ast_utils; -mod macro_utils; -mod jsx_visitor; +mod builder; +mod generate_id; mod js_macro_folder; +mod jsx_visitor; +mod macro_utils; mod options; -mod generate_id; +mod tests; +mod tokens; -use builder::*; +use crate::generate_id::*; +use crate::macro_utils::*; +use crate::options::*; use ast_utils::*; +use builder::*; use js_macro_folder::JsMacroFolder; use jsx_visitor::TransJSXVisitor; -use crate::macro_utils::{*}; -use crate::options::{*}; -use crate::generate_id::{*}; +pub struct IdentReplacer { + from: Id, + to: Ident, +} +impl IdentReplacer { + // pub fn new(from: Id, to: Ident) -> {} +} +impl Fold for IdentReplacer { + fn fold_ident(&mut self, n: Ident) -> Ident { + if n.to_id() == self.from { + return self.to.clone(); + } + + n + } +} #[derive(Default)] pub struct LinguiMacroFolder { @@ -38,7 +58,7 @@ pub struct LinguiMacroFolder { } impl LinguiMacroFolder { - pub fn new(options: LinguiOptions) -> LinguiMacroFolder { + pub fn new(options: LinguiOptions) -> LinguiMacroFolder { LinguiMacroFolder { has_lingui_macro_imports: false, ctx: MacroCtx::new(options), @@ -56,56 +76,45 @@ impl LinguiMacroFolder { el.visit_children_with(&mut trans_visitor); } - let parsed = MessageBuilder::parse(trans_visitor.tokens); - let id_attr = get_jsx_attr(&el.opening, "id"); + let parsed = MessageBuilder::parse(trans_visitor.tokens); + let id_attr = get_jsx_attr(&el.opening, "id"); - let context_attr_val = get_jsx_attr(&el.opening, "context") - .and_then(|attr| attr.value.as_ref()) - .and_then(|value| get_jsx_attr_value_as_string(value)); + let context_attr_val = get_jsx_attr(&el.opening, "context") + .and_then(|attr| attr.value.as_ref()) + .and_then(|value| get_jsx_attr_value_as_string(value)); - let mut attrs = vec![ - create_jsx_attribute( - "message".into(), - parsed.message, - ), - ]; + let mut attrs = vec![create_jsx_attribute("message".into(), parsed.message)]; - if !id_attr.is_some() { - attrs.push(create_jsx_attribute( - "id", - generate_message_id( - &parsed.message_str, - &context_attr_val.unwrap_or_default() - ).into(), - )); - } + if !id_attr.is_some() { + attrs.push(create_jsx_attribute( + "id", + generate_message_id(&parsed.message_str, &context_attr_val.unwrap_or_default()) + .into(), + )); + } - if let Some(exp) = parsed.values { - attrs.push(create_jsx_attribute( - "values", - exp, - )); - } + if let Some(exp) = parsed.values { + attrs.push(create_jsx_attribute("values", exp)); + } - if let Some(exp) = parsed.components { - attrs.push(create_jsx_attribute( - "components", - exp, - )); + if let Some(exp) = parsed.components { + attrs.push(create_jsx_attribute("components", exp)); } - attrs.extend( - pick_jsx_attrs(el.opening.attrs, HashSet::from(["id", "render", "i18n"])) - ); + attrs.extend(pick_jsx_attrs( + el.opening.attrs, + HashSet::from(["id", "render", "i18n"]), + )); if self.ctx.options.strip_non_essential_fields { - attrs = pick_jsx_attrs(attrs, HashSet::from(["id", "render", "i18n", "values", "components"])) + attrs = pick_jsx_attrs( + attrs, + HashSet::from(["id", "render", "i18n", "values", "components"]), + ) } self.ctx.should_add_trans_import = true; - let (_, trans_export) = self.ctx.options.runtime_modules.trans.clone(); - return JSXElement { span: el.span, children: vec![], @@ -113,23 +122,143 @@ impl LinguiMacroFolder { opening: JSXOpeningElement { self_closing: true, span: el.opening.span, - name: JSXElementName::Ident( - Ident::new(trans_export.into(), el.opening.span) - ), + name: JSXElementName::Ident(self.ctx.runtime_idents.trans.clone().into()), type_args: None, attrs, }, }; } + + pub fn handle_use_lingui(&mut self, n: BlockStmt) -> BlockStmt { + let mut ctx = self.ctx.clone(); + + let mut ident_replacer: Option = None; + + let stmts: Vec = n + .stmts + .into_iter() + .map(|stmt| { + return match stmt { + Stmt::Decl(Decl::Var(var_decl)) => { + let decl = *var_decl; + + let underscore_ident = quote_ident!("$__"); + let decls: Vec = decl.decls.into_iter().map(|declarator| { + if let Some(init) = &declarator.init { + let expr = init.as_ref(); + + if let Expr::Call(call) = &expr { + if match_callee_name(call, |n| { + self.ctx.is_lingui_ident("useLingui", n) + }) + .is_some() + { + if let Pat::Object(obj_pat) = declarator.name { + let mut new_props: Vec = + obj_pat.props.into_iter().map(|prop| { + return get_local_ident_from_object_pat_prop(&prop, "t") + .and_then(|ident| { + ctx.register_reference( + &"t".into(), + &ident.to_id(), + ); + + let new_i18n_ident = quote_ident!(ident.span, "$__i18n"); + + ident_replacer = Some(IdentReplacer { + from: ident.to_id(), + to: underscore_ident.clone(), + }); + + self.ctx.should_add_uselingui_import = true; + ctx.runtime_idents.i18n = new_i18n_ident.clone(); + + return Some(ObjectPatProp::KeyValue( + KeyValuePatProp { + value: Box::new(Pat::Ident(new_i18n_ident.into())), + key: PropName::Ident(quote_ident!("i18n")), + }, + )) + }) + .unwrap_or(prop); + }).collect(); + + new_props.push(ObjectPatProp::KeyValue( + KeyValuePatProp { + value: Box::new(Pat::Ident(underscore_ident.clone().into())), + key: PropName::Ident(quote_ident!("_")), + }, + )); + + return VarDeclarator { + init: Some(Box::new(Expr::Call(CallExpr { + callee: Callee::Expr(Box::new(Expr::Ident(ctx.runtime_idents.use_lingui.clone()))), + ..call.clone() + }))), + + definite: true, + span: declarator.span, + name: Pat::Object(ObjectPat { + optional: false, + type_ann: None, + span: DUMMY_SP, + props: new_props + + }), + } + } else { + HANDLER.with(|h| { + h.struct_span_warn(decl.span, "Unsupported Syntax") + .note( +r#"You have to destructure `t` when using the `useLingui` macro, i.e: + const { t } = useLingui() + or + const { t: _ } = useLingui()"#) + .emit() + }); + } + } + } + } + + return declarator; + }).collect(); + + return Stmt::Decl(Decl::Var(Box::new(VarDecl { + span: decl.span, + decls, + declare: false, + kind: decl.kind, + }))) + } + _ => stmt, + }; + }) + .collect(); + + let mut block = BlockStmt { + span: n.span, + stmts, + }; + + // use lingui matched above + if ident_replacer.is_some() { + block = block + .fold_children_with(&mut JsMacroFolder::new(&mut ctx)) + // replace other + .fold_children_with(&mut ident_replacer.unwrap()); + } + + return block.fold_children_with(self); + } } impl<'a> Fold for LinguiMacroFolder { fn fold_module_items(&mut self, mut n: Vec) -> Vec { - let mut has_i18n_import = false; - let mut has_trans_import = false; - let (i18n_source, i18n_export) = self.ctx.options.runtime_modules.i18n.clone(); let (trans_source, trans_export) = self.ctx.options.runtime_modules.trans.clone(); + let (use_lingui_source, use_lingui_export) = + self.ctx.options.runtime_modules.use_lingui.clone(); let mut insert_index: usize = 0; let mut index = 0; @@ -137,45 +266,96 @@ impl<'a> Fold for LinguiMacroFolder { n.retain(|m| { if let ModuleItem::ModuleDecl(ModuleDecl::Import(imp)) = m { // drop macro imports - if &imp.src.value == "@lingui/macro" || &imp.src.value == "@lingui/core/macro" || &imp.src.value == "@lingui/react/macro" { + if &imp.src.value == "@lingui/macro" + || &imp.src.value == "@lingui/core/macro" + || &imp.src.value == "@lingui/react/macro" + { self.has_lingui_macro_imports = true; self.ctx.register_macro_import(imp); insert_index = index; return false; } + } - if &imp.src.value == &i18n_source && !imp.type_only { - for spec in &imp.specifiers { - if let ImportSpecifier::Named(spec) = spec { - has_i18n_import = if !has_i18n_import { &spec.local.sym == &i18n_export } else { true }; - } - } - } + index += 1; + true + }); - if &imp.src.value == &trans_source && !imp.type_only { - for spec in &imp.specifiers { - if let ImportSpecifier::Named(spec) = spec { - has_trans_import = if !has_trans_import { &spec.local.sym == &trans_export } else { true }; - } - } - } + n = n.fold_children_with(self); + + if self.ctx.should_add_18n_import { + n.insert( + insert_index, + create_import( + i18n_source.into(), + quote_ident!(i18n_export[..]), + self.ctx.runtime_idents.i18n.clone(), + ), + ); + } + + if self.ctx.should_add_trans_import { + n.insert( + insert_index, + create_import( + trans_source.into(), + quote_ident!(trans_export[..]), + self.ctx.runtime_idents.trans.clone(), + ), + ); + } + + if self.ctx.should_add_uselingui_import { + n.insert( + insert_index, + create_import( + use_lingui_source.into(), + quote_ident!(use_lingui_export[..]), + self.ctx.runtime_idents.use_lingui.clone(), + ), + ); + } + + n + } + fn fold_arrow_expr(&mut self, n: ArrowExpr) -> ArrowExpr { + // If no package that we care about is imported, skip the following + // transformation logic. + if !self.has_lingui_macro_imports { + return n; + } + + let mut func = n; + + if func.body.is_block_stmt() { + let block = func.body.block_stmt().unwrap(); + + func = ArrowExpr { + body: Box::new(BlockStmtOrExpr::BlockStmt(self.handle_use_lingui(block))), + ..func } + } - index +=1; - true - }); + func.fold_children_with(self) + } - n = n.fold_children_with(self); + fn fold_function(&mut self, n: Function) -> Function { + // If no package that we care about is imported, skip the following + // transformation logic. + if !self.has_lingui_macro_imports { + return n; + } - if !has_i18n_import && self.ctx.should_add_18n_import { - n.insert(insert_index, create_import(i18n_source.into(), quote_ident!(i18n_export[..]))); - } + let mut func = n; - if !has_trans_import && self.ctx.should_add_trans_import { - n.insert(insert_index, create_import(trans_source.into(), quote_ident!(trans_export[..]))); - } + if let Some(body) = func.body { + func = Function { + body: Some(self.handle_use_lingui(body)), + ..func + }; + } - n + func.fold_children_with(self) } fn fold_expr(&mut self, expr: Expr) -> Expr { @@ -187,9 +367,7 @@ impl<'a> Fold for LinguiMacroFolder { let mut folder = JsMacroFolder::new(&mut self.ctx); - folder - .fold_expr(expr) - .fold_children_with(self) + folder.fold_expr(expr).fold_children_with(self) } fn fold_call_expr(&mut self, expr: CallExpr) -> CallExpr { @@ -201,9 +379,7 @@ impl<'a> Fold for LinguiMacroFolder { let mut folder = JsMacroFolder::new(&mut self.ctx); - folder - .fold_call_expr(expr) - .fold_children_with(self) + folder.fold_call_expr(expr).fold_children_with(self) } fn fold_jsx_element(&mut self, mut el: JSXElement) -> JSXElement { @@ -231,7 +407,6 @@ impl<'a> Fold for LinguiMacroFolder { } } - #[plugin_transform] pub fn process_transform(program: Program, metadata: TransformPluginProgramMetadata) -> Program { let config = serde_json::from_str::( @@ -239,7 +414,7 @@ pub fn process_transform(program: Program, metadata: TransformPluginProgramMetad .get_transform_plugin_config() .expect("failed to get plugin config for lingui-plugin"), ) - .expect("invalid config for lingui-plugin"); + .expect("invalid config for lingui-plugin"); let config = config.to_options( &metadata diff --git a/src/macro_utils.rs b/src/macro_utils.rs index ade55e8..0ca93f3 100644 --- a/src/macro_utils.rs +++ b/src/macro_utils.rs @@ -1,26 +1,42 @@ -use std::collections::HashMap; use crate::ast_utils::*; use crate::tokens::*; -use swc_core::{ - ecma::{ - ast::*, - atoms::JsWord - }, -}; use crate::LinguiOptions; +use std::collections::{HashMap, HashSet}; +use swc_core::ecma::{ast::*, atoms::JsWord}; +use swc_core::ecma::utils::quote_ident; const LINGUI_T: &str = &"t"; -#[derive(Default)] +#[derive(Default, Clone)] pub struct MacroCtx { // export name -> local name - imports_id_map: HashMap, + symbol_to_id_map: HashMap>, // local name -> export name - imports_id_map_inverted: HashMap, + id_to_symbol_map: HashMap, pub should_add_18n_import: bool, pub should_add_trans_import: bool, + pub should_add_uselingui_import: bool, + pub options: LinguiOptions, + pub runtime_idents: RuntimeIdents, +} + +#[derive(Clone)] +pub struct RuntimeIdents { + pub i18n: Ident, + pub trans: Ident, + pub use_lingui: Ident, +} + +impl Default for RuntimeIdents { + fn default() -> RuntimeIdents { + RuntimeIdents { + i18n: quote_ident!("$_i18n"), + trans: quote_ident!("Trans_"), + use_lingui: quote_ident!("$_useLingui"), + } + } } impl MacroCtx { @@ -33,29 +49,29 @@ impl MacroCtx { /// is given ident exported from @lingui/macro? and one of choice functions? fn is_lingui_fn_choice_cmp(&self, ident: &Ident) -> bool { - self.is_lingui_ident("plural", ident) || - self.is_lingui_ident("select", ident) || - self.is_lingui_ident("selectOrdinal", ident) + // self.symbol_to_id_map. + self.is_lingui_ident("plural", ident) + || self.is_lingui_ident("select", ident) + || self.is_lingui_ident("selectOrdinal", ident) } /// is given ident exported from @lingui/macro? pub fn is_lingui_ident(&self, name: &str, ident: &Ident) -> bool { - if let Some(imp) = self.imports_id_map.get(&name.into()) { - return ident.to_id() == *imp; - } - - false + self.symbol_to_id_map + .get(&name.into()) + .and_then(|refs| refs.get(&ident.to_id())) + .is_some() } pub fn is_define_message_ident(&self, ident: &Ident) -> bool { - return self.is_lingui_ident("defineMessage", &ident) - || self.is_lingui_ident("msg", &ident) + return self.is_lingui_ident("defineMessage", &ident) + || self.is_lingui_ident("msg", &ident); } /// given import {plural as i18nPlural} from "@lingui/macro"; /// get_ident_export_name("i18nPlural") would return `plural` pub fn get_ident_export_name(&self, ident: &Ident) -> Option<&JsWord> { - if let Some(name) = self.imports_id_map_inverted.get(&ident.to_id()) { + if let Some(name) = self.id_to_symbol_map.get(&ident.to_id()) { return Some(name); } @@ -63,21 +79,27 @@ impl MacroCtx { } pub fn is_lingui_jsx_choice_cmp(&self, ident: &Ident) -> bool { - self.is_lingui_ident("Plural", ident) || - self.is_lingui_ident("Select", ident) || - self.is_lingui_ident("SelectOrdinal", ident) + self.is_lingui_ident("Plural", ident) + || self.is_lingui_ident("Select", ident) + || self.is_lingui_ident("SelectOrdinal", ident) } + pub fn register_reference(&mut self, symbol: &JsWord, id: &Id) { + self.symbol_to_id_map + .entry(symbol.clone()) + .or_default() + .insert(id.clone()); + + self.id_to_symbol_map + .insert(id.clone(), symbol.clone()); + } pub fn register_macro_import(&mut self, imp: &ImportDecl) { for spec in &imp.specifiers { if let ImportSpecifier::Named(spec) = spec { if let Some(ModuleExportName::Ident(ident)) = &spec.imported { - self.imports_id_map.insert(ident.sym.clone(), spec.local.to_id()); - self.imports_id_map_inverted.insert(spec.local.to_id(), ident.sym.clone()); + self.register_reference(&ident.sym, &spec.local.to_id()); } else { - self.imports_id_map.insert(spec.local.sym.clone(), spec.local.to_id()); - self.imports_id_map_inverted.insert(spec.local.to_id(), spec.local.sym.clone()); - + self.register_reference(&spec.local.sym, &spec.local.to_id()); } } } @@ -88,7 +110,12 @@ impl MacroCtx { pub fn is_lingui_t_call_expr(&self, callee_expr: &Box) -> (bool, Option>) { match callee_expr.as_ref() { // t(i18n)... - Expr::Call(call) if matches!(match_callee_name(call, |n| self.is_lingui_ident(LINGUI_T, n)), Some(_)) => { + Expr::Call(call) + if matches!( + match_callee_name(call, |n| self.is_lingui_ident(LINGUI_T, n)), + Some(_) + ) => + { if let Some(v) = call.args.get(0) { (true, Some(v.expr.clone())) } else { @@ -96,12 +123,8 @@ impl MacroCtx { } } // t.. - Expr::Ident(ident) if self.is_lingui_ident(LINGUI_T, &ident) => { - (true, None) - } - _ => { - (false, None) - } + Expr::Ident(ident) if self.is_lingui_ident(LINGUI_T, &ident) => (true, None), + _ => (false, None), } } @@ -163,24 +186,16 @@ impl MacroCtx { pub fn try_tokenize_expr(&self, expr: &Box) -> Option> { match expr.as_ref() { // String Literal: "has # friend" - Expr::Lit(Lit::Str(str)) => { - Some(vec!(MsgToken::String(str.clone().value.to_string()))) - } + Expr::Lit(Lit::Str(str)) => Some(vec![MsgToken::String(str.clone().value.to_string())]), // Template Literal: `${name} has # friend` - Expr::Tpl(tpl) => { - Some(self.tokenize_tpl(tpl)) - } + Expr::Tpl(tpl) => Some(self.tokenize_tpl(tpl)), // ParenthesisExpression: ("has # friend") - Expr::Paren(ParenExpr { expr, .. }) => { - self.try_tokenize_expr(expr) - } + Expr::Paren(ParenExpr { expr, .. }) => self.try_tokenize_expr(expr), // Call Expression: {one: plural(numArticles, {...})} - Expr::Call(expr) => { - self.try_tokenize_call_expr_as_choice_cmp(expr) - } - _ => None + Expr::Call(expr) => self.try_tokenize_call_expr_as_choice_cmp(expr), + _ => None, } } @@ -206,7 +221,11 @@ impl MacroCtx { /// receive ObjectLiteral {few: "..", many: "..", other: ".."} and create tokens /// If messages passed as TemplateLiterals with variables, it extracts variables - pub fn get_choice_cases_from_obj(&self, props: &Vec, icu_format: &str) -> Vec { + pub fn get_choice_cases_from_obj( + &self, + props: &Vec, + icu_format: &str, + ) -> Vec { // todo: there might be more props then real choices. Id for example let mut choices: Vec = Vec::with_capacity(props.len()); @@ -221,13 +240,11 @@ impl MacroCtx { // todo: panic offset might be only a number, other forms is not supported } } else { - let tokens = self.try_tokenize_expr(&prop.value) - .unwrap_or(vec!(MsgToken::Expression(prop.value.clone()))); + let tokens = self + .try_tokenize_expr(&prop.value) + .unwrap_or(vec![MsgToken::Expression(prop.value.clone())]); - choices.push(CaseOrOffset::Case(ChoiceCase { - tokens, - key, - })); + choices.push(CaseOrOffset::Case(ChoiceCase { tokens, key })); } } } else { @@ -241,3 +258,4 @@ impl MacroCtx { choices } } + diff --git a/src/options.rs b/src/options.rs index 67fe389..bdea51c 100644 --- a/src/options.rs +++ b/src/options.rs @@ -18,12 +18,14 @@ struct RuntimeModulesConfig( pub struct RuntimeModulesConfigMap { i18n: Option, trans: Option, + use_lingui: Option, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct RuntimeModulesConfigMapNormalized { pub i18n: (String, String), pub trans: (String, String), + pub use_lingui: (String, String), } impl LinguiJsOptions { @@ -51,12 +53,22 @@ impl LinguiJsOptions { .and_then(|o| o.1.clone()) .unwrap_or("Trans".into()), ), + use_lingui: ( + self.runtime_modules.as_ref() + .and_then(|o| o.use_lingui.as_ref()) + .and_then(|o| Some(o.0.clone())) + .unwrap_or("@lingui/react".into()), + self.runtime_modules.as_ref() + .and_then(|o| o.use_lingui.as_ref()) + .and_then(|o| o.1.clone()) + .unwrap_or("useLingui".into()), + ), }, } } } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct LinguiOptions { pub strip_non_essential_fields: bool, pub runtime_modules: RuntimeModulesConfigMapNormalized, @@ -69,6 +81,7 @@ impl Default for LinguiOptions { runtime_modules: RuntimeModulesConfigMapNormalized { i18n: ("@lingui/core".into(), "i18n".into()), trans: ("@lingui/react".into(), "Trans".into()), + use_lingui: ("@lingui/react".into(), "useLingui".into()), }, } } @@ -83,8 +96,9 @@ mod lib_tests { let config = serde_json::from_str::( r#"{ "runtimeModules": { - "i18n": ["@lingui/core", "i18n"], - "trans": ["@lingui/react", "Trans"] + "i18n": ["my-core", "myI18n"], + "trans": ["my-react", "myTrans"], + "useLingui": ["my-react", "myUseLingui"] } }"# ) @@ -92,8 +106,9 @@ mod lib_tests { assert_eq!(config, LinguiJsOptions { runtime_modules: Some(RuntimeModulesConfigMap { - i18n: Some(RuntimeModulesConfig("@lingui/core".into(), Some("i18n".into()))), - trans: Some(RuntimeModulesConfig("@lingui/react".into(), Some("Trans".into()))), + i18n: Some(RuntimeModulesConfig("my-core".into(), Some("myI18n".into()))), + trans: Some(RuntimeModulesConfig("my-react".into(), Some("myTrans".into()))), + use_lingui: Some(RuntimeModulesConfig("my-react".into(), Some("myUseLingui".into()))), }) }) } @@ -113,6 +128,7 @@ mod lib_tests { runtime_modules: Some(RuntimeModulesConfigMap { i18n: Some(RuntimeModulesConfig("@lingui/core".into(), None)), trans: None, + use_lingui: None, }) }) } diff --git a/src/tests/imports.rs b/src/tests/imports.rs index 2e17c38..ea18046 100644 --- a/src/tests/imports.rs +++ b/src/tests/imports.rs @@ -1,7 +1,7 @@ use crate::{to}; to!( - should_not_add_extra_imports, + should_add_not_clashing_imports, r#" import { t } from "@lingui/core/macro"; import { Plural } from "@lingui/react/macro"; @@ -13,15 +13,17 @@ to!( Untouched "#, r#" + import { Trans as Trans_ } from "@lingui/react"; + import { i18n as $_i18n } from "@lingui/core"; import { i18n } from "@lingui/core"; import { Trans } from "@lingui/react"; - i18n._({ + $_i18n._({ id: "NnH3pK", message: "Test" }); - - ;; + ;; "# ); to!( @@ -196,9 +199,9 @@ to!( r#" "use client"; - import { i18n } from "@lingui/core"; + import { i18n as $_i18n } from "@lingui/core"; import foo from "bar"; - i18n._({ + $_i18n._({ id: "xeiujy", message: "Text" }); diff --git a/src/tests/js_icu.rs b/src/tests/js_icu.rs index 03ea96e..3ebd8db 100644 --- a/src/tests/js_icu.rs +++ b/src/tests/js_icu.rs @@ -21,22 +21,22 @@ to!( }) "#, r#" - import { i18n } from "@lingui/core"; - const messagePlural = i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + const messagePlural = $_i18n._({ id: "V/M0Vc", message: "{count, plural, one {# Book} other {# Books}}", values: { count: count } }); - const messageSelect = i18n._({ + const messageSelect = $_i18n._({ id: "VRptzI", message: "{gender, select, male {he} female {she} other {they}}", values: { gender: gender } }); - const messageSelectOrdinal = i18n._({ + const messageSelectOrdinal = $_i18n._({ id: "Q9Q8Bj", message: "{count, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}", values: { @@ -58,9 +58,9 @@ to!( }) "#, r#" - import { i18n } from "@lingui/core"; + import { i18n as $_i18n } from "@lingui/core"; - const messagePlural = i18n._({ + const messagePlural = $_i18n._({ id: "2y/Fr5", message: "{count, plural, one {# Book} other {# Books} few {# Books}}", values: { @@ -86,8 +86,8 @@ const messageSelect = select(gender, { }) "#, r#" -import { i18n } from "@lingui/core"; -const messagePlural = i18n._({ +import { i18n as $_i18n } from "@lingui/core"; +const messagePlural = $_i18n._({ id: "l6reUi", message: "{count, plural, one {{0}} other {{variable}}}", values: { @@ -96,7 +96,7 @@ const messagePlural = i18n._({ 0: foo.bar } }); -const messageSelect = i18n._({ +const messageSelect = $_i18n._({ id: "M4Fisk", message: "{gender, select, male {he} female {{variable}} third {{0}} other {{1}}}", values: { @@ -137,8 +137,8 @@ to!( }) "#, r#" - import { i18n } from "@lingui/core"; - const message = i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + const message = $_i18n._({ id: "CvuUwE", message: "{count, plural, one {{name} has # friend} other {{name} has # friends}}", values: { @@ -160,9 +160,9 @@ to!( }) "#, r#" - import { i18n } from "@lingui/core"; + import { i18n as $_i18n } from "@lingui/core"; - const message = i18n._({ + const message = $_i18n._({ id: "tK7kAV", message: "{count, plural, one {{name} has {count} friend} other {{name} has {count} friends}}", values: { @@ -185,9 +185,9 @@ to!( })} cat` "#, r#" - import { i18n } from "@lingui/core"; + import { i18n as $_i18n } from "@lingui/core"; - i18n._({ + $_i18n._({ id: "LF3Ndn", message: "This is my {count, selectordinal, one {st} two {nd} other {rd}} cat", values: { @@ -213,8 +213,8 @@ const message = plural(numBooks, { }) "#, r#" -import { i18n } from "@lingui/core" -const message = i18n._({ +import { i18n as $_i18n } from "@lingui/core" +const message = $_i18n._({ id: "AA3wsz", message: "{numBooks, plural, one {{numArticles, plural, one {1 book and 1 article} other {1 book and {numArticles} articles}}} other {{numArticles, plural, one {{numBooks} books and 1 article} other {{numBooks} books and {numArticles} articles}}}}", values: { @@ -237,8 +237,8 @@ to!( }); "#, r#" - import { i18n } from "@lingui/core"; - i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + $_i18n._({ id: "CF5t+7", message: "{0, plural, offset:1 =0 {No books} =1 {1 book} other {# books}}", values: { @@ -259,8 +259,8 @@ to!( }); "#, r#" - import { i18n } from "@lingui/core"; - i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + $_i18n._({ id: "QHtFym", message: "{value, select, offset {..} any {..} other {..}}", values: { diff --git a/src/tests/js_t.rs b/src/tests/js_t.rs index 5a664f3..8b8373a 100644 --- a/src/tests/js_t.rs +++ b/src/tests/js_t.rs @@ -38,8 +38,8 @@ to!( "#, // output after transform r#" - import { i18n } from "@lingui/core"; - i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + $_i18n._({ id: "EsCV2T", message: "Refresh inbox" }); @@ -60,12 +60,12 @@ to!( "#, // output after transform r#" - import { i18n } from "@lingui/core"; - i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + $_i18n._({ id: "EsCV2T", message: "Refresh inbox" }); - i18n._({ + $_i18n._({ id: "JPS+Xq", message: "Refresh {foo} inbox {bar}", values: { @@ -73,7 +73,7 @@ to!( bar: bar } }); - i18n._({ + $_i18n._({ id: "xplbye", message: "Refresh {0} inbox {bar}", values: { @@ -81,7 +81,7 @@ to!( 0: foo.bar } }); - i18n._({ + $_i18n._({ id: "+NCjg/", message: "Refresh {0}", values: { @@ -100,8 +100,8 @@ to!( "#, // output after transform r#" - import { i18n } from "@lingui/core"; - i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + $_i18n._({ id: "YZhODz", message: "Refresh {foo} inbox {foo}", values: { @@ -173,8 +173,8 @@ to!( string`; "#, r#" - import { i18n } from "@lingui/core"; - i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + $_i18n._({ id: "amQF7O", message: "Multiline\n string" }); @@ -189,8 +189,8 @@ to!( string`; "#, r#" - import { i18n } from "@lingui/core"; - i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + $_i18n._({ id: "d1nA7b", message: "Multiline string" }); @@ -204,12 +204,12 @@ to!( t`Bienvenue\xA0!` "#, r#" - import { i18n } from "@lingui/core"; - i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + $_i18n._({ id: "dZXeyN", message: "Message " }); - i18n._({ + $_i18n._({ id: "9K3RGd", message: "Bienvenue !" }); @@ -222,8 +222,8 @@ to!( const msg = t({ message: `Hello ${name}`, id: 'msgId', comment: 'description for translators' }) "#, r#" - import { i18n } from "@lingui/core"; - const msg = i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + const msg = $_i18n._({ id: "msgId", message: "Hello {name}", values: { @@ -240,9 +240,9 @@ to!( const msg = message.error(t({message: "dasd"})) "#, r#" - import { i18n } from "@lingui/core"; + import { i18n as $_i18n } from "@lingui/core"; const msg = message.error( - i18n._( + $_i18n._( { id: "9ZMZjU", message: "dasd", @@ -266,12 +266,12 @@ to!( }) "#, r#" - import { i18n } from "@lingui/core"; - const msg1 = i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + const msg1 = $_i18n._({ id: "xDAtGP" }); - const msg2 = i18n._({ + const msg2 = $_i18n._({ id: "msgId", values: { name: name, @@ -306,8 +306,8 @@ to!( const msg = t({ id: 'msgId', comment: 'description for translators', message: plural(val, { one: '...', other: '...' }) }) "#, r#" - import { i18n } from "@lingui/core"; - const msg = i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + const msg = $_i18n._({ id: "msgId", message: "{val, plural, one {...} other {...}}", values: { @@ -324,8 +324,8 @@ to!( const msg = t({ id: `msgId` }) "#, r#" - import { i18n } from "@lingui/core"; - const msg = i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + const msg = $_i18n._({ id: "msgId" }); "# @@ -341,16 +341,16 @@ to!( t({ message: 'Ola', context: `My Context`}) "#, r#" - import { i18n } from "@lingui/core"; - i18n._({ + import { i18n as $_i18n } from "@lingui/core"; + $_i18n._({ id: "l1LkPs", message: "Ola" }); - i18n._({ + $_i18n._({ id: "7hFP9A", message: "Ola" }); - i18n._({ + $_i18n._({ id: "7hFP9A", message: "Ola" }); diff --git a/src/tests/jsx.rs b/src/tests/jsx.rs index 163dfa4..da239d4 100644 --- a/src/tests/jsx.rs +++ b/src/tests/jsx.rs @@ -9,10 +9,10 @@ const exp2 = Refresh inbox; const exp3 =

Refresh inbox
; "#, r#" -import { Trans } from "@lingui/react"; +import { Trans as Trans_ } from "@lingui/react"; const exp1 = Refresh inbox; -const exp2 = ; -const exp3 =
; +const exp2 = ; +const exp3 =
; "# ); @@ -23,8 +23,8 @@ import { Trans } from "@lingui/macro"; const exp2 = Refresh inbox; "#, r#" -import { Trans } from "@lingui/react"; -const exp2 = ; +import { Trans as Trans_ } from "@lingui/react"; +const exp2 = ; "# ); @@ -35,8 +35,8 @@ to!( const exp2 = Refresh inbox; "#, r#" - import { Trans } from "@lingui/react"; - const exp2 = + import { Trans as Trans_ } from "@lingui/react"; + const exp2 = "# ); @@ -48,9 +48,9 @@ to!( const exp2 = Refresh inbox; "#, r#" - import { Trans } from "@lingui/react"; - const exp1 = ; - const exp2 = ; + import { Trans as Trans_ } from "@lingui/react"; + const exp1 = ; + const exp2 = ; "# ); @@ -61,8 +61,8 @@ to!( const exp2 = v}>Refresh inbox; "#, r#" - import { Trans } from "@lingui/react"; - const exp2 = v} /> + import { Trans as Trans_ } from "@lingui/react"; + const exp2 = v} /> "# ); @@ -80,8 +80,8 @@ to!( ; "#, r#" - import { Trans } from "@lingui/react"; - "#, r#" - import { Trans } from "@lingui/react"; - World!<1/><2>My name is <3> <4>{name}"} id={"k9gsHO"} values={{ @@ -134,8 +134,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - {`Hello ${foo} and ${bar}`} "#, r#" - import { Trans } from "@lingui/react"; - ; @@ -167,9 +167,9 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - ; - ; + import { Trans as Trans_ } from "@lingui/react"; + ; + ; "# ); @@ -183,8 +183,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - This should work  "} id={"K/1Xpr"} + import { Trans as Trans_ } from "@lingui/react"; + This should work  "} id={"K/1Xpr"} components={{ 0: , }} @@ -199,8 +199,8 @@ to!( & "#, r#" - import { Trans } from "@lingui/react"; - ; + import { Trans as Trans_ } from "@lingui/react"; + ; "# ); @@ -212,8 +212,8 @@ to!( {Component inside expression container}; "#, r#" - import { Trans } from "@lingui/react"; - Component inside expression container"} id={"1cZQQW"} components={{ @@ -230,8 +230,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - "} id={"SCJtqt"} components={{ + import { Trans as Trans_ } from "@lingui/react"; + "} id={"SCJtqt"} components={{ 0:
}} />; "# @@ -245,8 +245,8 @@ to!( // {...spread} // "#, // r#" -// import { Trans } from "@lingui/react"; -// {...spread} +// import { Trans as Trans_ } from "@lingui/react"; +// {...spread}
// "# // ); @@ -261,8 +261,8 @@ to!(
"#, r#" - import { Trans } from "@lingui/react"; - ; "# @@ -280,8 +280,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - forced spaces!"} id={"Ud4KOf"} components={{ + import { Trans as Trans_ } from "@lingui/react"; + forced spaces!"} id={"Ud4KOf"} components={{ 0: }} />; "# @@ -299,8 +299,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - ; + import { Trans as Trans_ } from "@lingui/react"; + ; "# ); @@ -312,10 +312,10 @@ to!( Read more "#, r#" - import { Trans } from "@lingui/react"; - import { i18n } from "@lingui/core"; - more"} id={"QZyANg"} components={{ - 0: more"} id={"QZyANg"} components={{ + 0: Hello {/* and I cannot stress this enough */} World; "#, r#" - import { Trans } from "@lingui/react"; - ; + import { Trans as Trans_ } from "@lingui/react"; + ; "# ); @@ -375,8 +375,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - }} id="msg.hello" @@ -399,9 +399,9 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; + import { Trans as Trans_ } from "@lingui/react"; - Next.js say hi. And <1>Next.js say hi." } diff --git a/src/tests/jsx_icu.rs b/src/tests/jsx_icu.rs index 28c3774..f266b28 100644 --- a/src/tests/jsx_icu.rs +++ b/src/tests/jsx_icu.rs @@ -19,12 +19,12 @@ other="Messages" "#, r#" -import { Trans } from "@lingui/react"; +import { Trans as Trans_ } from "@lingui/react"; -const ex1 = ; -const ex2 =
; @@ -45,9 +45,9 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; + import { Trans as Trans_ } from "@lingui/react"; - # slot added} other {<1># slots added}}"} id={"X8eyr1"} + import { Trans as Trans_ } from "@lingui/react"; + # slot added} other {<1># slots added}}"} id={"X8eyr1"} values={{ count: count }} components={{ @@ -175,8 +175,8 @@ import { Trans, Plural } from '@lingui/macro'; "#, r#" - import { Trans } from "@lingui/react"; - # slot added} other {<1># slots added}}"} id={"bDgQmM"} values={{ @@ -203,8 +203,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - A lot of them}}"} + import { Trans as Trans_ } from "@lingui/react"; + A lot of them}}"} id={"ZFknU1"} values={{ count: count @@ -227,8 +227,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - Other}}"} id={"Imwef9"} values={{ + import { Trans as Trans_ } from "@lingui/react"; + Other}}"} id={"Imwef9"} values={{ count: count }} components={{ 0: @@ -274,8 +274,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - Other}}"} id={"/7RSeH"} values={{ + import { Trans as Trans_ } from "@lingui/react"; + Other}}"} id={"/7RSeH"} values={{ count: count, variable: variable, 0: foo.bar @@ -302,14 +302,12 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - Other}}"} id={"4jX4Bx"} values={{ - count: count - }} components={{ - 0: - }} - render={(v) => v} - />; + import { Trans as Trans_ } from "@lingui/react"; + Other}}"} id={"4jX4Bx"} values={{ + count: count + }} components={{ + 0: + }} render={(v)=>v}/>; "# ); @@ -327,7 +325,7 @@ to!( // "#, // // r#" -// import { Trans } from "@lingui/react"; +// import { Trans as Trans_ } from "@lingui/react"; // Other}}"} values={{ // count: count // }} components={{ @@ -352,8 +350,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - ; "# @@ -379,8 +377,8 @@ to!( "#, r#" - import { Trans } from "@lingui/react"; - }} id="custom.id" diff --git a/src/tests/mod.rs b/src/tests/mod.rs index ccc5ad9..7d7a1ac 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -6,3 +6,4 @@ mod jsx_icu; mod js_define_message; mod imports; mod runtime_config; +mod use_lingui; diff --git a/src/tests/runtime_config.rs b/src/tests/runtime_config.rs index d9cb80f..878241f 100644 --- a/src/tests/runtime_config.rs +++ b/src/tests/runtime_config.rs @@ -23,7 +23,8 @@ to!( LinguiOptions { runtime_modules: RuntimeModulesConfigMapNormalized { i18n: ("./custom-core".into(), "customI18n".into()), - trans: ("./custom-react".into(), "CustomTrans".into()) + trans: ("./custom-react".into(), "CustomTrans".into()), + use_lingui: ("./custom-react".into(), "useLingui2".into()) }, ..Default::default() }, @@ -35,14 +36,12 @@ to!( const exp2 = Refresh inbox; "#, r#" - import { CustomTrans } from "./custom-react"; - import { customI18n } from "./custom-core"; - - customI18n._({ + import { CustomTrans as Trans_ } from "./custom-react"; + import { customI18n as $_i18n } from "./custom-core"; + $_i18n._({ id: "EsCV2T", message: "Refresh inbox" }); - - const exp2 = ; + const exp2 = ; "# ); diff --git a/src/tests/use_lingui.rs b/src/tests/use_lingui.rs new file mode 100644 index 0000000..9da57e3 --- /dev/null +++ b/src/tests/use_lingui.rs @@ -0,0 +1,254 @@ +use crate::{to}; + +to!( + js_use_lingui_hook, + // input + r#" + import { useLingui } from "@lingui/react/macro"; + + const bla1 = () => { + console.log() + } + + function bla() { + const { t, i18n } = useLingui(); + t`Refresh inbox`; + } + "#, + // output after transform + r#" + import { useLingui as $_useLingui } from "@lingui/react"; + + const bla1 = ()=>{ + console.log(); + }; + + function bla() { + const { i18n: $__i18n, i18n, _: $__ } = $_useLingui(); + + $__i18n._({ + id: "EsCV2T", + message: "Refresh inbox" + }); + } + "# +); + +to!( + support_renamed_destructuring, + // input + r#" +import { useLingui } from '@lingui/react/macro'; + +function MyComponent() { + const { t: _ } = useLingui(); + const a = _`Text`; +} + "#, + // output after transform + r#" +import { useLingui as $_useLingui } from "@lingui/react"; +function MyComponent() { + const { i18n: $__i18n, _: $__ } = $_useLingui(); + const a = $__i18n._({ + id: "xeiujy", + message: "Text" + }); +} + "# +); + +to!( + should_process_macro_with_matching_name_in_correct_scopes, + // input + r#" +import { useLingui } from '@lingui/react/macro'; + +function MyComponent() { + const { t } = useLingui(); + const a = t`Text`; + + { + // here is child scope with own "t" binding, shouldn't be processed + const t = () => {}; + t`Text`; + } + { + // here is child scope which should be processed, since 't' relates to outer scope + t`Text`; + } +} + "#, + // output after transform + r#" +import { useLingui as $_useLingui } from "@lingui/react"; +function MyComponent() { + const { i18n: $__i18n, _: $__ } = $_useLingui(); + const a = $__i18n._({ + id: "xeiujy", + message: "Text" + }); + { + const t = ()=>{}; + t`Text`; + } + { + $__i18n._({ + id: "xeiujy", + message: "Text" + }); + } +} + "# +); + +to!( + support_nested_macro, + // input + r#" +import { useLingui } from '@lingui/react/macro'; +import { plural } from '@lingui/core/macro'; + +function MyComponent() { + const { t } = useLingui(); + const a = t`Text ${plural(users.length, { + offset: 1, + 0: "No books", + 1: "1 book", + other: "\# books" + })}`; +} + "#, + // output after transform + r#" +import { useLingui as $_useLingui } from "@lingui/react"; +function MyComponent() { + const { i18n: $__i18n, _: $__ } = $_useLingui(); + const a = $__i18n._({ + id: "hJRCh6", + message: "Text {0, plural, offset:1 =0 {No books} =1 {1 book} other {# books}}", + values: { + 0: users.length + } + }); +} + "# +); + +to!( + support_passing_t_variable_as_dependency, + // input + r#" +import { useLingui } from '@lingui/react/macro'; + +function MyComponent() { + const { t } = useLingui(); + const a = useMemo(() => t`Text`, [t]); +} + "#, + // output after transform + r#" +import { useLingui as $_useLingui } from "@lingui/react"; +function MyComponent() { + const { i18n: $__i18n, _: $__ } = $_useLingui(); + const a = useMemo(()=>$__i18n._({ + id: "xeiujy", + message: "Text" + }), [ + $__ + ]); +} + "# +); + +to!( + work_with_existing_use_lingui_statement, + // input + r#" +import { useLingui as useLinguiMacro } from '@lingui/react/macro'; +import { useLingui } from '@lingui/react'; + +function MyComponent() { + const { _ } = useLingui(); + + console.log(_); + const { t } = useLinguiMacro(); + const a = t`Text`; +} + "#, + // output after transform + r#" +import { useLingui as $_useLingui } from "@lingui/react"; +import { useLingui } from '@lingui/react'; +function MyComponent() { + const { _ } = useLingui(); + console.log(_); + const { i18n: $__i18n, _: $__ } = $_useLingui(); + const a = $__i18n._({ + id: "xeiujy", + message: "Text" + }); +} + "# +); + + +to!( + work_with_multiple_react_components, + // input + r#" +import { useLingui } from '@lingui/react/macro'; + +function MyComponent() { + const { t } = useLingui(); + const a = t`Text`; +} + +function MyComponent2() { + const { t } = useLingui(); + const b = t`Text`; +} + "#, + // output after transform + r#" +import { useLingui as $_useLingui } from "@lingui/react"; +function MyComponent() { + const { i18n: $__i18n, _: $__ } = $_useLingui(); + const a = $__i18n._({ + id: "xeiujy", + message: "Text" + }); +} +function MyComponent2() { + const { i18n: $__i18n, _: $__ } = $_useLingui(); + const b = $__i18n._({ + id: "xeiujy", + message: "Text" + }); +} + "# +); + +to!( + work_with_components_defined_as_arrow_function, + // input + r#" +import { useLingui } from '@lingui/react/macro'; + +const MyComponent = () => { + const { t } = useLingui(); + const a = t`Text`; +} + "#, + // output after transform + r#" +import { useLingui as $_useLingui } from "@lingui/react"; +const MyComponent = ()=>{ + const { i18n: $__i18n, _: $__ } = $_useLingui(); + const a = $__i18n._({ + id: "xeiujy", + message: "Text" + }); +}; + "# +); From c9ddb846d2df54665fb5a57620ec75579a1b5211 Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Tue, 6 Aug 2024 14:35:40 +0200 Subject: [PATCH 07/17] chore: update rust version (#100) --- .github/workflows/ci.yml | 2 +- CONTRIBUTING.md | 2 + Cargo.lock | 4 +- rust-toolchain | 2 +- src/jsx_visitor.rs | 148 +++++++++++++++++---------------------- src/lib.rs | 2 - src/tests/jsx_icu.rs | 48 +++++-------- 7 files changed, 87 insertions(+), 121 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75806aa..688b4a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: stable + toolchain: nightly-2024-07-21 override: true - uses: Swatinem/rust-cache@v2 - uses: actions-rs/cargo@v1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5025210..94cf5e2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,3 +48,5 @@ module.exports = nextConfig; It's important to build a plugin with the same Rust version used to build SWC itself. This project uses `rust-toolchain` file in the root of project to define rust version. + +To update Rust, put new version into `rust-toolchain` and call `rustup update` command \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 41105f5..a994390 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,9 +29,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom", "once_cell", diff --git a/rust-toolchain b/rust-toolchain index 49a8e2a..bc6c996 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2023-03-20 +nightly-2024-07-21 diff --git a/src/jsx_visitor.rs b/src/jsx_visitor.rs index df8ed0f..a98a18e 100644 --- a/src/jsx_visitor.rs +++ b/src/jsx_visitor.rs @@ -1,15 +1,13 @@ -use swc_core::ecma::{ - visit::{Visit, VisitWith}, -}; -use swc_core::ecma::ast::{*}; -use swc_core::common::DUMMY_SP; use crate::ast_utils::{get_jsx_attr, get_jsx_attr_value_as_string}; -use crate::tokens::{IcuChoice, ChoiceCase, CaseOrOffset, MsgToken, TagOpening}; -use regex::{Regex}; +use crate::macro_utils::MacroCtx; +use crate::tokens::{CaseOrOffset, ChoiceCase, IcuChoice, MsgToken, TagOpening}; use once_cell::sync::Lazy; +use regex::Regex; +use swc_core::common::DUMMY_SP; +use swc_core::ecma::ast::*; use swc_core::ecma::atoms::JsWord; +use swc_core::ecma::visit::{Visit, VisitWith}; use swc_core::plugin::errors::HANDLER; -use crate::macro_utils::{ MacroCtx}; pub struct TransJSXVisitor<'a> { pub tokens: Vec, @@ -20,12 +18,13 @@ impl<'a> TransJSXVisitor<'a> { pub fn new(ctx: &'a MacroCtx) -> TransJSXVisitor<'a> { TransJSXVisitor { tokens: Vec::new(), - ctx + ctx, } } } -static PLURAL_OPTIONS_WHITELIST: Lazy = Lazy::new(|| Regex::new(r"(_[\d\w]+|zero|one|two|few|many|other)").unwrap()); +static PLURAL_OPTIONS_WHITELIST: Lazy = + Lazy::new(|| Regex::new(r"(_[\d\w]+|zero|one|two|few|many|other)").unwrap()); static NUM_OPTION: Lazy = Lazy::new(|| Regex::new(r"_(\d+)").unwrap()); static WORD_OPTION: Lazy = Lazy::new(|| Regex::new(r"_(\w+)").unwrap()); @@ -37,45 +36,45 @@ static TRIM_END: Lazy = Lazy::new(|| Regex::new(r"[ ]+$").unwrap()); // taken from babel repo -> packages/babel-types/src/utils/react/cleanJSXElementLiteralChild.ts fn clean_jsx_element_literal_child(value: &str) -> String { - let lines: Vec<&str> = value.split('\n').collect(); - let mut last_non_empty_line = 0; + let lines: Vec<&str> = value.split('\n').collect(); + let mut last_non_empty_line = 0; - for (i, line) in lines.iter().enumerate() { - if line.trim().len() > 0 { - last_non_empty_line = i; + for (i, line) in lines.iter().enumerate() { + if line.trim().len() > 0 { + last_non_empty_line = i; + } } - } - let mut result = String::new(); + let mut result = String::new(); - for (i, line) in lines.iter().enumerate() { - let is_first_line = i == 0; - let is_last_line = i == lines.len() - 1; - let is_last_non_empty_line = i == last_non_empty_line; + for (i, line) in lines.iter().enumerate() { + let is_first_line = i == 0; + let is_last_line = i == lines.len() - 1; + let is_last_non_empty_line = i == last_non_empty_line; - // replace rendered whitespace tabs with spaces - let mut trimmed_line = line.replace("\t", " "); + // replace rendered whitespace tabs with spaces + let mut trimmed_line = line.replace("\t", " "); - // trim whitespace touching a newline - if !is_first_line { - trimmed_line = TRIM_START.replace(&trimmed_line, "").to_string(); - } + // trim whitespace touching a newline + if !is_first_line { + trimmed_line = TRIM_START.replace(&trimmed_line, "").to_string(); + } - // trim whitespace touching an endline - if !is_last_line { - trimmed_line = TRIM_END.replace(&trimmed_line, "").to_string();; - } + // trim whitespace touching an endline + if !is_last_line { + trimmed_line = TRIM_END.replace(&trimmed_line, "").to_string(); + } - if !trimmed_line.is_empty() { - if !is_last_non_empty_line { - trimmed_line.push(' '); - } + if !trimmed_line.is_empty() { + if !is_last_non_empty_line { + trimmed_line.push(' '); + } - result.push_str(&trimmed_line); + result.push_str(&trimmed_line); + } } - } - result + result } fn is_allowed_plural_option(key: &str) -> Option { @@ -114,12 +113,14 @@ impl<'a> TransJSXVisitor<'a> { tokens.push(MsgToken::String(string)); } - JSXAttrValue::JSXExprContainer(JSXExprContainer { expr: JSXExpr::Expr(exp), .. }) => { + JSXAttrValue::JSXExprContainer(JSXExprContainer { + expr: JSXExpr::Expr(exp), + .. + }) => { match exp.as_ref() { // some={"# books"} - Expr::Lit(Lit::Str(str)) => { - tokens.push(MsgToken::String(str.value.clone().to_string())) - } + Expr::Lit(Lit::Str(str)) => tokens + .push(MsgToken::String(str.value.clone().to_string())), // some={`# books ${name}`} Expr::Tpl(tpl) => { tokens.extend(self.ctx.tokenize_tpl(tpl)); @@ -132,9 +133,7 @@ impl<'a> TransJSXVisitor<'a> { tokens.extend(visitor.tokens) } - _ => { - tokens.push(MsgToken::Expression(exp.clone())) - } + _ => tokens.push(MsgToken::Expression(exp.clone())), } } @@ -143,11 +142,7 @@ impl<'a> TransJSXVisitor<'a> { } } - choices.push(CaseOrOffset::Case( - ChoiceCase { - tokens, - key, - })) + choices.push(CaseOrOffset::Case(ChoiceCase { tokens, key })) } } } @@ -174,21 +169,18 @@ impl<'a> Visit for TransJSXVisitor<'a> { if self.ctx.is_lingui_jsx_choice_cmp(&ident) { let value = match get_jsx_attr(&el, "value").and_then(|attr| attr.value.as_ref()) { - Some( - JSXAttrValue::JSXExprContainer( - JSXExprContainer { expr: JSXExpr::Expr(exp), .. } - ) - ) => { - exp.clone() - } - _ => { - Box::new(Expr::Lit(Lit::Null(Null { - span: DUMMY_SP - }))) - } + Some(JSXAttrValue::JSXExprContainer(JSXExprContainer { + expr: JSXExpr::Expr(exp), + .. + })) => exp.clone(), + _ => Box::new(Expr::Lit(Lit::Null(Null { span: DUMMY_SP }))), }; - let icu_method = self.ctx.get_ident_export_name(ident).unwrap().to_lowercase(); + let icu_method = self + .ctx + .get_ident_export_name(ident) + .unwrap() + .to_lowercase(); let choices = self.visit_icu_macro(el, &icu_method); self.tokens.push(MsgToken::IcuChoice(IcuChoice { @@ -214,25 +206,21 @@ impl<'a> Visit for TransJSXVisitor<'a> { } fn visit_jsx_closing_element(&mut self, _el: &JSXClosingElement) { - self.tokens.push( - MsgToken::TagClosing - ); + self.tokens.push(MsgToken::TagClosing); } fn visit_jsx_text(&mut self, el: &JSXText) { - - self.tokens.push( - MsgToken::String(clean_jsx_element_literal_child(&el.raw.to_string())) - ); + self.tokens + .push(MsgToken::String(clean_jsx_element_literal_child( + &el.raw.to_string(), + ))); } fn visit_jsx_expr_container(&mut self, cont: &JSXExprContainer) { if let JSXExpr::Expr(exp) = &cont.expr { match exp.as_ref() { Expr::Lit(Lit::Str(str)) => { - self.tokens.push( - MsgToken::String(str.value.to_string()) - ); + self.tokens.push(MsgToken::String(str.value.to_string())); } // todo write tests and validate @@ -241,9 +229,7 @@ impl<'a> Visit for TransJSXVisitor<'a> { if let Some(tokens) = self.ctx.try_tokenize_call_expr_as_choice_cmp(call) { self.tokens.extend(tokens); } else { - self.tokens.push( - MsgToken::Expression(exp.clone()) - ); + self.tokens.push(MsgToken::Expression(exp.clone())); } } @@ -252,18 +238,12 @@ impl<'a> Visit for TransJSXVisitor<'a> { } Expr::Tpl(tpl) => { - self.tokens.extend( - self.ctx.tokenize_tpl(tpl) - ); + self.tokens.extend(self.ctx.tokenize_tpl(tpl)); } _ => { - self.tokens.push( - MsgToken::Expression(exp.clone()) - ); + self.tokens.push(MsgToken::Expression(exp.clone())); } } } } } - - diff --git a/src/lib.rs b/src/lib.rs index 819210b..839b2b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -#![feature(is_some_and)] - use std::collections::HashSet; use swc_core::common::DUMMY_SP; diff --git a/src/tests/jsx_icu.rs b/src/tests/jsx_icu.rs index f266b28..78dc8cb 100644 --- a/src/tests/jsx_icu.rs +++ b/src/tests/jsx_icu.rs @@ -1,8 +1,8 @@ -use crate::{to}; +use crate::to; to!( jsx_icu, - r#" + r#" import { Plural } from "@lingui/react/macro"; const ex1 = "#, - r#" import { Trans as Trans_ } from "@lingui/react"; @@ -33,7 +32,7 @@ const ex2 =
"#, - r#" import { Trans as Trans_ } from "@lingui/react"; @@ -57,7 +55,7 @@ to!( to!( jsx_plural_preserve_reserved_attrs, - r#" + r#" import { Plural } from "@lingui/react/macro"; "#, - r#" import { Trans as Trans_ } from "@lingui/react"; @@ -84,7 +81,7 @@ to!( to!( jsx_icu_nested, - r#" + r#" import { Plural, Trans } from "@lingui/react/macro"; @@ -96,7 +93,6 @@ to!( /> "#, - r#" import { Trans as Trans_ } from "@lingui/react"; @@ -110,7 +106,7 @@ to!( to!( jsx_trans_inside_plural, - r#" + r#" import { Trans, Plural } from '@lingui/macro'; ; "#, - r#" import { Trans as Trans_ } from "@lingui/react"; # slot added} other {<1># slots added}}"} id={"X8eyr1"} @@ -142,7 +137,7 @@ to!( to!( jsx_multivelel_nesting, - r#" + r#" import { Trans, Plural } from '@lingui/macro'; ; "#, - r#" import { Trans as Trans_ } from "@lingui/react"; A lot of them} />; "#, - r#" import { Trans as Trans_ } from "@lingui/react"; A lot of them}}"} @@ -216,7 +209,7 @@ to!( to!( jsx_icu_with_template_literal, - r#" + r#" import { Plural } from "@lingui/react/macro"; ; "#, - r#" import { Trans as Trans_ } from "@lingui/react"; Other} />; "#, - r#" import { Trans as Trans_ } from "@lingui/react"; Other}}"} id={"Imwef9"} values={{ @@ -262,7 +253,7 @@ to!( to!( jsx_select_with_expressions_in_cases, - r#" + r#" import { Select } from '@lingui/macro'; Other} />; "#, - r#" import { Trans as Trans_ } from "@lingui/react"; Other}}"} id={"4jX4Bx"} values={{ @@ -337,7 +326,7 @@ to!( to!( jsx_select_ordinal_with_offset_and_exact_matches, - r#" + r#" import { SelectOrdinal } from "@lingui/react/macro"; ; "#, - r#" import { Trans as Trans_ } from "@lingui/react"; A lot of them} /> "#, - r#" import { Trans as Trans_ } from "@lingui/react"; Line ending in non-breaking space.  text in element ; "#, - r#" -import { Trans } from "@lingui/react"; -text in element"} id={"CJuEhi"} components={{ +import { Trans as Trans_ } from "@lingui/react"; +text in element"} id={"CJuEhi"} components={{ 0: }}/>; "# From 35094f34297251c80dcda0378b3829d77591d7e0 Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Wed, 7 Aug 2024 12:02:54 +0300 Subject: [PATCH 08/17] fix: errors after merging main --- src/ast_utils.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ast_utils.rs b/src/ast_utils.rs index b3db754..582dd0c 100644 --- a/src/ast_utils.rs +++ b/src/ast_utils.rs @@ -186,6 +186,5 @@ pub fn create_import(source: JsWord, imported: Ident, local: Ident) -> ModuleIte }), with: None, type_only: false, - phase: Default::default(), })) } From 4ce3a31dae634d66e7dd0d1285b87635f03855d4 Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Wed, 7 Aug 2024 12:21:56 +0300 Subject: [PATCH 09/17] chore: version 5.0.0-next.1 (#101) --- Cargo.lock | 2 +- Cargo.toml | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a994390..19c6ceb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -537,7 +537,7 @@ checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "lingui_macro_plugin" -version = "5.0.0-next.0" +version = "5.0.0-next.1" dependencies = [ "data-encoding", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index dd0ebff..4cac664 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lingui_macro_plugin" -version = "5.0.0-next.0" +version = "5.0.0-next.1" edition = "2021" [lib] diff --git a/package.json b/package.json index face07e..7b5e028 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingui/swc-plugin", - "version": "5.0.0-next.0", + "version": "5.0.0-next.1", "description": "A SWC Plugin for LinguiJS", "author": { "name": "Timofei Iatsenko", From 56aca4d250375876b20da0adf3a3e0af6b73dfe3 Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Wed, 7 Aug 2024 14:21:54 +0300 Subject: [PATCH 10/17] ci: fix release (#102) --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++-- .github/workflows/release.yml | 13 +++++++++--- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e0e0b8..8e752e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,13 +12,21 @@ on: - 'README.md' - 'LICENSE' +env: + TOOLCHAIN: nightly-2024-07-21 + jobs: check: name: Check runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.TOOLCHAIN }} + targets: wasm32-wasi + - uses: Swatinem/rust-cache@v2 - name: Run cargo check @@ -30,11 +38,36 @@ jobs: needs: check steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: - toolchain: nightly-2024-07-21 + toolchain: ${{ env.TOOLCHAIN }} + targets: wasm32-wasi - uses: Swatinem/rust-cache@v2 - name: Run cargo test run: cargo test + + test-publish: + name: Test Publish + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.TOOLCHAIN }} + targets: wasm32-wasi + + - uses: Swatinem/rust-cache@v2 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + registry-url: 'https://registry.npmjs.org' + node-version: 16.x + + - name: Publish Dry Run + run: npm publish --dry-run diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6136ed7..26cc3bc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,19 +4,26 @@ on: release: types: [released, prereleased] +env: + TOOLCHAIN: nightly-2024-07-21 + jobs: release: name: Release runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - name: Set up Node 14 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.TOOLCHAIN }} + targets: wasm32-wasi + + - name: Set up Node uses: actions/setup-node@v4 with: registry-url: 'https://registry.npmjs.org' - node-version: 14.x + node-version: 16.x - uses: Swatinem/rust-cache@v2 From 05dcef1fa0ecfb5caa5c339621dae612606c00ca Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Thu, 15 Aug 2024 16:46:33 +0200 Subject: [PATCH 11/17] Sync with main & bump swc_core@0.96.9 (#105) --- .cargo/{config => config.toml} | 0 .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- Cargo.lock | 276 +++++++++++---------------------- Cargo.toml | 12 +- README.md | 25 +-- rust-toolchain | 2 +- src/jsx_visitor.rs | 2 +- src/tests/common/mod.rs | 4 +- src/tests/jsx_icu.rs | 2 +- src/tests/runtime_config.rs | 2 +- 11 files changed, 120 insertions(+), 209 deletions(-) rename .cargo/{config => config.toml} (100%) diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e752e2..f232c7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: - 'LICENSE' env: - TOOLCHAIN: nightly-2024-07-21 + TOOLCHAIN: 1.80.0 jobs: check: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 26cc3bc..7f12ea4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: types: [released, prereleased] env: - TOOLCHAIN: nightly-2024-07-21 + TOOLCHAIN: 1.80.0 jobs: release: diff --git a/Cargo.lock b/Cargo.lock index 19c6ceb..879b879 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,21 +12,6 @@ dependencies = [ "regex", ] -[[package]] -name = "addr2line" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "ahash" version = "0.7.8" @@ -64,9 +49,9 @@ checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "ast_node" -version = "0.9.6" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e3e06ec6ac7d893a0db7127d91063ad7d9da8988f8a1a256f03729e6eec026" +checksum = "f9184f2b369b3e8625712493c89b785881f27eedc6cde480a81883cef78868b2" dependencies = [ "proc-macro2", "quote", @@ -91,21 +76,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "backtrace" -version = "0.3.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - [[package]] name = "base64" version = "0.21.7" @@ -355,9 +325,9 @@ dependencies = [ [[package]] name = "from_variant" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a0b11eeb173ce52f84ebd943d42e58813a2ebb78a6a3ff0a243b71c5199cd7b" +checksum = "32016f1242eb82af5474752d00fd8ebcd9004bd69b462b1c91de833972d08ed4" dependencies = [ "proc-macro2", "swc_macros_common", @@ -391,12 +361,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - [[package]] name = "glob" version = "0.3.0" @@ -511,12 +475,6 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "is_ci" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" - [[package]] name = "itoa" version = "1.0.4" @@ -579,7 +537,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -590,19 +548,13 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "miette" -version = "4.7.1" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c90329e44f9208b55f45711f9558cec15d7ef8295cc65ecd6d4188ae8edc58c" +checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" dependencies = [ - "atty", - "backtrace", + "cfg-if", "miette-derive", - "once_cell", "owo-colors", - "supports-color", - "supports-hyperlinks", - "supports-unicode", - "terminal_size", "textwrap", "thiserror", "unicode-width", @@ -610,29 +562,20 @@ dependencies = [ [[package]] name = "miette-derive" -version = "4.7.1" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b5bc45b761bcf1b5e6e6c4128cd93b84c218721a8d9b894aa0aff4ed180174c" +checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 1.0.105", -] - -[[package]] -name = "miniz_oxide" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" -dependencies = [ - "adler", + "syn 2.0.60", ] [[package]] name = "new_debug_unreachable" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "nu-ansi-term" @@ -685,15 +628,6 @@ dependencies = [ "libc", ] -[[package]] -name = "object" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -723,9 +657,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "owo-colors" -version = "3.5.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" [[package]] name = "parking_lot" @@ -904,13 +838,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.1" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.1", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -922,6 +857,17 @@ dependencies = [ "regex-syntax 0.6.28", ] +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.4", +] + [[package]] name = "regex-syntax" version = "0.6.28" @@ -930,9 +876,9 @@ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "regex-syntax" -version = "0.7.1" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "relative-path" @@ -978,12 +924,6 @@ dependencies = [ "syn 1.0.105", ] -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - [[package]] name = "rustc-hash" version = "1.1.0" @@ -1025,6 +965,12 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +[[package]] +name = "ryu-js" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad97d4ce1560a5e27cec89519dc8300d1aa6035b099821261c651486a19e44d5" + [[package]] name = "scoped-tls" version = "1.0.1" @@ -1069,18 +1015,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.198" +version = "1.0.207" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.207" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" dependencies = [ "proc-macro2", "quote", @@ -1089,11 +1035,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1208,9 +1155,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "string_enum" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b650ea2087d32854a0f20b837fc56ec987a1cb4f758c9757e1171ee9812da63" +checksum = "05e383308aebc257e7d7920224fa055c632478d92744eca77f99be8fa1545b90" dependencies = [ "proc-macro2", "quote", @@ -1218,34 +1165,6 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "supports-color" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" -dependencies = [ - "atty", - "is_ci", -] - -[[package]] -name = "supports-hyperlinks" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "590b34f7c5f01ecc9d78dba4b3f445f31df750a67621cf31626f3b7441ce6406" -dependencies = [ - "atty", -] - -[[package]] -name = "supports-unicode" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8b945e45b417b125a8ec51f1b7df2f8df7920367700d1f98aedd21e5735f8b2" -dependencies = [ - "atty", -] - [[package]] name = "swc_atoms" version = "0.6.7" @@ -1262,9 +1181,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.33.25" +version = "0.34.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a529796c240cd87da18d26d63f9de4c7ad3680cf0a04b95f0c37f4c4f0a0da63" +checksum = "9087befec6b63911f9d2f239e4f91c9b21589c169b86ed2d616944d23cf4a243" dependencies = [ "anyhow", "ast_node", @@ -1294,9 +1213,9 @@ dependencies = [ [[package]] name = "swc_core" -version = "0.90.35" +version = "0.96.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b9e641c348c1e8b0e01430b4706b777ecb0873323b423a8e8e5515093583e43" +checksum = "de60918c09a10e55b659b4e70029d283da815e3107b22f79ec9fac280d4d8843" dependencies = [ "once_cell", "swc_atoms", @@ -1315,9 +1234,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.112.8" +version = "0.115.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1d5c33c22ad50e8e34b3080a6fb133316d2eaa7d00400fc5018151f5ca44c5a" +checksum = "7be1306930c235435a892104c00c2b5e16231043c085d5a10bd3e7537b15659b" dependencies = [ "bitflags 2.5.0", "bytecheck", @@ -1334,9 +1253,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.148.17" +version = "0.151.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7188b2848402ce983f6c618a829b4ceb18d21eed7986782a7b7028cc234ede6b" +checksum = "f5141a8cb4eb69e090e6aea5d49061b46919be5210f3d084f9d9ad63d30f5cff" dependencies = [ "memchr", "num-bigint", @@ -1353,9 +1272,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen_macros" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "394b8239424b339a12012ceb18726ed0244fce6bf6345053cb9320b2791dcaa5" +checksum = "859fabde36db38634f3fad548dd5e3410c1aebba1b67a3c63e67018fa57a0bca" dependencies = [ "proc-macro2", "quote", @@ -1365,9 +1284,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.143.16" +version = "0.146.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b7faa481ac015b330f1c4bc8df2c9947242020e23ccdb10bc7a8ef84342509" +checksum = "0a4e0c2e85f12c63b85c805e923079b04d1fb3e25edd069d638eed5f2098de74" dependencies = [ "either", "new_debug_unreachable", @@ -1387,9 +1306,9 @@ dependencies = [ [[package]] name = "swc_ecma_testing" -version = "0.22.22" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c5704ef494b1805bc4566ff566b964bc1e9d3fb0f0e046ad6392b09a54de844" +checksum = "7f495dae76f1ef3f5be46993b050c3c7f9bf534bcdacf1e40789d32255040776" dependencies = [ "anyhow", "hex", @@ -1400,9 +1319,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.137.21" +version = "0.140.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "660badfe2eed8b6213ec9dcd71aa0786f8fb46ffa012e0313bcba1fe4a9a5c73" +checksum = "d37dc505c92af56d0f77cf6f31a6ccd37ac40cad1e01ff77277e0b1c70e8f8ff" dependencies = [ "better_scoped_tls", "bitflags 2.5.0", @@ -1423,9 +1342,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_testing" -version = "0.140.18" +version = "0.143.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0ea6f85b7bf04391a172d7a369e49865effa77ec3a6cd0e969a274cfcb982d" +checksum = "20932deae5f94d2c2d722ed2ed70a140e1e9f19d105414c02572bd49e83fb29a" dependencies = [ "ansi_term", "anyhow", @@ -1449,14 +1368,15 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.127.20" +version = "0.130.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d40abfc4f3a7bfdf54d11ac705cc9dd0836c48bf085b359143b4d40b50cb31" +checksum = "13e62b199454a576c5fdbd7e1bef8ab88a395427456d8a713d994b7d469833aa" dependencies = [ "indexmap", "num_cpus", "once_cell", "rustc-hash", + "ryu-js", "swc_atoms", "swc_common", "swc_ecma_ast", @@ -1467,9 +1387,9 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.98.7" +version = "0.101.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93692bdcdbb63db8f5e10fea5d202b5487cb27eb443aec424f4335c88f9864af" +checksum = "ce0d997f0c9b4e181225f603d161f6757c2a97022258170982cfe005ec69ec92" dependencies = [ "num-bigint", "swc_atoms", @@ -1492,9 +1412,9 @@ dependencies = [ [[package]] name = "swc_error_reporters" -version = "0.17.19" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329e73f159a3d38d4cd5f606a0918eeff39f5bbdbdafd9b6fecb290d2e9a32d" +checksum = "4689d9bb6092b5e6a0b79c0152336a8bd7f0acaf70dcf4133f86deb01775baa0" dependencies = [ "anyhow", "miette", @@ -1505,9 +1425,9 @@ dependencies = [ [[package]] name = "swc_macros_common" -version = "0.3.9" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50176cfc1cbc8bb22f41c6fe9d1ec53fbe057001219b5954961b8ad0f336fce9" +checksum = "f486687bfb7b5c560868f69ed2d458b880cebc9babebcb67e49f31b55c5bf847" dependencies = [ "proc-macro2", "quote", @@ -1536,9 +1456,9 @@ dependencies = [ [[package]] name = "swc_plugin_proxy" -version = "0.41.7" +version = "0.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e09ebf5da9eb13f431ebfb916cd3378a87ffae927ba896261ebc9dc094457ae" +checksum = "3d5460f8f89905a6d698d8d9a965f6c99888c8ebcbb5a0266556d06ad39f09f7" dependencies = [ "better_scoped_tls", "rkyv", @@ -1561,9 +1481,9 @@ dependencies = [ [[package]] name = "swc_visit" -version = "0.5.13" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0263be55289abfe9c877ffef83d877b5bdfac036ffe2de793f48f5e47e41dbae" +checksum = "043d11fe683dcb934583ead49405c0896a5af5face522e4682c16971ef7871b9" dependencies = [ "either", "swc_visit_macros", @@ -1571,9 +1491,9 @@ dependencies = [ [[package]] name = "swc_visit_macros" -version = "0.5.11" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33fc817055fe127b4285dc85058596768bfde7537ae37da82c67815557f03e33" +checksum = "92807d840959f39c60ce8a774a3f83e8193c658068e6d270dbe0a05e40e90b41" dependencies = [ "Inflector", "proc-macro2", @@ -1633,21 +1553,11 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "testing" -version = "0.35.23" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "689e2661712768726869f62945ccbe5d76ab3a3957b88221275bebe22a0761c8" +checksum = "27d395aa823f3ad1ad845ed74b96188f493b469794cfbe9ef82f03196064086f" dependencies = [ "ansi_term", "cargo_metadata", @@ -1682,9 +1592,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.2" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "smawk", "unicode-linebreak", @@ -1693,22 +1603,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 1.0.105", + "syn 2.0.60", ] [[package]] @@ -1832,9 +1742,9 @@ checksum = "d70b6494226b36008c8366c288d77190b3fad2eb4c10533139c1c1f461127f1a" [[package]] name = "unicode-id-start" -version = "1.1.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8f73150333cb58412db36f2aca8f2875b013049705cc77b94ded70a1ab1f5da" +checksum = "02aebfa694eccbbbffdd92922c7de136b9fe764396d2f10e21bce1681477cfc1" [[package]] name = "unicode-ident" @@ -1863,9 +1773,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "url" diff --git a/Cargo.toml b/Cargo.toml index 4cac664..f6d5469 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,12 +17,12 @@ opt-level = "s" [dependencies] data-encoding = "2.3.3" -sha2 = "0.10.6" -serde = "1" -serde_json = "1.0.95" -regex = "1.7.3" -once_cell = "1.17.1" -swc_core = { version = "0.90.35", features = [ +sha2 = "0.10.8" +serde = "1.0.207" +serde_json = "1.0.125" +regex = "1.10.6" +once_cell = "1.19.0" +swc_core = { version = "0.96.9", features = [ "ecma_plugin_transform", "ecma_utils", "ecma_visit", diff --git a/README.md b/README.md index 9f99fc9..dbd59a3 100644 --- a/README.md +++ b/README.md @@ -85,18 +85,19 @@ SWC Plugin support is still experimental. They do not guarantee a semver backwar So you need to select an appropriate version of the plugin to match compatible `swc_core`. -| Plugin Version | used `swc_core` | Compatibility | -|------------------------------------------|-----------------|------------------------------------------------------------------------------------------------------| -| `0.1.0`, `4.0.0-next.0` | `0.52.8` | `next@13.0.0` ~ `next@13.2.3` | -| `0.2.*`, `4.0.0-next.1` ~ `4.0.0-next.3` | `0.56.1` | `@swc/core@1.3.29` ~ `@swc/core@1.3.37`
`next@13.2.4-canary.0` ~ `next@13.2.5-canary.5` | -| `4.0.0` | `0.75.33` | `@swc/core@1.3.49` ~ `@swc/core@1.3.57`
`next@v13.3.1-canary.12` ~ `next@v13.4.3-canary.1` | -| `4.0.1` | `0.76.0` | broken due to [`lto = true`](https://github.com/swc-project/swc/issues/7470#issuecomment-1571585905) | -| `4.0.2` | `0.76.41` | `@swc/core@1.3.58` ~ `@swc/core@1.3.62`
`next@v13.4.3-canary.2` ~ | -| `4.0.3` | `0.78.28` | `@swc/core@1.3.63` ~ `@swc/core@1.3.67`
`next@v13.4.8 ~ next@v13.4.10-canary.0` | -| `4.0.4` | `0.79.x` | `@swc/core@1.3.68` ~ `@swc/core@1.3.80`
`next@v13.4.10-canary.1` ~ | -| `4.0.5` | `0.87.x` | broken due incorrect version of `swc_common` | -| `4.0.6` | `0.87.x` | `@swc/core@1.3.81 ~ @swc/core@1.3.105`
`~ next@v14.1.0` | -| `4.0.7`, `4.0.8` | `0.90.35` | `@swc/core@1.4.0 ~`
`next@14.1.1-canary.52 ~`
`@rspack/core@0.6.0 ~` | +| Plugin Version | used `swc_core` | Compatibility | +|---------------------------------------------------|-----------------|---------------------------------------------------------------------------------------------------------------------------| +| `0.1.0`, `4.0.0-next.0` | `0.52.8` | `next@13.0.0` ~ `next@13.2.3` | +| `0.2.*`, `4.0.0-next.1` ~ `4.0.0-next.3` | `0.56.1` | `@swc/core@1.3.29` ~ `@swc/core@1.3.37`
`next@13.2.4-canary.0` ~ `next@13.2.5-canary.5` | +| `4.0.0` | `0.75.33` | `@swc/core@1.3.49` ~ `@swc/core@1.3.57`
`next@v13.3.1-canary.12` ~ `next@v13.4.3-canary.1` | +| `4.0.1` | `0.76.0` | broken due to [`lto = true`](https://github.com/swc-project/swc/issues/7470#issuecomment-1571585905) | +| `4.0.2` | `0.76.41` | `@swc/core@1.3.58` ~ `@swc/core@1.3.62`
`next@v13.4.3-canary.2` ~ | +| `4.0.3` | `0.78.28` | `@swc/core@1.3.63` ~ `@swc/core@1.3.67`
`next@v13.4.8 ~ next@v13.4.10-canary.0` | +| `4.0.4` | `0.79.x` | `@swc/core@1.3.68` ~ `@swc/core@1.3.80`
`next@v13.4.10-canary.1` ~ | +| `4.0.5` | `0.87.x` | broken due incorrect version of `swc_common` | +| `4.0.6` | `0.87.x` | `@swc/core@1.3.81 ~ @swc/core@1.3.105`
`~ next@v14.1.0` | +| `4.0.7`, `4.0.8`, `5.0.0-next.0` ~ `5.0.0-next.1` | `0.90.35` | `@swc/core@1.4.0` ~ `@swc/core@1.5.0`
`next@14.1.1-canary.52` ~ `v15.0.0-canary.36`
`@rspack/core@0.6.0 ~` | +| `4.0.9` | `0.96.9` | `@swc/core@1.6.x`
`next@15.0.0-canary.37 ~` | This table may become outdated. If you don't see a particular version of `@swc/core` or `next` check the compatibility by referring to the upstream's [Selecting the version](https://swc.rs/docs/plugin/selecting-swc-core) article. This will help you select the appropriate plugin version for your project. diff --git a/rust-toolchain b/rust-toolchain index bc6c996..aaceec0 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2024-07-21 +1.80.0 diff --git a/src/jsx_visitor.rs b/src/jsx_visitor.rs index a98a18e..2337c93 100644 --- a/src/jsx_visitor.rs +++ b/src/jsx_visitor.rs @@ -212,7 +212,7 @@ impl<'a> Visit for TransJSXVisitor<'a> { fn visit_jsx_text(&mut self, el: &JSXText) { self.tokens .push(MsgToken::String(clean_jsx_element_literal_child( - &el.raw.to_string(), + &el.value.to_string(), ))); } diff --git a/src/tests/common/mod.rs b/src/tests/common/mod.rs index e000f8d..1ca38f6 100644 --- a/src/tests/common/mod.rs +++ b/src/tests/common/mod.rs @@ -2,7 +2,7 @@ macro_rules! to { ($name:ident, $from:expr, $to:expr) => { swc_core::ecma::transforms::testing::test_inline!( - swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsConfig { + swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsSyntax { tsx: true, ..Default::default() }), @@ -20,7 +20,7 @@ macro_rules! to { (production, $name:ident, $from:expr, $to:expr) => { swc_core::ecma::transforms::testing::test_inline!( - swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsConfig { + swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsSyntax { tsx: true, ..Default::default() }), diff --git a/src/tests/jsx_icu.rs b/src/tests/jsx_icu.rs index 78dc8cb..68292c1 100644 --- a/src/tests/jsx_icu.rs +++ b/src/tests/jsx_icu.rs @@ -375,7 +375,7 @@ to!( ); to!( - multiple_new_lines_with_nbsp_endind, + multiple_new_lines_with_nbsp_ending, r#" import { Trans } from "@lingui/react/macro"; diff --git a/src/tests/runtime_config.rs b/src/tests/runtime_config.rs index 878241f..6a47417 100644 --- a/src/tests/runtime_config.rs +++ b/src/tests/runtime_config.rs @@ -4,7 +4,7 @@ use crate::{LinguiOptions, RuntimeModulesConfigMapNormalized}; macro_rules! to { ($name:ident, $options:expr, $from:expr, $to:expr) => { swc_core::ecma::transforms::testing::test_inline!( - swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsConfig { + swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsSyntax { tsx: true, ..Default::default() }), From 4cd7fa709bb2dda4b44b5a0e07a0d093af249aa8 Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Thu, 15 Aug 2024 16:47:05 +0200 Subject: [PATCH 12/17] fix: useLingui when `t` is not used (#107) --- src/lib.rs | 3 ++- src/tests/use_lingui.rs | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index db3e32a..29b484b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -151,6 +151,8 @@ impl LinguiMacroFolder { }) .is_some() { + self.ctx.should_add_uselingui_import = true; + if let Pat::Object(obj_pat) = declarator.name { let mut new_props: Vec = obj_pat.props.into_iter().map(|prop| { @@ -168,7 +170,6 @@ impl LinguiMacroFolder { to: underscore_ident.clone(), }); - self.ctx.should_add_uselingui_import = true; ctx.runtime_idents.i18n = new_i18n_ident.clone(); return Some(ObjectPatProp::KeyValue( diff --git a/src/tests/use_lingui.rs b/src/tests/use_lingui.rs index 9da57e3..4398330 100644 --- a/src/tests/use_lingui.rs +++ b/src/tests/use_lingui.rs @@ -161,6 +161,27 @@ function MyComponent() { "# ); +to!( + work_when_t_is_not_used, + // input + r#" +import { useLingui } from '@lingui/react/macro'; + +function MyComponent() { + const { i18n } = useLingui(); + console.log(i18n); +} + "#, + // output after transform + r#" +import { useLingui as $_useLingui } from "@lingui/react"; +function MyComponent() { + const { i18n, _: $__ } = $_useLingui(); + console.log(i18n); +} + "# +); + to!( work_with_existing_use_lingui_statement, // input From 47b25304d95a46ac28d99b99b4119eaa718129a8 Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Fri, 16 Aug 2024 11:51:01 +0200 Subject: [PATCH 13/17] Revert "Sync with main & bump swc_core@0.96.9 (#105)" (#108) This reverts commit 05dcef1fa0ecfb5caa5c339621dae612606c00ca. --- .cargo/{config.toml => config} | 0 .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- Cargo.lock | 276 ++++++++++++++++++++++----------- Cargo.toml | 12 +- README.md | 25 ++- rust-toolchain | 2 +- src/jsx_visitor.rs | 2 +- src/tests/common/mod.rs | 4 +- src/tests/jsx_icu.rs | 2 +- src/tests/runtime_config.rs | 2 +- 11 files changed, 209 insertions(+), 120 deletions(-) rename .cargo/{config.toml => config} (100%) diff --git a/.cargo/config.toml b/.cargo/config similarity index 100% rename from .cargo/config.toml rename to .cargo/config diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f232c7e..8e752e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: - 'LICENSE' env: - TOOLCHAIN: 1.80.0 + TOOLCHAIN: nightly-2024-07-21 jobs: check: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f12ea4..26cc3bc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: types: [released, prereleased] env: - TOOLCHAIN: 1.80.0 + TOOLCHAIN: nightly-2024-07-21 jobs: release: diff --git a/Cargo.lock b/Cargo.lock index 879b879..19c6ceb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,6 +12,21 @@ dependencies = [ "regex", ] +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.7.8" @@ -49,9 +64,9 @@ checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "ast_node" -version = "0.9.9" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9184f2b369b3e8625712493c89b785881f27eedc6cde480a81883cef78868b2" +checksum = "c3e3e06ec6ac7d893a0db7127d91063ad7d9da8988f8a1a256f03729e6eec026" dependencies = [ "proc-macro2", "quote", @@ -76,6 +91,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.21.7" @@ -325,9 +355,9 @@ dependencies = [ [[package]] name = "from_variant" -version = "0.1.9" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32016f1242eb82af5474752d00fd8ebcd9004bd69b462b1c91de833972d08ed4" +checksum = "3a0b11eeb173ce52f84ebd943d42e58813a2ebb78a6a3ff0a243b71c5199cd7b" dependencies = [ "proc-macro2", "swc_macros_common", @@ -361,6 +391,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" + [[package]] name = "glob" version = "0.3.0" @@ -475,6 +511,12 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "is_ci" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" + [[package]] name = "itoa" version = "1.0.4" @@ -537,7 +579,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] @@ -548,13 +590,19 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "miette" -version = "7.2.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" +checksum = "1c90329e44f9208b55f45711f9558cec15d7ef8295cc65ecd6d4188ae8edc58c" dependencies = [ - "cfg-if", + "atty", + "backtrace", "miette-derive", + "once_cell", "owo-colors", + "supports-color", + "supports-hyperlinks", + "supports-unicode", + "terminal_size", "textwrap", "thiserror", "unicode-width", @@ -562,20 +610,29 @@ dependencies = [ [[package]] name = "miette-derive" -version = "7.2.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" +checksum = "6b5bc45b761bcf1b5e6e6c4128cd93b84c218721a8d9b894aa0aff4ed180174c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 1.0.105", +] + +[[package]] +name = "miniz_oxide" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +dependencies = [ + "adler", ] [[package]] name = "new_debug_unreachable" -version = "1.0.6" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" [[package]] name = "nu-ansi-term" @@ -628,6 +685,15 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -657,9 +723,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "owo-colors" -version = "4.0.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "parking_lot" @@ -838,14 +904,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-syntax 0.7.1", ] [[package]] @@ -857,17 +922,6 @@ dependencies = [ "regex-syntax 0.6.28", ] -[[package]] -name = "regex-automata" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.8.4", -] - [[package]] name = "regex-syntax" version = "0.6.28" @@ -876,9 +930,9 @@ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "relative-path" @@ -924,6 +978,12 @@ dependencies = [ "syn 1.0.105", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -965,12 +1025,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" -[[package]] -name = "ryu-js" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad97d4ce1560a5e27cec89519dc8300d1aa6035b099821261c651486a19e44d5" - [[package]] name = "scoped-tls" version = "1.0.1" @@ -1015,18 +1069,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.207" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.207" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", @@ -1035,12 +1089,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", - "memchr", "ryu", "serde", ] @@ -1155,9 +1208,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "string_enum" -version = "0.4.4" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e383308aebc257e7d7920224fa055c632478d92744eca77f99be8fa1545b90" +checksum = "1b650ea2087d32854a0f20b837fc56ec987a1cb4f758c9757e1171ee9812da63" dependencies = [ "proc-macro2", "quote", @@ -1165,6 +1218,34 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "supports-color" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" +dependencies = [ + "atty", + "is_ci", +] + +[[package]] +name = "supports-hyperlinks" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "590b34f7c5f01ecc9d78dba4b3f445f31df750a67621cf31626f3b7441ce6406" +dependencies = [ + "atty", +] + +[[package]] +name = "supports-unicode" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8b945e45b417b125a8ec51f1b7df2f8df7920367700d1f98aedd21e5735f8b2" +dependencies = [ + "atty", +] + [[package]] name = "swc_atoms" version = "0.6.7" @@ -1181,9 +1262,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.34.4" +version = "0.33.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9087befec6b63911f9d2f239e4f91c9b21589c169b86ed2d616944d23cf4a243" +checksum = "a529796c240cd87da18d26d63f9de4c7ad3680cf0a04b95f0c37f4c4f0a0da63" dependencies = [ "anyhow", "ast_node", @@ -1213,9 +1294,9 @@ dependencies = [ [[package]] name = "swc_core" -version = "0.96.9" +version = "0.90.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de60918c09a10e55b659b4e70029d283da815e3107b22f79ec9fac280d4d8843" +checksum = "2b9e641c348c1e8b0e01430b4706b777ecb0873323b423a8e8e5515093583e43" dependencies = [ "once_cell", "swc_atoms", @@ -1234,9 +1315,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.115.1" +version = "0.112.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7be1306930c235435a892104c00c2b5e16231043c085d5a10bd3e7537b15659b" +checksum = "d1d5c33c22ad50e8e34b3080a6fb133316d2eaa7d00400fc5018151f5ca44c5a" dependencies = [ "bitflags 2.5.0", "bytecheck", @@ -1253,9 +1334,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.151.1" +version = "0.148.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5141a8cb4eb69e090e6aea5d49061b46919be5210f3d084f9d9ad63d30f5cff" +checksum = "7188b2848402ce983f6c618a829b4ceb18d21eed7986782a7b7028cc234ede6b" dependencies = [ "memchr", "num-bigint", @@ -1272,9 +1353,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen_macros" -version = "0.7.7" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859fabde36db38634f3fad548dd5e3410c1aebba1b67a3c63e67018fa57a0bca" +checksum = "394b8239424b339a12012ceb18726ed0244fce6bf6345053cb9320b2791dcaa5" dependencies = [ "proc-macro2", "quote", @@ -1284,9 +1365,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.146.12" +version = "0.143.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e0c2e85f12c63b85c805e923079b04d1fb3e25edd069d638eed5f2098de74" +checksum = "40b7faa481ac015b330f1c4bc8df2c9947242020e23ccdb10bc7a8ef84342509" dependencies = [ "either", "new_debug_unreachable", @@ -1306,9 +1387,9 @@ dependencies = [ [[package]] name = "swc_ecma_testing" -version = "0.23.0" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f495dae76f1ef3f5be46993b050c3c7f9bf534bcdacf1e40789d32255040776" +checksum = "7c5704ef494b1805bc4566ff566b964bc1e9d3fb0f0e046ad6392b09a54de844" dependencies = [ "anyhow", "hex", @@ -1319,9 +1400,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.140.3" +version = "0.137.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d37dc505c92af56d0f77cf6f31a6ccd37ac40cad1e01ff77277e0b1c70e8f8ff" +checksum = "660badfe2eed8b6213ec9dcd71aa0786f8fb46ffa012e0313bcba1fe4a9a5c73" dependencies = [ "better_scoped_tls", "bitflags 2.5.0", @@ -1342,9 +1423,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_testing" -version = "0.143.2" +version = "0.140.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20932deae5f94d2c2d722ed2ed70a140e1e9f19d105414c02572bd49e83fb29a" +checksum = "7c0ea6f85b7bf04391a172d7a369e49865effa77ec3a6cd0e969a274cfcb982d" dependencies = [ "ansi_term", "anyhow", @@ -1368,15 +1449,14 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.130.3" +version = "0.127.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e62b199454a576c5fdbd7e1bef8ab88a395427456d8a713d994b7d469833aa" +checksum = "15d40abfc4f3a7bfdf54d11ac705cc9dd0836c48bf085b359143b4d40b50cb31" dependencies = [ "indexmap", "num_cpus", "once_cell", "rustc-hash", - "ryu-js", "swc_atoms", "swc_common", "swc_ecma_ast", @@ -1387,9 +1467,9 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.101.0" +version = "0.98.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce0d997f0c9b4e181225f603d161f6757c2a97022258170982cfe005ec69ec92" +checksum = "93692bdcdbb63db8f5e10fea5d202b5487cb27eb443aec424f4335c88f9864af" dependencies = [ "num-bigint", "swc_atoms", @@ -1412,9 +1492,9 @@ dependencies = [ [[package]] name = "swc_error_reporters" -version = "0.18.1" +version = "0.17.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4689d9bb6092b5e6a0b79c0152336a8bd7f0acaf70dcf4133f86deb01775baa0" +checksum = "3329e73f159a3d38d4cd5f606a0918eeff39f5bbdbdafd9b6fecb290d2e9a32d" dependencies = [ "anyhow", "miette", @@ -1425,9 +1505,9 @@ dependencies = [ [[package]] name = "swc_macros_common" -version = "0.3.13" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f486687bfb7b5c560868f69ed2d458b880cebc9babebcb67e49f31b55c5bf847" +checksum = "50176cfc1cbc8bb22f41c6fe9d1ec53fbe057001219b5954961b8ad0f336fce9" dependencies = [ "proc-macro2", "quote", @@ -1456,9 +1536,9 @@ dependencies = [ [[package]] name = "swc_plugin_proxy" -version = "0.44.2" +version = "0.41.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d5460f8f89905a6d698d8d9a965f6c99888c8ebcbb5a0266556d06ad39f09f7" +checksum = "7e09ebf5da9eb13f431ebfb916cd3378a87ffae927ba896261ebc9dc094457ae" dependencies = [ "better_scoped_tls", "rkyv", @@ -1481,9 +1561,9 @@ dependencies = [ [[package]] name = "swc_visit" -version = "0.5.14" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043d11fe683dcb934583ead49405c0896a5af5face522e4682c16971ef7871b9" +checksum = "0263be55289abfe9c877ffef83d877b5bdfac036ffe2de793f48f5e47e41dbae" dependencies = [ "either", "swc_visit_macros", @@ -1491,9 +1571,9 @@ dependencies = [ [[package]] name = "swc_visit_macros" -version = "0.5.13" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92807d840959f39c60ce8a774a3f83e8193c658068e6d270dbe0a05e40e90b41" +checksum = "33fc817055fe127b4285dc85058596768bfde7537ae37da82c67815557f03e33" dependencies = [ "Inflector", "proc-macro2", @@ -1553,11 +1633,21 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "testing" -version = "0.36.0" +version = "0.35.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27d395aa823f3ad1ad845ed74b96188f493b469794cfbe9ef82f03196064086f" +checksum = "689e2661712768726869f62945ccbe5d76ab3a3957b88221275bebe22a0761c8" dependencies = [ "ansi_term", "cargo_metadata", @@ -1592,9 +1682,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.16.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" dependencies = [ "smawk", "unicode-linebreak", @@ -1603,22 +1693,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 1.0.105", ] [[package]] @@ -1742,9 +1832,9 @@ checksum = "d70b6494226b36008c8366c288d77190b3fad2eb4c10533139c1c1f461127f1a" [[package]] name = "unicode-id-start" -version = "1.0.4" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02aebfa694eccbbbffdd92922c7de136b9fe764396d2f10e21bce1681477cfc1" +checksum = "b8f73150333cb58412db36f2aca8f2875b013049705cc77b94ded70a1ab1f5da" [[package]] name = "unicode-ident" @@ -1773,9 +1863,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "url" diff --git a/Cargo.toml b/Cargo.toml index f6d5469..4cac664 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,12 +17,12 @@ opt-level = "s" [dependencies] data-encoding = "2.3.3" -sha2 = "0.10.8" -serde = "1.0.207" -serde_json = "1.0.125" -regex = "1.10.6" -once_cell = "1.19.0" -swc_core = { version = "0.96.9", features = [ +sha2 = "0.10.6" +serde = "1" +serde_json = "1.0.95" +regex = "1.7.3" +once_cell = "1.17.1" +swc_core = { version = "0.90.35", features = [ "ecma_plugin_transform", "ecma_utils", "ecma_visit", diff --git a/README.md b/README.md index dbd59a3..9f99fc9 100644 --- a/README.md +++ b/README.md @@ -85,19 +85,18 @@ SWC Plugin support is still experimental. They do not guarantee a semver backwar So you need to select an appropriate version of the plugin to match compatible `swc_core`. -| Plugin Version | used `swc_core` | Compatibility | -|---------------------------------------------------|-----------------|---------------------------------------------------------------------------------------------------------------------------| -| `0.1.0`, `4.0.0-next.0` | `0.52.8` | `next@13.0.0` ~ `next@13.2.3` | -| `0.2.*`, `4.0.0-next.1` ~ `4.0.0-next.3` | `0.56.1` | `@swc/core@1.3.29` ~ `@swc/core@1.3.37`
`next@13.2.4-canary.0` ~ `next@13.2.5-canary.5` | -| `4.0.0` | `0.75.33` | `@swc/core@1.3.49` ~ `@swc/core@1.3.57`
`next@v13.3.1-canary.12` ~ `next@v13.4.3-canary.1` | -| `4.0.1` | `0.76.0` | broken due to [`lto = true`](https://github.com/swc-project/swc/issues/7470#issuecomment-1571585905) | -| `4.0.2` | `0.76.41` | `@swc/core@1.3.58` ~ `@swc/core@1.3.62`
`next@v13.4.3-canary.2` ~ | -| `4.0.3` | `0.78.28` | `@swc/core@1.3.63` ~ `@swc/core@1.3.67`
`next@v13.4.8 ~ next@v13.4.10-canary.0` | -| `4.0.4` | `0.79.x` | `@swc/core@1.3.68` ~ `@swc/core@1.3.80`
`next@v13.4.10-canary.1` ~ | -| `4.0.5` | `0.87.x` | broken due incorrect version of `swc_common` | -| `4.0.6` | `0.87.x` | `@swc/core@1.3.81 ~ @swc/core@1.3.105`
`~ next@v14.1.0` | -| `4.0.7`, `4.0.8`, `5.0.0-next.0` ~ `5.0.0-next.1` | `0.90.35` | `@swc/core@1.4.0` ~ `@swc/core@1.5.0`
`next@14.1.1-canary.52` ~ `v15.0.0-canary.36`
`@rspack/core@0.6.0 ~` | -| `4.0.9` | `0.96.9` | `@swc/core@1.6.x`
`next@15.0.0-canary.37 ~` | +| Plugin Version | used `swc_core` | Compatibility | +|------------------------------------------|-----------------|------------------------------------------------------------------------------------------------------| +| `0.1.0`, `4.0.0-next.0` | `0.52.8` | `next@13.0.0` ~ `next@13.2.3` | +| `0.2.*`, `4.0.0-next.1` ~ `4.0.0-next.3` | `0.56.1` | `@swc/core@1.3.29` ~ `@swc/core@1.3.37`
`next@13.2.4-canary.0` ~ `next@13.2.5-canary.5` | +| `4.0.0` | `0.75.33` | `@swc/core@1.3.49` ~ `@swc/core@1.3.57`
`next@v13.3.1-canary.12` ~ `next@v13.4.3-canary.1` | +| `4.0.1` | `0.76.0` | broken due to [`lto = true`](https://github.com/swc-project/swc/issues/7470#issuecomment-1571585905) | +| `4.0.2` | `0.76.41` | `@swc/core@1.3.58` ~ `@swc/core@1.3.62`
`next@v13.4.3-canary.2` ~ | +| `4.0.3` | `0.78.28` | `@swc/core@1.3.63` ~ `@swc/core@1.3.67`
`next@v13.4.8 ~ next@v13.4.10-canary.0` | +| `4.0.4` | `0.79.x` | `@swc/core@1.3.68` ~ `@swc/core@1.3.80`
`next@v13.4.10-canary.1` ~ | +| `4.0.5` | `0.87.x` | broken due incorrect version of `swc_common` | +| `4.0.6` | `0.87.x` | `@swc/core@1.3.81 ~ @swc/core@1.3.105`
`~ next@v14.1.0` | +| `4.0.7`, `4.0.8` | `0.90.35` | `@swc/core@1.4.0 ~`
`next@14.1.1-canary.52 ~`
`@rspack/core@0.6.0 ~` | This table may become outdated. If you don't see a particular version of `@swc/core` or `next` check the compatibility by referring to the upstream's [Selecting the version](https://swc.rs/docs/plugin/selecting-swc-core) article. This will help you select the appropriate plugin version for your project. diff --git a/rust-toolchain b/rust-toolchain index aaceec0..bc6c996 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.80.0 +nightly-2024-07-21 diff --git a/src/jsx_visitor.rs b/src/jsx_visitor.rs index 2337c93..a98a18e 100644 --- a/src/jsx_visitor.rs +++ b/src/jsx_visitor.rs @@ -212,7 +212,7 @@ impl<'a> Visit for TransJSXVisitor<'a> { fn visit_jsx_text(&mut self, el: &JSXText) { self.tokens .push(MsgToken::String(clean_jsx_element_literal_child( - &el.value.to_string(), + &el.raw.to_string(), ))); } diff --git a/src/tests/common/mod.rs b/src/tests/common/mod.rs index 1ca38f6..e000f8d 100644 --- a/src/tests/common/mod.rs +++ b/src/tests/common/mod.rs @@ -2,7 +2,7 @@ macro_rules! to { ($name:ident, $from:expr, $to:expr) => { swc_core::ecma::transforms::testing::test_inline!( - swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsSyntax { + swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsConfig { tsx: true, ..Default::default() }), @@ -20,7 +20,7 @@ macro_rules! to { (production, $name:ident, $from:expr, $to:expr) => { swc_core::ecma::transforms::testing::test_inline!( - swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsSyntax { + swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsConfig { tsx: true, ..Default::default() }), diff --git a/src/tests/jsx_icu.rs b/src/tests/jsx_icu.rs index 68292c1..78dc8cb 100644 --- a/src/tests/jsx_icu.rs +++ b/src/tests/jsx_icu.rs @@ -375,7 +375,7 @@ to!( ); to!( - multiple_new_lines_with_nbsp_ending, + multiple_new_lines_with_nbsp_endind, r#" import { Trans } from "@lingui/react/macro"; diff --git a/src/tests/runtime_config.rs b/src/tests/runtime_config.rs index 6a47417..878241f 100644 --- a/src/tests/runtime_config.rs +++ b/src/tests/runtime_config.rs @@ -4,7 +4,7 @@ use crate::{LinguiOptions, RuntimeModulesConfigMapNormalized}; macro_rules! to { ($name:ident, $options:expr, $from:expr, $to:expr) => { swc_core::ecma::transforms::testing::test_inline!( - swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsSyntax { + swc_core::ecma::parser::Syntax::Typescript(swc_core::ecma::parser::TsConfig { tsx: true, ..Default::default() }), From 931ee1d802f7cfb416961c0ff15a7e3bf9e8361c Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Fri, 16 Aug 2024 16:02:58 +0300 Subject: [PATCH 14/17] chore: version 5.0.0-next.2 (#109) --- Cargo.lock | 2 +- Cargo.toml | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 19c6ceb..bd88751 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -537,7 +537,7 @@ checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "lingui_macro_plugin" -version = "5.0.0-next.1" +version = "5.0.0-next.2" dependencies = [ "data-encoding", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 4cac664..07fb78f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lingui_macro_plugin" -version = "5.0.0-next.1" +version = "5.0.0-next.2" edition = "2021" [lib] diff --git a/package.json b/package.json index 7b5e028..90e6283 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingui/swc-plugin", - "version": "5.0.0-next.1", + "version": "5.0.0-next.2", "description": "A SWC Plugin for LinguiJS", "author": { "name": "Timofei Iatsenko", From 02ca026cd40a52d9e69c2ce4b3eb66e680d1bfeb Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Wed, 30 Oct 2024 14:11:12 +0100 Subject: [PATCH 15/17] feat: fix incompatibility with latest swc-core --- Cargo.lock | 2 +- src/ast_utils.rs | 6 +++--- src/js_macro_folder.rs | 4 +++- src/jsx_visitor.rs | 2 +- src/lib.rs | 12 +++++++----- src/macro_utils.rs | 6 +++--- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a69888a..558da77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -539,7 +539,7 @@ checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "lingui_macro_plugin" -version = "4.1.0" +version = "5.0.0-next.2" dependencies = [ "data-encoding", "once_cell", diff --git a/src/ast_utils.rs b/src/ast_utils.rs index f717a13..040af9a 100644 --- a/src/ast_utils.rs +++ b/src/ast_utils.rs @@ -163,15 +163,15 @@ pub fn create_key_value_prop(key: &str, value: Box) -> PropOrSpread { ))); } -pub fn create_import(source: JsWord, imported: Ident, local: Ident) -> ModuleItem { +pub fn create_import(source: JsWord, imported: IdentName, local: IdentName) -> ModuleItem { ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { span: DUMMY_SP, phase: ImportPhase::default(), specifiers: vec![ ImportSpecifier::Named(ImportNamedSpecifier { span: DUMMY_SP, - local, - imported: Some(ModuleExportName::Ident(imported)), + local: local.into(), + imported: Some(ModuleExportName::Ident(imported.into())), is_type_only: false, }) ], diff --git a/src/js_macro_folder.rs b/src/js_macro_folder.rs index a92ce61..db6a95d 100644 --- a/src/js_macro_folder.rs +++ b/src/js_macro_folder.rs @@ -6,6 +6,7 @@ use swc_core::{ visit::{Fold, FoldWith}, }, }; +use swc_core::common::SyntaxContext; use crate::ast_utils::{*}; use crate::builder::MessageBuilder; use crate::macro_utils::{*}; @@ -66,10 +67,11 @@ impl<'a> JsMacroFolder<'a> { return Box::new(self.ctx.runtime_idents.i18n.clone().into()); }), - prop: MemberProp::Ident(Ident::new("_".into(), DUMMY_SP)), + prop: MemberProp::Ident(IdentName::new("_".into(), DUMMY_SP)), }).as_callee(), args, type_args: None, + ctxt: SyntaxContext::empty(), } } diff --git a/src/jsx_visitor.rs b/src/jsx_visitor.rs index a98a18e..2337c93 100644 --- a/src/jsx_visitor.rs +++ b/src/jsx_visitor.rs @@ -212,7 +212,7 @@ impl<'a> Visit for TransJSXVisitor<'a> { fn visit_jsx_text(&mut self, el: &JSXText) { self.tokens .push(MsgToken::String(clean_jsx_element_literal_child( - &el.raw.to_string(), + &el.value.to_string(), ))); } diff --git a/src/lib.rs b/src/lib.rs index 29b484b..7d59609 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ use std::collections::HashSet; -use swc_core::common::DUMMY_SP; +use swc_core::common::{SyntaxContext, DUMMY_SP}; use swc_core::plugin::errors::HANDLER; use swc_core::{ @@ -140,7 +140,7 @@ impl LinguiMacroFolder { Stmt::Decl(Decl::Var(var_decl)) => { let decl = *var_decl; - let underscore_ident = quote_ident!("$__"); + let underscore_ident = quote_ident!(SyntaxContext::empty(), "$__"); let decls: Vec = decl.decls.into_iter().map(|declarator| { if let Some(init) = &declarator.init { let expr = init.as_ref(); @@ -163,14 +163,14 @@ impl LinguiMacroFolder { &ident.to_id(), ); - let new_i18n_ident = quote_ident!(ident.span, "$__i18n"); + let new_i18n_ident = quote_ident!(ident.ctxt, "$__i18n"); ident_replacer = Some(IdentReplacer { from: ident.to_id(), to: underscore_ident.clone(), }); - ctx.runtime_idents.i18n = new_i18n_ident.clone(); + ctx.runtime_idents.i18n = new_i18n_ident.clone().into(); return Some(ObjectPatProp::KeyValue( KeyValuePatProp { @@ -191,7 +191,7 @@ impl LinguiMacroFolder { return VarDeclarator { init: Some(Box::new(Expr::Call(CallExpr { - callee: Callee::Expr(Box::new(Expr::Ident(ctx.runtime_idents.use_lingui.clone()))), + callee: Callee::Expr(Box::new(Expr::Ident(ctx.runtime_idents.use_lingui.clone().into()))), ..call.clone() }))), @@ -228,6 +228,7 @@ r#"You have to destructure `t` when using the `useLingui` macro, i.e: decls, declare: false, kind: decl.kind, + ctxt: SyntaxContext::empty() }))) } _ => stmt, @@ -238,6 +239,7 @@ r#"You have to destructure `t` when using the `useLingui` macro, i.e: let mut block = BlockStmt { span: n.span, stmts, + ctxt: SyntaxContext::empty() }; // use lingui matched above diff --git a/src/macro_utils.rs b/src/macro_utils.rs index 57450eb..c33e602 100644 --- a/src/macro_utils.rs +++ b/src/macro_utils.rs @@ -24,9 +24,9 @@ pub struct MacroCtx { #[derive(Clone)] pub struct RuntimeIdents { - pub i18n: Ident, - pub trans: Ident, - pub use_lingui: Ident, + pub i18n: IdentName, + pub trans: IdentName, + pub use_lingui: IdentName, } impl Default for RuntimeIdents { From 5c6f718085e6c36787ca793156fa9e1cbe182d27 Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Wed, 30 Oct 2024 15:43:36 +0200 Subject: [PATCH 16/17] chore: version 5.0.0-next.3 --- Cargo.lock | 2 +- Cargo.toml | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 558da77..902abaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -539,7 +539,7 @@ checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "lingui_macro_plugin" -version = "5.0.0-next.2" +version = "5.0.0-next.3" dependencies = [ "data-encoding", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index c9b682e..96c9ae4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lingui_macro_plugin" -version = "5.0.0-next.2" +version = "5.0.0-next.3" edition = "2021" [lib] diff --git a/package.json b/package.json index 90e6283..d830cd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingui/swc-plugin", - "version": "5.0.0-next.2", + "version": "5.0.0-next.3", "description": "A SWC Plugin for LinguiJS", "author": { "name": "Timofei Iatsenko", From b6189ca7f5b687ed83f14ed843c2cf0dcca4ad80 Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Fri, 29 Nov 2024 09:59:32 +0200 Subject: [PATCH 17/17] chore: version 5.0.0 (#126) --- Cargo.lock | 2 +- Cargo.toml | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 902abaa..79967a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -539,7 +539,7 @@ checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "lingui_macro_plugin" -version = "5.0.0-next.3" +version = "5.0.0" dependencies = [ "data-encoding", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 96c9ae4..2ac8719 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lingui_macro_plugin" -version = "5.0.0-next.3" +version = "5.0.0" edition = "2021" [lib] diff --git a/package.json b/package.json index d830cd8..78f1a85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingui/swc-plugin", - "version": "5.0.0-next.3", + "version": "5.0.0", "description": "A SWC Plugin for LinguiJS", "author": { "name": "Timofei Iatsenko",