diff --git a/.changeset/lemon-streets-watch.md b/.changeset/lemon-streets-watch.md new file mode 100644 index 0000000000..3e7f6a4705 --- /dev/null +++ b/.changeset/lemon-streets-watch.md @@ -0,0 +1,9 @@ +--- +"@lynx-js/react": minor +--- + +fix: Delay execution of `runOnMainThread()` during initial render + +When called during the initial render, `runOnMainThread()` would execute before the `main-thread:ref` was hydrated, causing it to be incorrectly set to null. + +This change delays the function's execution to ensure the ref is available and correctly assigned. diff --git a/.changeset/mighty-numbers-talk.md b/.changeset/mighty-numbers-talk.md new file mode 100644 index 0000000000..daef32f1f9 --- /dev/null +++ b/.changeset/mighty-numbers-talk.md @@ -0,0 +1,5 @@ +--- +"@lynx-js/react": patch +--- + +Bump `swc_core` to `39.0.3`. diff --git a/.changeset/smooth-dragons-smash.md b/.changeset/smooth-dragons-smash.md new file mode 100644 index 0000000000..810cea4eac --- /dev/null +++ b/.changeset/smooth-dragons-smash.md @@ -0,0 +1,5 @@ +--- +"@lynx-js/react-rsbuild-plugin": patch +--- + +Be compat with `@lynx-js/react` v0.113.0 diff --git a/Cargo.lock b/Cargo.lock index a8c777ac54..c449dba55a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,19 +18,19 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom", + "getrandom 0.2.15", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.10" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b79b82693f705137f8fb9b37871d99e4f9a7df12b917eed79c3d3954830a60b" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.3.3", "once_cell", "serde", "version_check", @@ -96,11 +96,10 @@ checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" [[package]] name = "ast_node" -version = "3.0.0" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fb5864e2f5bf9fd9797b94b2dfd1554d4c3092b535008b27d7e15c86675a2f" +checksum = "a1e2cddd48eafd883890770673b1971faceaf80a185445671abc3ea0c00593ee" dependencies = [ - "proc-macro2", "quote", "swc_macros_common", "syn 2.0.90", @@ -141,9 +140,9 @@ dependencies = [ [[package]] name = "better_scoped_tls" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50fd297a11c709be8348aec039c8b91de16075d2b2bdaee1bd562c0875993664" +checksum = "7cd228125315b132eed175bf47619ac79b945b26e56b848ba203ae4ea8603609" dependencies = [ "scoped-tls", ] @@ -181,16 +180,26 @@ dependencies = [ "generic-array", ] +[[package]] +name = "browserslist-data" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e977366ea69a6e756ae616c0d5def0da9a3521fca5f91f447fdf613c928a15a" +dependencies = [ + "ahash 0.8.12", + "chrono", +] + [[package]] name = "browserslist-rs" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f95aff901882c66e4b642f3f788ceee152ef44f8a5ef12cb1ddee5479c483be" +checksum = "8dd48a6ca358df4f7000e3fb5f08738b1b91a0e5d5f862e2f77b2b14647547f5" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.12", + "browserslist-data", "chrono", "either", - "indexmap", "itertools", "nom", "serde", @@ -198,6 +207,16 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "bstr" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -207,6 +226,22 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + +[[package]] +name = "bytes-str" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c60b5ce37e0b883c37eb89f79a1e26fbe9c1081945d024eee93e8d91a7e18b3" +dependencies = [ + "bytes", + "serde", +] + [[package]] name = "camino" version = "1.1.6" @@ -565,6 +600,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -576,11 +617,10 @@ dependencies = [ [[package]] name = "from_variant" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d7ccf961415e7aa17ef93dcb6c2441faaa8e768abe09e659b908089546f74c5" +checksum = "308530a56b099da144ebc5d8e179f343ad928fa2b3558d1eb3db9af18d6eff43" dependencies = [ - "proc-macro2", "swc_macros_common", "syn 2.0.90", ] @@ -609,7 +649,19 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.5+wasi-0.2.4", ] [[package]] @@ -618,6 +670,18 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "globset" +version = "0.4.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a1028dfc5f5df5da8a56a73e6c153c9a9708ec57232470703592a3f18e49f5" +dependencies = [ + "aho-corasick", + "bstr", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -633,7 +697,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.12", ] [[package]] @@ -642,7 +706,7 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.12", "allocator-api2", ] @@ -651,6 +715,11 @@ name = "hashbrown" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] [[package]] name = "hermit-abi" @@ -669,14 +738,13 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hstr" -version = "1.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71399f53a92ef72ee336a4b30201c6e944827e14e0af23204c291aad9c24cc85" +checksum = "ced1416104790052518d199e753d49a7d8130d476c664bc9e53f40cfecb8e615" dependencies = [ "hashbrown 0.14.5", "new_debug_unreachable", "once_cell", - "phf", "rustc-hash", "triomphe", ] @@ -1240,9 +1308,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "output_vt100" @@ -1273,18 +1341,18 @@ checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" [[package]] name = "par-core" -version = "1.0.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b506ab63a8bd3cd38858c7bfc2d078a189dc3210c7f8c9be1bbaf50c082a0ae" +checksum = "e96cbd21255b7fb29a5d51ef38a779b517a91abd59e2756c039583f43ef4c90f" dependencies = [ "once_cell", ] [[package]] name = "par-iter" -version = "1.0.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a5b20f31e9ba82bfcbbb54a67aa40be6cebec9f668ba5753be138f9523c531a" +checksum = "3eae0176a010bb94b9a67f0eb9da0fd31410817d58850649c54f485124c9a71a" dependencies = [ "either", "par-core", @@ -1395,11 +1463,17 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +[[package]] +name = "precomputed-map" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84350ffee5cedfabf9bee3e8825721f651da8ff79d50fe7a37cf0ca015c428ee" + [[package]] name = "preset_env_base" -version = "3.0.1" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06c1ead1873928228f01ffafe4800c3accb27d019c034626c54698408e36bfb" +checksum = "b8e82699979593636125cbeeedaf538d11f3dc4645287bbd594041404ad4a88a" dependencies = [ "anyhow", "browserslist-rs", @@ -1443,26 +1517,6 @@ dependencies = [ "cc", ] -[[package]] -name = "ptr_meta" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9e76f66d3f9606f44e45598d155cb13ecf09f4a28199e48daf8c8fc937ea90" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca414edb151b4c8d125c12566ab0d74dc9cdba36fb80eb7b848c15f495fd32d1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.90", -] - [[package]] name = "quote" version = "1.0.35" @@ -1472,6 +1526,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "radium" version = "0.7.0" @@ -1504,7 +1564,7 @@ name = "react-transform" version = "0.0.0" dependencies = [ "convert_case", - "getrandom", + "getrandom 0.3.3", "hex", "indexmap", "napi", @@ -1582,6 +1642,16 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "regress" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "145bb27393fe455dd64d6cbc8d059adfa392590a45eadf079c01b11857e7b010" +dependencies = [ + "hashbrown 0.15.0", + "memchr", +] + [[package]] name = "relative-path" version = "1.8.0" @@ -1652,6 +1722,12 @@ dependencies = [ "serde", ] +[[package]] +name = "seq-macro" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" + [[package]] name = "serde" version = "1.0.217" @@ -1750,24 +1826,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "sourcemap" -version = "9.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd430118acc9fdd838557649b9b43fd0a78e3834d84a283b466f8e84720d6101" -dependencies = [ - "base64-simd", - "bitvec", - "data-encoding", - "debugid", - "if_chain", - "rustc-hash", - "serde", - "serde_json", - "unicode-id-start", - "url", -] - [[package]] name = "st-map" version = "0.2.3" @@ -1816,11 +1874,10 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "string_enum" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9fe66b8ee349846ce2f9557a26b8f1e74843c4a13fb381f9a3d73617a5f956a" +checksum = "ae36a4951ca7bd1cfd991c241584a9824a70f6aff1e7d4f693fb3f2465e4030e" dependencies = [ - "proc-macro2", "quote", "swc_macros_common", "syn 2.0.90", @@ -1834,36 +1891,32 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "swc" -version = "22.0.0" +version = "38.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80c62891c5429818ccfd614cc1e6023ca005a8a893ef47a18c4620d5f1bf4e8e" +checksum = "ab9c00873d50c358e53e06d917bc67af9f533c6db03890992336672a70af8393" dependencies = [ "anyhow", "base64", + "bytes-str", "dashmap", "either", "indexmap", "jsonc-parser", - "lru", "once_cell", "par-core", "par-iter", "parking_lot", - "pathdiff", "regex", "rustc-hash", "serde", "serde_json", - "sourcemap", "swc_atoms", - "swc_cached", "swc_common", "swc_compiler_base", "swc_config", "swc_ecma_ast", "swc_ecma_codegen", "swc_ecma_ext_transforms", - "swc_ecma_lints", "swc_ecma_loader", "swc_ecma_minifier", "swc_ecma_parser", @@ -1876,9 +1929,9 @@ dependencies = [ "swc_ecma_visit", "swc_error_reporters", "swc_node_comments", + "swc_sourcemap", "swc_timer", "swc_transform_common", - "swc_typescript", "swc_visit", "tracing", "url", @@ -1886,54 +1939,37 @@ dependencies = [ [[package]] name = "swc_allocator" -version = "4.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6b926f0d94bbb34031fe5449428cfa1268cdc0b31158d6ad9c97e0fc1e79dd" +checksum = "9d7eefd2c8b228a8c73056482b2ae4b3a1071fbe07638e3b55ceca8570cc48bb" dependencies = [ "allocator-api2", "bumpalo", "hashbrown 0.14.5", - "ptr_meta", "rustc-hash", - "triomphe", ] [[package]] name = "swc_atoms" -version = "5.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d7077ba879f95406459bc0c81f3141c529b34580bc64d7ab7bd15e7118a0391" +checksum = "3500dcf04c84606b38464561edc5e46f5132201cb3e23cf9613ed4033d6b1bb2" dependencies = [ "hstr", "once_cell", - "rustc-hash", - "serde", -] - -[[package]] -name = "swc_cached" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7133338c3bef796430deced151b0eaa5430710a90e38da19e8e3045e8e36eeb" -dependencies = [ - "anyhow", - "dashmap", - "once_cell", - "regex", - "rustc-hash", "serde", ] [[package]] name = "swc_common" -version = "9.2.0" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56b6f5a8e5affa271b56757a93badee6f44defcd28f3ba106bb2603afe40d3d" +checksum = "63fdb58d278e7cd625f671e5371b3e6c0eab56c6e2a995a6f70dd0f7725255d4" dependencies = [ "anyhow", "ast_node", "better_scoped_tls", - "cfg-if", + "bytes-str", "either", "from_variant", "new_debug_unreachable", @@ -1943,10 +1979,9 @@ dependencies = [ "rustc-hash", "serde", "siphasher", - "sourcemap", - "swc_allocator", "swc_atoms", "swc_eq_ignore_macros", + "swc_sourcemap", "swc_visit", "termcolor", "tracing", @@ -1956,19 +1991,18 @@ dependencies = [ [[package]] name = "swc_compiler_base" -version = "19.0.0" +version = "34.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac447d455ed338b84dcd914e790525a12a2a2f91173359e5ac7d62b4915af39" +checksum = "1099ada4b7524c4f6f7cc0c6db24d81f8dfd3163b64dd2b1015437c673057645" dependencies = [ "anyhow", "base64", + "bytes-str", "once_cell", "pathdiff", "rustc-hash", "serde", "serde_json", - "sourcemap", - "swc_allocator", "swc_atoms", "swc_common", "swc_config", @@ -1977,22 +2011,29 @@ dependencies = [ "swc_ecma_minifier", "swc_ecma_parser", "swc_ecma_visit", + "swc_sourcemap", "swc_timer", ] [[package]] name = "swc_config" -version = "2.0.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb63364aebd1a8490a80fa8933825c6916d4df55d5472312d5adb62c9fb4e4ba" +checksum = "d94f41e0f3c4c119a06af5e164674b63ae7eb6d7c1c60e46036c4a548f9fbe44" dependencies = [ "anyhow", + "bytes-str", + "dashmap", + "globset", "indexmap", + "once_cell", + "regex", + "regress", + "rustc-hash", "serde", "serde_json", - "sourcemap", - "swc_cached", "swc_config_macro", + "swc_sourcemap", ] [[package]] @@ -2009,9 +2050,9 @@ dependencies = [ [[package]] name = "swc_core" -version = "23.2.0" +version = "39.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd11a6fb068925bcb493d68ec6f1f35fb28c0bd9052071d22e49d4d60fae8916" +checksum = "56ad087b00477b9d310b5ebfa26acb867be338765558632597976ee56c898b63" dependencies = [ "swc", "swc_allocator", @@ -2038,9 +2079,9 @@ dependencies = [ [[package]] name = "swc_css_ast" -version = "9.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd778bc4e1601c6cc510542f1ec9f63207f4c703738e795b36a2de18eaeaf679" +checksum = "d9fd83077e8da39e58c378ac25003ada5d1931b6823079aa2d48503f5166668d" dependencies = [ "is-macro", "string_enum", @@ -2050,9 +2091,9 @@ dependencies = [ [[package]] name = "swc_css_codegen" -version = "9.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f7422302204a99d0f63c1876a6dd8e8c389c73a9d6838bdef502e74e21c5511" +checksum = "ddaef5c00a714a3c9348fc94fc4b6c755f689a1c36b4ec190870fadf240261aa" dependencies = [ "auto_impl", "bitflags 2.5.0", @@ -2067,21 +2108,19 @@ dependencies = [ [[package]] name = "swc_css_codegen_macros" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50abd25b3b79f18423cdf99b0d11dee24e64496be3b8abe18c10a2c40bd6c91f" +checksum = "d7e32e407d0a010fedb53cf9dfdccf091521a2c9081efc077da647f7c8963741" dependencies = [ - "proc-macro2", "quote", - "swc_macros_common", "syn 2.0.90", ] [[package]] name = "swc_css_parser" -version = "9.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d8f886ca5c6e01f110569661a3b8858b1446b082cb1ebcf7373628a27c6c84" +checksum = "a87cd0258c1c28c592fe738d44e7ad4c7535d48c39df8546225747bdecc982fa" dependencies = [ "lexical", "serde", @@ -2092,25 +2131,24 @@ dependencies = [ [[package]] name = "swc_css_utils" -version = "9.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bdc773abf536501676628aef3138fb5ee0b6e2f74b50b92a55e6d01c71bc6b4" +checksum = "1cd30a941e3c6edc245c5119344e4126e7e21a5a01a10496ff65db3bffeca226" dependencies = [ "once_cell", "rustc-hash", "serde", "serde_json", "swc_atoms", - "swc_common", "swc_css_ast", "swc_css_visit", ] [[package]] name = "swc_css_visit" -version = "9.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "992563fbab95867e30a77abf59b0394cd00a31ecf14688a2da1b7c1c7955880f" +checksum = "92be458e0c9f037d928c3c2ec75a6cb41a68f77bdec4add1110f69a0e85cd70a" dependencies = [ "serde", "swc_atoms", @@ -2121,9 +2159,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "9.0.0" +version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0613d84468a6bb6d45d13c5a3368b37bd21f3067a089f69adac630dcb462a018" +checksum = "65c25af97d53cf8aab66a6c68f3418663313fc969ad267fc2a4d19402c329be1" dependencies = [ "bitflags 2.5.0", "is-macro", @@ -2131,7 +2169,6 @@ dependencies = [ "once_cell", "phf", "rustc-hash", - "scoped-tls", "serde", "string_enum", "swc_atoms", @@ -2142,9 +2179,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "11.0.0" +version = "17.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b01b3de365a86b8f982cc162f257c82f84bda31d61084174a3be37e8ab15c0f4" +checksum = "bcf55c2d7555c93f4945e29f93b7529562be97ba16e60dd94c25724d746174ac" dependencies = [ "ascii", "compact_str", @@ -2153,33 +2190,33 @@ dependencies = [ "once_cell", "regex", "rustc-hash", + "ryu-js", "serde", - "sourcemap", "swc_allocator", "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_codegen_macros", + "swc_sourcemap", "tracing", ] [[package]] name = "swc_ecma_codegen_macros" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e99e1931669a67c83e2c2b4375674f6901d1480994a76aa75b23f1389e6c5076" +checksum = "e276dc62c0a2625a560397827989c82a93fd545fcf6f7faec0935a82cc4ddbb8" dependencies = [ "proc-macro2", - "quote", "swc_macros_common", "syn 2.0.90", ] [[package]] name = "swc_ecma_compat_bugfixes" -version = "13.0.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff1612d4d90df938533b5308634be1228c6bf14d7141c9f7787c99b5b26f4cc" +checksum = "825195e1c14e3e3b78823e51af52ed192e9d52ccb94a81f0449ac48e6cdd1ba2" dependencies = [ "rustc-hash", "swc_atoms", @@ -2195,22 +2232,21 @@ dependencies = [ [[package]] name = "swc_ecma_compat_common" -version = "13.0.0" +version = "21.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611db1605bff05603aacaf5e14f58cf2339991cceef03817bb8ed19010d10506" +checksum = "2949ac4924597be747348639eadedf8e54818fb26641f050d3d78361b15d1e0d" dependencies = [ "swc_common", "swc_ecma_ast", "swc_ecma_utils", "swc_ecma_visit", - "swc_trace_macro", ] [[package]] name = "swc_ecma_compat_es2015" -version = "13.0.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2a2cf0263f34234cfcebde0545e4ed017e1b2b5667792c6902319d75df03110" +checksum = "ec81d1c9807d6aaa75f9eee66a27aaa61d7dabc97b12474bbec55609c63d8f38" dependencies = [ "arrayvec", "indexmap", @@ -2235,11 +2271,10 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2016" -version = "13.0.0" +version = "26.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2c8cce4b0b0acfa156c235eca429d1bbffe3297cb48cd61578908ddcc5a8899" +checksum = "26d08be3aaea9e0cb603a00b958f78c6149ce6fc98d0d9622935821a8dd2a99b" dependencies = [ - "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_transforms_base", @@ -2252,16 +2287,14 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2017" -version = "13.0.0" +version = "26.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4da9ff1172f67c8792b73d97a9c578e7de44b3af7a60991ce87145cf7f5372c8" +checksum = "1b68fc5c6237cdb8bb450672443cd640c2acbc84edc3d097349db33de0051668" dependencies = [ "serde", - "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_transforms_base", - "swc_ecma_transforms_macros", "swc_ecma_utils", "swc_ecma_visit", "swc_trace_macro", @@ -2270,12 +2303,11 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2018" -version = "13.0.0" +version = "26.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "544ef337a40dfa7f3fe7b4c7e65bba99057258f3ecee79fa9052eac59f502b97" +checksum = "0de471037ff0e178a678a852d232206049578dab258b4e4abc57a677f2d8322d" dependencies = [ "serde", - "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_compat_common", @@ -2289,11 +2321,10 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2019" -version = "13.0.0" +version = "26.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e116fb7a5a50251947160862c52596bdd2d8c417a1f9b8eb061d83bdfc699272" +checksum = "9e5cc26969456801ee879a9b79d69b82ddf3ac8ecd0c601d9960f867d3f91a7c" dependencies = [ - "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_transforms_base", @@ -2305,49 +2336,46 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2020" -version = "14.0.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e858e1fc3d5a4299a81ca25028f8a01feca8f1876db6d2e19bbe5a8bac39c8a" +checksum = "6ffd86caa05bc410105d05afe0c2fda17cb85ccba82d08fa72250d686a1ad4a3" dependencies = [ "serde", - "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_compat_es2022", + "swc_ecma_compiler", "swc_ecma_transforms_base", "swc_ecma_utils", "swc_ecma_visit", - "swc_trace_macro", "tracing", ] [[package]] name = "swc_ecma_compat_es2021" -version = "13.0.0" +version = "26.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba25f8d0c7f915525abe4f2efde17c7f04ecd7a1500acc82a36133bef7b9f60" +checksum = "41b9c2e5183b794675e84c0543fe62a3ec3353bf461dd5b1a0e9396c1ef85101" dependencies = [ - "swc_atoms", - "swc_common", "swc_ecma_ast", + "swc_ecma_compiler", "swc_ecma_transforms_base", "swc_ecma_utils", - "swc_ecma_visit", - "swc_trace_macro", "tracing", ] [[package]] name = "swc_ecma_compat_es2022" -version = "14.0.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c412ba2452b20fdcb791448c6606ba43fa84f80e23b0b2fef0cc9ee02794d12c" +checksum = "251f6791226538ac992067316e108b49c90e241e7eb33bc5632d6b0d08c20fd8" dependencies = [ "rustc-hash", "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_compat_common", + "swc_ecma_compiler", "swc_ecma_transforms_base", "swc_ecma_transforms_classes", "swc_ecma_transforms_macros", @@ -2359,10 +2387,27 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es3" -version = "13.0.0" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248256b4708793bc05ddd67a3e5f5096fcb10349ffb147697bddd368311928f3" +dependencies = [ + "swc_common", + "swc_ecma_ast", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_compiler" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "059c8b419ce4a2e432ec1520dde77db3b8f45df552bf0b6bd974d8516986c9eb" +checksum = "d2e2c5abb053281fa1dd99f4ce1e4c062bb18fed4cc24a2eada80d4160212e28" dependencies = [ + "bitflags 2.5.0", + "rustc-hash", + "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_transforms_base", @@ -2374,12 +2419,11 @@ dependencies = [ [[package]] name = "swc_ecma_ext_transforms" -version = "13.0.1" +version = "21.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd377cf6502daf10b2d7428ea35ae959ca3584a7c968c296af3bdd98e70cff12" +checksum = "bf730dc1404ebc2fc6ccbb9e0aa5f25b3a89bd477f8ca79d4fe8257eb0c87742" dependencies = [ "phf", - "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_utils", @@ -2388,18 +2432,17 @@ dependencies = [ [[package]] name = "swc_ecma_lexer" -version = "12.0.0" +version = "23.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d11c8e71901401b9aae2ece4946eeb7674b14b8301a53768afbbeeb0e48b599" +checksum = "67c3bd958a5a67e2cc3f74abdd41fda688e54e7a25b866569260ef7018b67972" dependencies = [ "arrayvec", "bitflags 2.5.0", "either", - "new_debug_unreachable", "num-bigint", - "num-traits", "phf", "rustc-hash", + "seq-macro", "serde", "smallvec", "smartstring", @@ -2408,35 +2451,13 @@ dependencies = [ "swc_common", "swc_ecma_ast", "tracing", - "typed-arena", -] - -[[package]] -name = "swc_ecma_lints" -version = "13.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10710ebbe155fd07b5be28a6af80c6f46c6385feeb3f6b3033d1d5d93b885312" -dependencies = [ - "auto_impl", - "dashmap", - "par-core", - "parking_lot", - "regex", - "rustc-hash", - "serde", - "swc_atoms", - "swc_common", - "swc_config", - "swc_ecma_ast", - "swc_ecma_utils", - "swc_ecma_visit", ] [[package]] name = "swc_ecma_loader" -version = "9.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb574d660c05f3483c984107452b386e45b95531bdb1253794077edc986f413" +checksum = "c675d14700c92f12585049b22b02356f1e142f4b0c32a4d0eb4b7a968a4c0c1e" dependencies = [ "anyhow", "dashmap", @@ -2450,16 +2471,15 @@ dependencies = [ "serde", "serde_json", "swc_atoms", - "swc_cached", "swc_common", "tracing", ] [[package]] name = "swc_ecma_minifier" -version = "17.0.0" +version = "32.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca0ad5b72d8b440e701d47f544a728543414f6f165c6c61a899a76d3c7fdf9d" +checksum = "a018d76f240123a319bd4aed1371126528e226531f829dbb71d03eb372762349" dependencies = [ "arrayvec", "bitflags 2.5.0", @@ -2472,12 +2492,10 @@ dependencies = [ "parking_lot", "phf", "radix_fmt", - "regex", "rustc-hash", "ryu-js", "serde", "serde_json", - "swc_allocator", "swc_atoms", "swc_common", "swc_config", @@ -2495,50 +2513,40 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "12.0.0" +version = "24.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "250786944fbc05f6484eda9213df129ccfe17226ae9ad51b62fce2f72135dbee" +checksum = "37c0b41d7e86acb8abc1e75b39163a1dffd88f75b69d8f89a199dfc416bb46d6" dependencies = [ - "arrayvec", - "bitflags 2.5.0", "either", - "new_debug_unreachable", "num-bigint", - "num-traits", - "phf", - "rustc-hash", "serde", - "smallvec", - "smartstring", - "stacker", "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_lexer", "tracing", - "typed-arena", ] [[package]] name = "swc_ecma_preset_env" -version = "17.0.0" +version = "33.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "551d1b1d3f27e9525b001fba9afd06294a5eaf8a8a9aff85da458a51e790ca1c" +checksum = "f6c425f34110310018f20d53fff5da82da30710b1719b3c24bad87a878a77586" dependencies = [ "anyhow", - "dashmap", + "foldhash", "indexmap", "once_cell", + "precomputed-map", "preset_env_base", "rustc-hash", - "semver", "serde", "serde_json", - "st-map", "string_enum", "swc_atoms", "swc_common", "swc_ecma_ast", + "swc_ecma_compiler", "swc_ecma_transforms", "swc_ecma_utils", "swc_ecma_visit", @@ -2546,9 +2554,9 @@ dependencies = [ [[package]] name = "swc_ecma_quote_macros" -version = "12.0.0" +version = "24.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3221879cd18131a3946f8f29d181fe239b58b6595ccefa7263a9395ad4b5e575" +checksum = "1c8c018ebafab9285b7e3dfd757f28c40345e2dfade4566cf3cd3da81fbd2963" dependencies = [ "anyhow", "proc-macro2", @@ -2564,9 +2572,9 @@ dependencies = [ [[package]] name = "swc_ecma_testing" -version = "10.0.0" +version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "977386a831e9464cc99e914d5682621efca49c443e5c737a00a2babd6d1589aa" +checksum = "bd297865d417cf7e99bf36f4f29928e89ccf3446b56440e110b2f488f6d8d2d0" dependencies = [ "anyhow", "hex", @@ -2577,12 +2585,11 @@ dependencies = [ [[package]] name = "swc_ecma_transforms" -version = "16.0.0" +version = "32.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2813bad599d24b1aeba4c90891703a046d86b681b003863673f2b418dff185" +checksum = "ba40c41079f3e65553a693ff58abce6e90addfb99d8b2b12f7facaa9406db29b" dependencies = [ "par-core", - "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_transforms_base", @@ -2593,24 +2600,21 @@ dependencies = [ "swc_ecma_transforms_react", "swc_ecma_transforms_typescript", "swc_ecma_utils", - "swc_ecma_visit", ] [[package]] name = "swc_ecma_transforms_base" -version = "13.0.0" +version = "26.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6856da3da598f4da001b7e4ce225ee8970bc9d5cbaafcaf580190cf0a6031ec5" +checksum = "b6db893332e61360b330063c0d0e67d61b777832ece3980096fa8ad05c0101bd" dependencies = [ "better_scoped_tls", - "bitflags 2.5.0", "indexmap", "once_cell", "par-core", "phf", "rustc-hash", "serde", - "smallvec", "swc_atoms", "swc_common", "swc_ecma_ast", @@ -2622,11 +2626,10 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_classes" -version = "13.0.0" +version = "26.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f84248f82bad599d250bbcd52cb4db6ff6409f48267fd6f001302a2e9716f80" +checksum = "7ad4c8c59a000e0bd587f94afb51eb9caad6a42d07f41b75c56d8bf6276e1bae" dependencies = [ - "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_transforms_base", @@ -2636,20 +2639,15 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_compat" -version = "14.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "012cd84fcc6c6fab718a177a3ffc360332d6bad29dbe19699be2ccbaba91e712" +checksum = "f4eeb14f20ca165416ca09afdb83376c077b113a5bad37100d2d5626ab657456" dependencies = [ - "arrayvec", "indexmap", - "is-macro", - "num-bigint", "par-core", "serde", - "smallvec", "swc_atoms", "swc_common", - "swc_config", "swc_ecma_ast", "swc_ecma_compat_bugfixes", "swc_ecma_compat_common", @@ -2663,19 +2661,16 @@ dependencies = [ "swc_ecma_compat_es2022", "swc_ecma_compat_es3", "swc_ecma_transforms_base", - "swc_ecma_transforms_classes", - "swc_ecma_transforms_macros", "swc_ecma_utils", "swc_ecma_visit", - "swc_trace_macro", "tracing", ] [[package]] name = "swc_ecma_transforms_macros" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6845dfb88569f3e8cd05901505916a8ebe98be3922f94769ca49f84e8ccec8f7" +checksum = "bc777288799bf6786e5200325a56e4fbabba590264a4a48a0c70b16ad0cf5cd8" dependencies = [ "proc-macro2", "quote", @@ -2685,9 +2680,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_module" -version = "14.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4653a46bffad40875469a0b75f0b9c8f1e019ca7014a45e876c3a10aadd58721" +checksum = "ea2b562a6db48b8ce932d54227ceab243137eb5220e0455937b1032b947b4cda" dependencies = [ "Inflector", "anyhow", @@ -2700,8 +2695,8 @@ dependencies = [ "rustc-hash", "serde", "swc_atoms", - "swc_cached", "swc_common", + "swc_config", "swc_ecma_ast", "swc_ecma_loader", "swc_ecma_parser", @@ -2713,10 +2708,11 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "13.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5874d0c808f0e658882edf00fef3d206f01a22781c48ca9b1795cf025cc9650" +checksum = "8ecb86ae16f150aa4fbc46bd37d6cce44612af59861afa987ab3053f17d343b1" dependencies = [ + "bytes-str", "dashmap", "indexmap", "once_cell", @@ -2729,7 +2725,6 @@ dependencies = [ "swc_ecma_ast", "swc_ecma_parser", "swc_ecma_transforms_base", - "swc_ecma_transforms_macros", "swc_ecma_utils", "swc_ecma_visit", "tracing", @@ -2737,55 +2732,51 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_proposal" -version = "13.0.0" +version = "26.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193237e318421ef621c2b3958b4db174770c5280ef999f1878f2df93a2837ca6" +checksum = "b7cd9f54f3e7b3efb0e30e80f9efeaf99cd4d66ff0b83fda6dcfcbc0e293a767" dependencies = [ "either", "rustc-hash", "serde", - "smallvec", "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_transforms_base", "swc_ecma_transforms_classes", - "swc_ecma_transforms_macros", "swc_ecma_utils", "swc_ecma_visit", ] [[package]] name = "swc_ecma_transforms_react" -version = "14.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17564ef28b1183a5d79f890066f11aba4563f390708cb03a6738cbc24799210" +checksum = "3c9939e0a5a23529b63ac87d7a9981dba7f7021b7cb64ecf9039f3dfb0abb48c" dependencies = [ "base64", - "dashmap", + "bytes-str", "indexmap", "once_cell", "rustc-hash", "serde", "sha1", "string_enum", - "swc_allocator", "swc_atoms", "swc_common", "swc_config", "swc_ecma_ast", "swc_ecma_parser", "swc_ecma_transforms_base", - "swc_ecma_transforms_macros", "swc_ecma_utils", "swc_ecma_visit", ] [[package]] name = "swc_ecma_transforms_testing" -version = "16.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93a905befc831be30430ab1e4af5aa6f2052ea397f44e1747c28a4d3859f4f84" +checksum = "b394293ee1a70c986aac9282d606cfb05d0ee81f7f48958e3975e33886bd8745" dependencies = [ "ansi_term", "anyhow", @@ -2794,8 +2785,6 @@ dependencies = [ "serde", "serde_json", "sha2", - "sourcemap", - "swc_allocator", "swc_common", "swc_ecma_ast", "swc_ecma_codegen", @@ -2804,19 +2793,19 @@ dependencies = [ "swc_ecma_transforms_base", "swc_ecma_utils", "swc_ecma_visit", + "swc_sourcemap", "tempfile", "testing", ] [[package]] name = "swc_ecma_transforms_typescript" -version = "14.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a647a99548ead69e5e87cf2b7caa7921e8a81e252e13e3180c3101a1d911fa6b" +checksum = "52079079848d95fdfe3634d06b40bdb47865ffbedd9b3c2cf63a8d91dec5eebf" dependencies = [ - "once_cell", + "bytes-str", "rustc-hash", - "ryu-js", "serde", "swc_atoms", "swc_common", @@ -2829,9 +2818,9 @@ dependencies = [ [[package]] name = "swc_ecma_usage_analyzer" -version = "14.0.0" +version = "22.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d7858f1eccac3c8a85b97ba3820020583efa28bc766d253f0a93d7bbc54c985" +checksum = "8031a4473e5366165f23766f5bc8361c45e8ed57f7475c0227147727cbaf3342" dependencies = [ "bitflags 2.5.0", "indexmap", @@ -2847,15 +2836,14 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "13.1.0" +version = "21.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ed837406d5dbbfbf5792b1dc90964245a0cf659753d4745fe177ffebe8598b9" +checksum = "83259addd99ed4022aa9fc4d39428c008d3d42533769e1a005529da18cde4568" dependencies = [ "indexmap", "num_cpus", "once_cell", "par-core", - "par-iter", "rustc-hash", "ryu-js", "swc_atoms", @@ -2863,14 +2851,13 @@ dependencies = [ "swc_ecma_ast", "swc_ecma_visit", "tracing", - "unicode-id", ] [[package]] name = "swc_ecma_visit" -version = "9.0.0" +version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "249dc9eede1a4ad59a038f9cfd61ce67845bd2c1392ade3586d714e7181f3c1a" +checksum = "75a579aa8f9e212af521588df720ccead079c09fe5c8f61007cf724324aed3a0" dependencies = [ "new_debug_unreachable", "num-bigint", @@ -2883,9 +2870,9 @@ dependencies = [ [[package]] name = "swc_eq_ignore_macros" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96e15288bf385ab85eb83cff7f9e2d834348da58d0a31b33bdb572e66ee413e" +checksum = "c16ce73424a6316e95e09065ba6a207eba7765496fed113702278b7711d4b632" dependencies = [ "proc-macro2", "quote", @@ -2894,25 +2881,22 @@ dependencies = [ [[package]] name = "swc_error_reporters" -version = "11.0.0" +version = "16.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5be5f151485ec9372c23bbb132c4a829c879632db8b790439779b873970be" +checksum = "b7a16e3c08fd820735631820a7c220d5ce39bdc08b83eddbc73a645ef744511e" dependencies = [ "anyhow", "miette", "once_cell", - "parking_lot", "serde", - "serde_derive", - "serde_json", "swc_common", ] [[package]] name = "swc_macros_common" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a509f56fca05b39ba6c15f3e58636c3924c78347d63853632ed2ffcb6f5a0ac7" +checksum = "aae1efbaa74943dc5ad2a2fb16cbd78b77d7e4d63188f3c5b4df2b4dcd2faaae" dependencies = [ "proc-macro2", "quote", @@ -2921,9 +2905,9 @@ dependencies = [ [[package]] name = "swc_node_comments" -version = "9.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b9ded5a3355c56eb1148491c70bd4f85f7fcb706d40c0a86a67260cbcb560c3" +checksum = "6bf07db306bc7e19b8fc46702e8298419d12f587bd4724858bc9889fef8f3e72" dependencies = [ "dashmap", "rustc-hash", @@ -2931,6 +2915,25 @@ dependencies = [ "swc_common", ] +[[package]] +name = "swc_sourcemap" +version = "9.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de08ef00f816acdd1a58ee8a81c0e1a59eefef2093aefe5611f256fa6b64c4d7" +dependencies = [ + "base64-simd", + "bitvec", + "bytes-str", + "data-encoding", + "debugid", + "if_chain", + "rustc-hash", + "serde", + "serde_json", + "unicode-id-start", + "url", +] + [[package]] name = "swc_timer" version = "1.0.0" @@ -2942,51 +2945,31 @@ dependencies = [ [[package]] name = "swc_trace_macro" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "559185db338f1bcb50297aafd4f79c0956c84dc71a66da4cffb57acf9d93fd88" +checksum = "dfd2b4b0adb82e36f2ac688d00a6a67132c7f4170c772617516793a701be89e8" dependencies = [ - "proc-macro2", "quote", "syn 2.0.90", ] [[package]] name = "swc_transform_common" -version = "3.0.0" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d73c21cecc518e0107f890012a747fa679cb0faf04f32fc8f5bd618040eb8fe" +checksum = "ca33f282df60eefee05511c9aaf557696d2f9f0e22f4a5abca318da10c22f1cc" dependencies = [ "better_scoped_tls", - "once_cell", "rustc-hash", "serde", - "serde_json", - "swc_common", -] - -[[package]] -name = "swc_typescript" -version = "12.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c01b8c9b645f4b3b39664477166876bdc239c9b5f785389e117dee822dbcec5" -dependencies = [ - "bitflags 2.5.0", - "petgraph", - "rustc-hash", - "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_utils", - "swc_ecma_visit", - "thiserror 1.0.69", ] [[package]] name = "swc_visit" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9138b6a36bbe76dd6753c4c0794f7e26480ea757bee499738bedbbb3ae3ec5f3" +checksum = "62fb71484b486c185e34d2172f0eabe7f4722742aad700f426a494bb2de232a2" dependencies = [ "either", "new_debug_unreachable", @@ -3055,11 +3038,10 @@ dependencies = [ [[package]] name = "testing" -version = "10.0.0" +version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "987241734b96bd71228f0395ab38e05b71ec7c6ded958538c5d3a1b67f6465ce" +checksum = "cb14720ff995a98916e7fafc6771242727ed1ac5f2725059f03f203586d8ca1b" dependencies = [ - "ansi_term", "cargo_metadata 0.18.1", "difference", "once_cell", @@ -3077,9 +3059,9 @@ dependencies = [ [[package]] name = "testing_macros" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d27bf245b90a80d5aa231133418ae7db98f032855ce5292e12071ab29c4b26" +checksum = "b7442bd3ca09f38d4788dc5ebafbc1967c3717726b4b074db011d470b353548b" dependencies = [ "anyhow", "glob", @@ -3231,24 +3213,12 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "typed-arena" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" - [[package]] name = "typenum" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" -[[package]] -name = "unicode-id" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d70b6494226b36008c8366c288d77190b3fad2eb4c10533139c1c1f461127f1a" - [[package]] name = "unicode-id-start" version = "1.3.1" @@ -3367,6 +3337,24 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.14.5+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4" +dependencies = [ + "wasip2", +] + +[[package]] +name = "wasip2" +version = "1.0.0+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "wasm-bindgen" version = "0.2.101" @@ -3605,6 +3593,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +[[package]] +name = "wit-bindgen" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36" + [[package]] name = "write16" version = "1.0.0" @@ -3658,18 +3652,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 07ddcfeca1..b91be8c193 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ rustc-hash = "2.1.1" serde = "1.0.217" serde_json = "1.0.134" sha-1 = "0.10.1" -swc_core = "23.2.0" +swc_core = "39.0.3" version-compare = "0.2.0" wasm-bindgen = "0.2.101" diff --git a/benchmark/react/plugins/pluginScriptLoad.mjs b/benchmark/react/plugins/pluginScriptLoad.mjs index f5678bec28..7d824dfc13 100644 --- a/benchmark/react/plugins/pluginScriptLoad.mjs +++ b/benchmark/react/plugins/pluginScriptLoad.mjs @@ -24,7 +24,9 @@ const runAfterLoadScript = (() => { r.flush = () => { for (const cb of q) { cb(); } }; return r; })(); -Codspeed.startBenchmark(); +if (typeof Codspeed !== "undefined") { + Codspeed.startBenchmark(); +} `; }, }), @@ -40,8 +42,10 @@ Codspeed.startBenchmark(); const chunkName = filename.replace(/^\.rspeedy\//, ''); // dprint-ignore return `\ -Codspeed.stopBenchmark(); -Codspeed.setExecutedBenchmark(\`${caseDir}::\${${JSON.stringify(chunkName)}}_LoadScript\`); +if (typeof Codspeed !== "undefined") { + Codspeed.stopBenchmark(); + Codspeed.setExecutedBenchmark(\`${caseDir}::\${${JSON.stringify(chunkName)}}_LoadScript\`); +} runAfterLoadScript.flush(); `; }, diff --git a/eslint.config.js b/eslint.config.js index 1354e2819d..d380a7e08f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -217,7 +217,7 @@ export default tseslint.config( 'error', { ignoreCase: false, - ignoreDeclarationSort: true, // don"t want to sort import lines, use eslint-plugin-import instead + ignoreDeclarationSort: true, // don't want to sort import lines, use eslint-plugin-import instead ignoreMemberSort: false, memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], allowSeparatedGroups: true, diff --git a/packages/react/runtime/__test__/worklet/runOnMainThread.test.js b/packages/react/runtime/__test__/worklet/runOnMainThread.test.js deleted file mode 100644 index cfc0bf5b4e..0000000000 --- a/packages/react/runtime/__test__/worklet/runOnMainThread.test.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2024 The Lynx Authors. All rights reserved. -// Licensed under the Apache License Version 2.0 that can be found in the -// LICENSE file in the root directory of this source tree. -import { afterEach, beforeEach, describe, expect, it } from 'vitest'; - -import { WorkletEvents } from '@lynx-js/react/worklet-runtime/bindings'; - -import { destroyWorklet } from '../../src/worklet/destroy'; -import { clearConfigCacheForTesting } from '../../src/worklet/functionality'; -import { runOnMainThread } from '../../src/worklet/runOnMainThread'; -import { globalEnvManager } from '../utils/envManager'; - -beforeEach(() => { - globalThis.SystemInfo.lynxSdkVersion = '2.14'; - clearConfigCacheForTesting(); -}); - -afterEach(() => { - destroyWorklet(); -}); - -describe('runOnMainThread', () => { - it('should trigger event', () => { - globalEnvManager.switchToBackground(); - const worklet = { - _wkltId: '835d:450ef:2', - }; - runOnMainThread(worklet)(1, ['args']); - expect(lynx.getCoreContext().dispatchEvent.mock.calls).toMatchInlineSnapshot(` - [ - [ - { - "data": "{"worklet":{"_wkltId":"835d:450ef:2"},"params":[1,["args"]],"resolveId":1}", - "type": "Lynx.Worklet.runWorkletCtx", - }, - ], - ] - `); - }); - - it('should get return value', async () => { - globalEnvManager.switchToBackground(); - const promise = runOnMainThread('someWorklet')('hello'); - - globalEnvManager.switchToMainThread(); - lynx.getJSContext().dispatchEvent({ - type: WorkletEvents.FunctionCallRet, - data: JSON.stringify({ - resolveId: 1, - returnValue: 'world', - }), - }); - - await expect(promise).resolves.toBe('world'); - }); - - it('should throw when on the main thread', () => { - globalEnvManager.switchToMainThread(); - const worklet = { - _wkltId: '835d:450ef:2', - }; - expect(() => { - runOnMainThread(worklet)(1, ['args']); - }).toThrowError('runOnMainThread can only be used on the background thread.'); - }); - - it('should not trigger event when native capabilities not fulfilled', () => { - globalThis.SystemInfo.lynxSdkVersion = '2.13'; - globalEnvManager.switchToBackground(); - const worklet = { - _wkltId: '835d:450ef:2', - }; - expect(() => { - runOnMainThread(worklet)(1, ['args']); - }).toThrowError('runOnMainThread requires Lynx sdk version 2.14.'); - }); -}); diff --git a/packages/react/runtime/__test__/worklet/runOnMainThread.test.jsx b/packages/react/runtime/__test__/worklet/runOnMainThread.test.jsx new file mode 100644 index 0000000000..e386f00f0f --- /dev/null +++ b/packages/react/runtime/__test__/worklet/runOnMainThread.test.jsx @@ -0,0 +1,323 @@ +// Copyright 2024 The Lynx Authors. All rights reserved. +// Licensed under the Apache License Version 2.0 that can be found in the +// LICENSE file in the root directory of this source tree. + +import { render } from 'preact'; +import { afterEach, beforeEach, describe, expect, it, vi, beforeAll } from 'vitest'; + +import { WorkletEvents } from '@lynx-js/react/worklet-runtime/bindings'; + +import { destroyWorklet } from '../../src/worklet/destroy'; +import { clearConfigCacheForTesting } from '../../src/worklet/functionality'; +import { runOnMainThread } from '../../src/worklet/runOnMainThread'; +import { globalEnvManager } from '../utils/envManager'; +import { initGlobalSnapshotPatch } from '../../src/lifecycle/patch/snapshotPatch'; +import { replaceCommitHook } from '../../src/lifecycle/patch/commit'; +import { __root } from '../../src/root'; +import { root } from '../../src/lynx-api'; +import { waitSchedule } from '../utils/nativeMethod'; + +const App = ({ fn, attr }) => { + fn?.(); + return ( + + hello + + ); +}; + +const MTFQueue = []; + +beforeAll(() => { + vi.stubGlobal( + 'runWorklet', + vi.fn((worklet, args) => { + MTFQueue.push({ api: 'runWorklet', worklet, args }); + }), + ); + vi.stubGlobal('lynxWorkletImpl', { + _runRunOnMainThreadTask: vi.fn((worklet, args) => { + MTFQueue.push({ api: '_runRunOnMainThreadTask', worklet, args }); + }), + _runOnBackgroundDelayImpl: { + runDelayedBackgroundFunctions: vi.fn(), + }, + _eomImpl: { + setShouldFlush: vi.fn((value) => { + MTFQueue.push({ api: 'setShouldFlush', value }); + }), + }, + _refImpl: { + clearFirstScreenWorkletRefMap: vi.fn(), + }, + _eventDelayImpl: { + clearDelayedWorklets: vi.fn(), + runDelayedWorklet: vi.fn(), + }, + }); + vi.stubGlobal( + '__FlushElementTree', + vi.fn(() => { + MTFQueue.push({ api: '__FlushElementTree' }); + }), + ); +}); + +beforeEach(() => { + globalThis.SystemInfo.lynxSdkVersion = '2.14'; + clearConfigCacheForTesting(); + globalEnvManager.resetEnv(); + replaceCommitHook(); +}); + +afterEach(() => { + destroyWorklet(); + vi.resetAllMocks(); + MTFQueue.length = 0; +}); + +describe('runOnMainThread', () => { + it('should trigger event', () => { + globalEnvManager.switchToBackground(); + initGlobalSnapshotPatch(); + const worklet = { + _wkltId: '835d:450ef:2', + }; + runOnMainThread(worklet)(1, ['args']); + expect(lynx.getCoreContext().dispatchEvent.mock.calls).toMatchInlineSnapshot(` + [ + [ + { + "data": "{"worklet":{"_wkltId":"835d:450ef:2"},"params":[1,["args"]],"resolveId":1}", + "type": "Lynx.Worklet.runWorkletCtx", + }, + ], + ] + `); + }); + + it('should get return value', async () => { + globalEnvManager.switchToBackground(); + initGlobalSnapshotPatch(); + const promise = runOnMainThread('someWorklet')('hello'); + + globalEnvManager.switchToMainThread(); + lynx.getJSContext().dispatchEvent({ + type: WorkletEvents.FunctionCallRet, + data: JSON.stringify({ + resolveId: 1, + returnValue: 'world', + }), + }); + + await expect(promise).resolves.toBe('world'); + }); + + it('should throw when on the main thread', () => { + globalEnvManager.switchToMainThread(); + const worklet = { + _wkltId: '835d:450ef:2', + }; + expect(() => { + runOnMainThread(worklet)(1, ['args']); + }).toThrowError('runOnMainThread can only be used on the background thread.'); + }); + + it('should not trigger event when native capabilities not fulfilled', () => { + globalThis.SystemInfo.lynxSdkVersion = '2.13'; + globalEnvManager.switchToBackground(); + initGlobalSnapshotPatch(); + const worklet = { + _wkltId: '835d:450ef:2', + }; + expect(() => { + runOnMainThread(worklet)(1, ['args']); + }).toThrowError('runOnMainThread requires Lynx sdk version 2.14.'); + }); + + it('should delay until hydration finished while initial rendering', async () => { + const MTF_during_render = 'MTF_during_render'; + const MTF_after_render = 'MTF_after_render'; + + // 1. MTS init render + { + __root.__jsx = ; + renderPage(); + } + + // 2. hydration + { + globalEnvManager.switchToBackground(); + root.render(); + await waitSchedule(); + runOnMainThread(MTF_after_render)(); + } + + // 3. check MTFs are not invoked + { + expect(MTFQueue).toMatchInlineSnapshot(`[]`); + expect(lynx.getCoreContext().dispatchEvent.mock.calls).toMatchInlineSnapshot(`[]`); + MTFQueue.length = 0; + } + + // 4. hydrate + { + // LifecycleConstant.firstScreen + lynxCoreInject.tt.OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]); + + // rLynxChange + globalEnvManager.switchToMainThread(); + const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0]; + globalThis[rLynxChange[0]](rLynxChange[1]); + lynx.getNativeApp().callLepusMethod.mockClear(); + } + + // 5. check MTFs are invoked + { + expect(MTFQueue).toMatchInlineSnapshot(` + [ + { + "api": "runWorklet", + "args": [ + { + "elementRefptr": + + , + }, + ], + "worklet": { + "_unmount": undefined, + "_wkltId": "MTRef", + }, + }, + { + "api": "setShouldFlush", + "value": false, + }, + { + "api": "_runRunOnMainThreadTask", + "args": [], + "worklet": "MTF_during_render", + }, + { + "api": "_runRunOnMainThreadTask", + "args": [], + "worklet": "MTF_after_render", + }, + { + "api": "setShouldFlush", + "value": true, + }, + { + "api": "__FlushElementTree", + }, + ] + `); + expect(lynx.getCoreContext().dispatchEvent.mock.calls).toMatchInlineSnapshot(`[]`); + } + }); + + it('should delay until patch applying finished while updating', async () => { + const MTF_during_render = 'MTF_during_render'; + + // 1. MTS init render + { + __root.__jsx = ; + renderPage(); + } + + // 2. hydration + { + globalEnvManager.switchToBackground(); + root.render(); + await waitSchedule(); + } + + // 3. hydrate + { + // LifecycleConstant.firstScreen + lynxCoreInject.tt.OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]); + + // rLynxChange + globalEnvManager.switchToMainThread(); + const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0]; + globalThis[rLynxChange[0]](rLynxChange[1]); + lynx.getNativeApp().callLepusMethod.mockClear(); + } + + // 4. check MTFs are not invoked + { + expect(MTFQueue).toMatchInlineSnapshot(` + [ + { + "api": "__FlushElementTree", + }, + ] + `); + expect(lynx.getCoreContext().dispatchEvent.mock.calls).toMatchInlineSnapshot(`[]`); + MTFQueue.length = 0; + } + + // 5. BTS update + { + globalEnvManager.switchToBackground(); + render( + , + __root, + ); + + // rLynxChange + globalEnvManager.switchToMainThread(); + const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0]; + globalThis[rLynxChange[0]](rLynxChange[1]); + lynx.getNativeApp().callLepusMethod.mockClear(); + } + + // 6. check MTFs are invoked + { + expect(MTFQueue).toMatchInlineSnapshot(` + [ + { + "api": "runWorklet", + "args": [ + { + "elementRefptr": + + , + }, + ], + "worklet": { + "_unmount": undefined, + "_wkltId": "MTRef", + }, + }, + { + "api": "setShouldFlush", + "value": false, + }, + { + "api": "_runRunOnMainThreadTask", + "args": [], + "worklet": "MTF_during_render", + }, + { + "api": "setShouldFlush", + "value": true, + }, + { + "api": "__FlushElementTree", + }, + ] + `); + expect(lynx.getCoreContext().dispatchEvent.mock.calls).toMatchInlineSnapshot(`[]`); + } + }); +}); diff --git a/packages/react/runtime/lazy/internal.js b/packages/react/runtime/lazy/internal.js index 613ccf4863..6508e6cd0a 100644 --- a/packages/react/runtime/lazy/internal.js +++ b/packages/react/runtime/lazy/internal.js @@ -22,6 +22,7 @@ export const { loadLazyBundle, loadWorkletRuntime, options, + process, registerWorkletOnBackground, snapshotCreateList, snapshotManager, diff --git a/packages/react/runtime/src/internal.ts b/packages/react/runtime/src/internal.ts index 5f3140f461..253672adad 100644 --- a/packages/react/runtime/src/internal.ts +++ b/packages/react/runtime/src/internal.ts @@ -38,6 +38,7 @@ export { options, // Component is not an internal API, but refresh needs it from 'react/internal' Component, + process, } from 'preact'; export type { Options } from 'preact'; diff --git a/packages/react/runtime/src/lifecycle/patch/commit.ts b/packages/react/runtime/src/lifecycle/patch/commit.ts index f93f908571..f87a5fca6d 100644 --- a/packages/react/runtime/src/lifecycle/patch/commit.ts +++ b/packages/react/runtime/src/lifecycle/patch/commit.ts @@ -21,6 +21,8 @@ import { options } from 'preact'; +import type { RunWorkletCtxData } from '@lynx-js/react/worklet-runtime/bindings'; + import { LifecycleConstant } from '../../lifecycleConstant.js'; import { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../lynx/performance.js'; import { COMMIT } from '../../renderToOpcodes/constants.js'; @@ -32,6 +34,7 @@ import { getReloadVersion } from '../pass.js'; import type { SnapshotPatch } from './snapshotPatch.js'; import { takeGlobalSnapshotPatch } from './snapshotPatch.js'; import { profileEnd, profileStart } from '../../debug/utils.js'; +import { delayedRunOnMainThreadData, takeDelayedRunOnMainThreadData } from '../../worklet/runOnMainThread.js'; import { isRendering } from '../isRendering.js'; let globalFlushOptions: FlushOptions = {}; @@ -62,6 +65,7 @@ interface Patch { */ interface PatchList { patchList: Patch[]; + delayedRunOnMainThreadData?: RunWorkletCtxData[]; flushOptions?: FlushOptions; } @@ -156,6 +160,9 @@ function replaceCommitHook(): void { if (!isEmptyObject(flushOptions)) { patchList.flushOptions = flushOptions; } + if (snapshotPatch && delayedRunOnMainThreadData.length) { + patchList.delayedRunOnMainThreadData = takeDelayedRunOnMainThreadData(); + } const obj = commitPatchUpdate(patchList, patchOptions); // Send the update to the native layer diff --git a/packages/react/runtime/src/lifecycle/patch/updateMainThread.ts b/packages/react/runtime/src/lifecycle/patch/updateMainThread.ts index 3d8776b6da..c15ce37f1d 100644 --- a/packages/react/runtime/src/lifecycle/patch/updateMainThread.ts +++ b/packages/react/runtime/src/lifecycle/patch/updateMainThread.ts @@ -2,7 +2,12 @@ // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. -import { updateWorkletRefInitValueChanges } from '@lynx-js/react/worklet-runtime/bindings'; +import type { ClosureValueType } from '@lynx-js/react/worklet-runtime/bindings'; +import { + runRunOnMainThreadTask, + setEomShouldFlushElementTree, + updateWorkletRefInitValueChanges, +} from '@lynx-js/react/worklet-runtime/bindings'; import type { PatchList, PatchOptions } from './commit.js'; import { setMainThreadHydrating } from './isMainThreadHydrating.js'; @@ -12,6 +17,7 @@ import { markTiming, setPipeline } from '../../lynx/performance.js'; import { __pendingListUpdates } from '../../pendingListUpdates.js'; import { applyRefQueue } from '../../snapshot/workletRef.js'; import { __page } from '../../snapshot.js'; +import { isMtsEnabled } from '../../worklet/functionality.js'; import { getReloadVersion } from '../pass.js'; function updateMainThread( @@ -36,7 +42,7 @@ function updateMainThread( setPipeline(patchOptions.pipelineOptions); markTiming('mtsRenderStart'); markTiming('parseChangesStart'); - const { patchList, flushOptions = {} } = JSON.parse(data) as PatchList; + const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = JSON.parse(data) as PatchList; markTiming('parseChangesEnd'); markTiming('patchChangesStart'); @@ -62,6 +68,18 @@ function updateMainThread( } } applyRefQueue(); + if (delayedRunOnMainThreadData && isMtsEnabled()) { + setEomShouldFlushElementTree(false); + for (const data of delayedRunOnMainThreadData) { + try { + runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId); + /* v8 ignore next 3 */ + } catch (e) { + lynx.reportError(e as Error); + } + } + setEomShouldFlushElementTree(true); + } if (patchOptions.pipelineOptions) { flushOptions.pipelineOptions = patchOptions.pipelineOptions; } diff --git a/packages/react/runtime/src/lynx/tt.ts b/packages/react/runtime/src/lynx/tt.ts index f29c5ad262..9a6403180e 100644 --- a/packages/react/runtime/src/lynx/tt.ts +++ b/packages/react/runtime/src/lynx/tt.ts @@ -22,6 +22,7 @@ import { __root } from '../root.js'; import { backgroundSnapshotInstanceManager } from '../snapshot.js'; import type { SerializedSnapshotInstance } from '../snapshot.js'; import { destroyWorklet } from '../worklet/destroy.js'; +import { delayedRunOnMainThreadData, takeDelayedRunOnMainThreadData } from '../worklet/runOnMainThread.js'; export { runWithForce }; @@ -120,6 +121,9 @@ function onLifecycleEventImpl(type: LifecycleConstant, data: unknown): void { const patchList: PatchList = { patchList: [{ snapshotPatch, id: commitTaskId }], }; + if (delayedRunOnMainThreadData.length) { + patchList.delayedRunOnMainThreadData = takeDelayedRunOnMainThreadData(); + } const obj = commitPatchUpdate(patchList, { isHydration: true }); lynx.getNativeApp().callLepusMethod(LifecycleConstant.patchUpdate, obj, () => { diff --git a/packages/react/runtime/src/worklet/runOnMainThread.ts b/packages/react/runtime/src/worklet/runOnMainThread.ts index 5b3154a382..17cb839bfd 100644 --- a/packages/react/runtime/src/worklet/runOnMainThread.ts +++ b/packages/react/runtime/src/worklet/runOnMainThread.ts @@ -7,6 +7,16 @@ import { WorkletEvents } from '@lynx-js/react/worklet-runtime/bindings'; import { onPostWorkletCtx } from './ctx.js'; import { isMtsEnabled } from './functionality.js'; import { onFunctionCall } from './functionCall.js'; +import { isRendering } from '../lifecycle/isRendering.js'; +import { __globalSnapshotPatch } from '../lifecycle/patch/snapshotPatch.js'; + +export let delayedRunOnMainThreadData: RunWorkletCtxData[] = []; + +export function takeDelayedRunOnMainThreadData(): typeof delayedRunOnMainThreadData { + const data = delayedRunOnMainThreadData; + delayedRunOnMainThreadData = []; + return data; +} /** * `runOnMainThread` allows triggering main thread functions on the main thread asynchronously. @@ -37,13 +47,19 @@ export function runOnMainThread R>(fn: Fn): (. return new Promise((resolve) => { onPostWorkletCtx(fn as any as Worklet); const resolveId = onFunctionCall(resolve); + const data = { + worklet: fn as any as Worklet, + params, + resolveId, + } as RunWorkletCtxData; + if (__globalSnapshotPatch === undefined || isRendering.value) { + // before hydration or is rendering + delayedRunOnMainThreadData.push(data); + return; + } lynx.getCoreContext().dispatchEvent({ type: WorkletEvents.runWorkletCtx, - data: JSON.stringify({ - worklet: fn as any as Worklet, - params, - resolveId, - } as RunWorkletCtxData), + data: JSON.stringify(data), }); }); }; diff --git a/packages/react/transform/Cargo.toml b/packages/react/transform/Cargo.toml index 3e277299f5..2871c9d475 100644 --- a/packages/react/transform/Cargo.toml +++ b/packages/react/transform/Cargo.toml @@ -23,8 +23,7 @@ swc_core = { workspace = true, features = ["base", "ecma_codegen", "ecma_parser" version-compare = { workspace = true } [target."cfg(all(target_arch = \"wasm32\", target_os = \"unknown\"))".dependencies.getrandom] -version = "0.2.15" -features = ["custom"] +version = "0.3.3" [build-dependencies] napi-build = "2.1.3" diff --git a/packages/react/transform/__test__/basic.bench.js b/packages/react/transform/__test__/basic.bench.js index b992aba7e2..2fd94169ce 100644 --- a/packages/react/transform/__test__/basic.bench.js +++ b/packages/react/transform/__test__/basic.bench.js @@ -35,4 +35,46 @@ export function App() { bench('transform 1000 view elements', async () => { await transformReactLynx(largeInputContent, config); }); + + const largeInputContentWithEvent = ` +export function App() { + return ( + + ${Array.from({ length: 1000 }, () => ' void 0} />').join('\n ')} + + ); +}`; + + bench('transform 1000 view elements with event', async () => { + await transformReactLynx(largeInputContentWithEvent, config); + }); + + const largeInputContentWithChildren = ` +export function App() { + return ( + + ${Array.from({ length: 1000 }, () => '{content}').join('\n ')} + + ); +}`; + + bench('transform 1000 view elements with Children', async () => { + await transformReactLynx(largeInputContentWithChildren, config); + }); + + const largeInputContentWithEffect = ` +import { useEffect } from '@lynx-js/react'; + +export function App() { + ${Array.from({ length: 1000 }, () => 'useEffect(() => { console.log("effect") })').join('\n ')} + return ( + + + + ); +}`; + + bench('transform 1000 effects', async () => { + await transformReactLynx(largeInputContentWithEffect, config); + }); }); diff --git a/packages/react/transform/__test__/fixture.spec.js b/packages/react/transform/__test__/fixture.spec.js index 34644fbd6c..10e29e62eb 100644 --- a/packages/react/transform/__test__/fixture.spec.js +++ b/packages/react/transform/__test__/fixture.spec.js @@ -225,14 +225,14 @@ describe('errors and warnings', () => { "errors": [ { "location": { - "column": 1, + "column": 7, "file": "", - "length": 4, + "length": 0, "line": 1, "lineText": ";", }, "pluginName": "", - "text": "Unexpected token \`view\`. Expected jsx identifier", + "text": "Expected ''", }, ], "warnings": [], @@ -699,14 +699,14 @@ describe('transformBundle', () => { [ { "location": { - "column": 11, + "column": 31, "file": "", - "length": 3, + "length": 0, "line": 1, "lineText": "const p = Promise.all([]);", }, "pluginName": "", - "text": "Unexpected token \`any\`. Expected jsx identifier", + "text": "Expected ''", }, ] `); diff --git a/packages/react/transform/scripts/build_wasm.js b/packages/react/transform/scripts/build_wasm.js index 10ab950bb7..0d6ee351ae 100644 --- a/packages/react/transform/scripts/build_wasm.js +++ b/packages/react/transform/scripts/build_wasm.js @@ -18,7 +18,7 @@ await fs.mkdir('dist', { recursive: true }); execSync(`cargo build --release --target wasm32-unknown-unknown --features noop`, { env: { ...process.env, - RUSTFLAGS: '-C link-arg=--export-table -C link-arg=-s', + RUSTFLAGS: '-C link-arg=--export-table -C link-arg=-s --cfg getrandom_backend="custom"', }, stdio: 'inherit', }); diff --git a/packages/react/transform/src/bundle.rs b/packages/react/transform/src/bundle.rs index 08669de5ef..235c3e26de 100644 --- a/packages/react/transform/src/bundle.rs +++ b/packages/react/transform/src/bundle.rs @@ -158,6 +158,7 @@ pub fn transform_bundle_result_inner( source_root: "".into(), // TODO: add root source_file_name: options.source_file_name.as_deref(), source_map_url: None, + source_map_ignore_list: None, output_path: None, inline_sources_content: true, source_map: match options.sourcemap { diff --git a/packages/react/transform/src/lib.rs b/packages/react/transform/src/lib.rs index cdaa3ca226..f27e003481 100644 --- a/packages/react/transform/src/lib.rs +++ b/packages/react/transform/src/lib.rs @@ -201,8 +201,19 @@ impl napi::bindgen_prelude::FromNapiValue for IsModuleConfig { } let str_val = <&str>::from_napi_value(env, napi_val); - if str_val.is_ok() && str_val.unwrap() == "unknown" { - return Ok(IsModuleConfig(IsModule::Unknown)); + + if let Ok(val) = str_val { + match val { + "unknown" => return Ok(IsModuleConfig(IsModule::Unknown)), + "commonjs" => return Ok(IsModuleConfig(IsModule::CommonJS)), + _ => { + return Err(napi::bindgen_prelude::error!( + napi::bindgen_prelude::Status::InvalidArg, + "Invalid variant '{}' for enum IsModuleConfig", + val + )); + } + } } Err(napi::bindgen_prelude::error!( @@ -221,6 +232,7 @@ impl napi::bindgen_prelude::ToNapiValue for IsModuleConfig { match val.0 { IsModule::Bool(v) => ::to_napi_value(env, v), IsModule::Unknown => <&str>::to_napi_value(env, "unknown"), + IsModule::CommonJS => <&str>::to_napi_value(env, "commonjs"), } } } @@ -636,6 +648,7 @@ fn transform_react_lynx_inner( source_root: "".into(), // TODO: add root source_file_name: options.source_file_name.as_deref(), source_map_url: None, + source_map_ignore_list: None, output_path: None, inline_sources_content: options.inline_sources_content.unwrap_or(true), source_map: match options.sourcemap { @@ -759,23 +772,6 @@ pub fn transform_bundle_result( #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] mod wasm { - use getrandom::register_custom_getrandom; - use getrandom::Error; - - #[link(wasm_import_module = "getrandom")] - extern "C" { - fn random_fill_sync(offset: *mut u8, size: usize); - } - - fn custom_getrandom(buf: &mut [u8]) -> Result<(), Error> { - unsafe { - random_fill_sync(buf.as_mut_ptr(), buf.len()); - } - Ok(()) - } - - register_custom_getrandom!(custom_getrandom); - use ::napi::{JsObject, NapiValue}; const fn max(a: usize, b: usize) -> usize { diff --git a/packages/react/worklet-runtime/__test__/runOnMainThread.test.js b/packages/react/worklet-runtime/__test__/runOnMainThread.test.js new file mode 100644 index 0000000000..d3402708be --- /dev/null +++ b/packages/react/worklet-runtime/__test__/runOnMainThread.test.js @@ -0,0 +1,47 @@ +// Copyright 2024 The Lynx Authors. All rights reserved. +// Licensed under the Apache License Version 2.0 that can be found in the +// LICENSE file in the root directory of this source tree. +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; + +import { runRunOnMainThreadTask } from '../src/runOnMainThread'; +import { initWorklet } from '../src/workletRuntime'; + +beforeEach(() => { + globalThis.SystemInfo = { + lynxSdkVersion: '2.16', + }; + initWorklet(); + const dispatchEvent = vi.fn(); + globalThis.lynx = { + getJSContext: vi.fn(() => ({ + dispatchEvent, + })), + }; +}); + +afterEach(() => { + delete globalThis.lynxWorkletImpl; +}); + +describe('runOnMainThread', () => { + it('worklet should be called', () => { + const fn = vi.fn(() => 'ret'); + globalThis.registerWorklet('main-thread', '1', fn); + let worklet = { + _wkltId: '1', + }; + + runRunOnMainThreadTask(worklet, [42], 10); + expect(fn).toBeCalledWith(42); + expect(globalThis.lynx.getJSContext().dispatchEvent.mock.calls).toMatchInlineSnapshot(` + [ + [ + { + "data": "{"resolveId":10,"returnValue":"ret"}", + "type": "Lynx.Worklet.FunctionCallRet", + }, + ], + ] + `); + }); +}); diff --git a/packages/react/worklet-runtime/src/bindings/bindings.ts b/packages/react/worklet-runtime/src/bindings/bindings.ts index 005283489b..a7fca5ebb2 100644 --- a/packages/react/worklet-runtime/src/bindings/bindings.ts +++ b/packages/react/worklet-runtime/src/bindings/bindings.ts @@ -63,6 +63,15 @@ function setEomShouldFlushElementTree(value: boolean) { globalThis.lynxWorkletImpl?._eomImpl.setShouldFlush(value); } +/** + * Runs a task on the main thread. + * + * @internal + */ +function runRunOnMainThreadTask(task: Worklet, params: ClosureValueType[], resolveId: number): void { + globalThis.lynxWorkletImpl?._runRunOnMainThreadTask(task, params, resolveId); +} + export { runWorkletCtx, updateWorkletRef, @@ -70,4 +79,5 @@ export { registerWorklet, delayRunOnBackground, setEomShouldFlushElementTree, + runRunOnMainThreadTask, }; diff --git a/packages/react/worklet-runtime/src/global.ts b/packages/react/worklet-runtime/src/global.ts index c00a9f0faf..02a4caffe7 100644 --- a/packages/react/worklet-runtime/src/global.ts +++ b/packages/react/worklet-runtime/src/global.ts @@ -18,6 +18,7 @@ declare global { _runOnBackgroundDelayImpl: RunOnBackgroundDelayImpl; _hydrateCtx: (worklet: Worklet, firstScreenWorklet: Worklet) => void; _eomImpl: EomImpl; + _runRunOnMainThreadTask: (task: Worklet, params: ClosureValueType[], resolveId: number) => void; }; function runWorklet(ctx: Worklet, params: ClosureValueType[]): unknown; diff --git a/packages/react/worklet-runtime/src/listeners.ts b/packages/react/worklet-runtime/src/listeners.ts index 6ebe94faaf..8918a48021 100644 --- a/packages/react/worklet-runtime/src/listeners.ts +++ b/packages/react/worklet-runtime/src/listeners.ts @@ -2,8 +2,9 @@ // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. import { WorkletEvents } from './bindings/events.js'; -import type { ReleaseWorkletRefData, RunWorkletCtxData, RunWorkletCtxRetData } from './bindings/events.js'; +import type { ReleaseWorkletRefData, RunWorkletCtxData } from './bindings/events.js'; import type { ClosureValueType } from './bindings/types.js'; +import { runRunOnMainThreadTask } from './runOnMainThread.js'; import type { Event } from './types/runtimeProxy.js'; import { removeValueFromWorkletRefMap } from './workletRef.js'; @@ -13,14 +14,7 @@ function initEventListeners(): void { WorkletEvents.runWorkletCtx, (event: Event) => { const data = JSON.parse(event.data as string) as RunWorkletCtxData; - const returnValue = runWorklet(data.worklet, data.params as ClosureValueType[]); - jsContext.dispatchEvent({ - type: WorkletEvents.FunctionCallRet, - data: JSON.stringify({ - resolveId: data.resolveId, - returnValue, - } as RunWorkletCtxRetData), - }); + runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId); }, ); jsContext.addEventListener( diff --git a/packages/react/worklet-runtime/src/runOnMainThread.ts b/packages/react/worklet-runtime/src/runOnMainThread.ts new file mode 100644 index 0000000000..b8561dd2d5 --- /dev/null +++ b/packages/react/worklet-runtime/src/runOnMainThread.ts @@ -0,0 +1,21 @@ +// Copyright 2025 The Lynx Authors. All rights reserved. +// Licensed under the Apache License Version 2.0 that can be found in the +// LICENSE file in the root directory of this source tree. +import { WorkletEvents } from './bindings/index.js'; +import type { ClosureValueType, RunWorkletCtxRetData, Worklet } from './bindings/index.js'; + +export function runRunOnMainThreadTask(task: Worklet, params: ClosureValueType[], resolveId: number): void { + let returnValue; + try { + returnValue = runWorklet(task, params); + } finally { + // TODO: Should be more proper to reject the promise if there is an error. + lynx.getJSContext().dispatchEvent({ + type: WorkletEvents.FunctionCallRet, + data: JSON.stringify({ + resolveId, + returnValue, + } as RunWorkletCtxRetData), + }); + } +} diff --git a/packages/react/worklet-runtime/src/workletRuntime.ts b/packages/react/worklet-runtime/src/workletRuntime.ts index 41623aa2ef..9cd3876766 100644 --- a/packages/react/worklet-runtime/src/workletRuntime.ts +++ b/packages/react/worklet-runtime/src/workletRuntime.ts @@ -8,6 +8,7 @@ import { delayExecUntilJsReady, initEventDelay } from './delayWorkletEvent.js'; import { initEomImpl } from './eomImpl.js'; import { hydrateCtx } from './hydrate.js'; import { JsFunctionLifecycleManager, isRunOnBackgroundEnabled } from './jsFunctionLifecycle.js'; +import { runRunOnMainThreadTask } from './runOnMainThread.js'; import { profile } from './utils/profile.js'; import { getFromWorkletRefMap, initWorkletRef } from './workletRef.js'; @@ -19,6 +20,7 @@ function initWorklet(): void { _hydrateCtx: hydrateCtx, _eventDelayImpl: initEventDelay(), _eomImpl: initEomImpl(), + _runRunOnMainThreadTask: runRunOnMainThreadTask, }; if (isRunOnBackgroundEnabled()) { diff --git a/packages/rspeedy/plugin-react/package.json b/packages/rspeedy/plugin-react/package.json index ad00b6ad1e..a312a03eb0 100644 --- a/packages/rspeedy/plugin-react/package.json +++ b/packages/rspeedy/plugin-react/package.json @@ -64,7 +64,7 @@ "typia-rspack-plugin": "2.2.2" }, "peerDependencies": { - "@lynx-js/react": "^0.103.0 || ^0.104.0 || ^0.105.0 || ^0.106.0 || ^0.107.0 || ^0.108.0 || ^0.109.0 || ^0.110.0 || ^0.111.0 || ^0.112.0" + "@lynx-js/react": "^0.103.0 || ^0.104.0 || ^0.105.0 || ^0.106.0 || ^0.107.0 || ^0.108.0 || ^0.109.0 || ^0.110.0 || ^0.111.0 || ^0.112.0 || ^0.113.0" }, "peerDependenciesMeta": { "@lynx-js/react": { diff --git a/packages/third-party/tailwind-preset/docs/plugins/lynx-ui/uiVariants.md b/packages/third-party/tailwind-preset/docs/plugins/lynx-ui/uiVariants.md index f47081a61a..b1348eda03 100644 --- a/packages/third-party/tailwind-preset/docs/plugins/lynx-ui/uiVariants.md +++ b/packages/third-party/tailwind-preset/docs/plugins/lynx-ui/uiVariants.md @@ -4,13 +4,13 @@ The UI Variants plugin (`uiVariants`) enables Tailwind-compatible variants based on a component's internal state or configuration using a unified class-based `ui-*` prefix. -This mirrors patterns found in Headless UI or Radix UI, where internal states like `open`, `disabled`, or layout configurations like `side="left"` are surfaced via attribute selectors for styling purposes. Since Lynx doesn't support attribute selectors, this plugin provides a class-based alternative: instead of `[data-state="open"]`, you can write `.ui-open:*`. +This mirrors patterns found in Headless UI or Radix UI, where internal states like `open`, `disabled`, or layout configurations like `side="left"` are surfaced via attribute selectors for styling purposes. Since Lynx doesn't support attribute selectors, this plugin provides a class-based alternative: instead of `[data-state="open"]`, you can write `ui-open:*`. ## How to Enable and Customize ### Enable with Default Values -Enable the plugin with built-in `ui-*` prefixes and common component states: +Enable the plugin with built-in `ui-*` prefix and common component states: ```ts createLynxPreset({ @@ -22,7 +22,7 @@ createLynxPreset({ ### Customize Prefixes and Values -Use a custom mapping to align with your component state structure (e.g., data-* patterns): +Use a custom mapping to align with your component state structure (e.g., `data-*` patterns): ```ts createLynxPreset({