diff --git a/Cargo.lock b/Cargo.lock index fb52135..06fc364 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,13 +26,18 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" +[[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + [[package]] name = "ast_node" -version = "3.0.0" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fb5864e2f5bf9fd9797b94b2dfd1554d4c3092b535008b27d7e15c86675a2f" +checksum = "2eb025ef00a6da925cf40870b9c8d008526b6004ece399cb0974209720f0b194" dependencies = [ - "proc-macro2", "quote", "swc_macros_common", "syn", @@ -55,9 +60,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", ] @@ -81,12 +86,19 @@ dependencies = [ ] [[package]] -name = "bumpalo" -version = "3.17.0" +name = "bytes" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" + +[[package]] +name = "bytes-str" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "7c60b5ce37e0b883c37eb89f79a1e26fbe9c1081945d024eee93e8d91a7e18b3" dependencies = [ - "allocator-api2", + "bytes", + "serde", ] [[package]] @@ -151,11 +163,10 @@ dependencies = [ [[package]] name = "from_variant" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d7ccf961415e7aa17ef93dcb6c2441faaa8e768abe09e659b908089546f74c5" +checksum = "e5ff35a391aef949120a0340d690269b3d9f63460a6106e99bd07b961f345ea9" dependencies = [ - "proc-macro2", "swc_macros_common", "syn", ] @@ -184,15 +195,15 @@ checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "hstr" -version = "1.0.0" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71399f53a92ef72ee336a4b30201c6e944827e14e0af23204c291aad9c24cc85" +checksum = "0c43c0a9e8fbdb3bb9dc8eee85e1e2ac81605418b4c83b6b7413cbf14d56ca5c" dependencies = [ "hashbrown 0.14.5", "new_debug_unreachable", "once_cell", - "phf", "rustc-hash 2.1.1", + "serde", "triomphe", ] @@ -371,7 +382,7 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-source-scopes" -version = "0.5.0" +version = "0.6.0" dependencies = [ "indexmap", "sourcemap", @@ -513,26 +524,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", -] - [[package]] name = "quote" version = "1.0.36" @@ -611,20 +602,36 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[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.203" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -720,50 +727,36 @@ 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", ] -[[package]] -name = "swc_allocator" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6b926f0d94bbb34031fe5449428cfa1268cdc0b31158d6ad9c97e0fc1e79dd" -dependencies = [ - "allocator-api2", - "bumpalo", - "ptr_meta", - "rustc-hash 2.1.1", - "triomphe", -] - [[package]] name = "swc_atoms" -version = "5.0.0" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d7077ba879f95406459bc0c81f3141c529b34580bc64d7ab7bd15e7118a0391" +checksum = "d4ccbe2ecad10ad7432100f878a107b1d972a8aee83ca53184d00c23a078bb8a" dependencies = [ "hstr", "once_cell", - "rustc-hash 2.1.1", "serde", ] [[package]] name = "swc_common" -version = "8.0.0" +version = "17.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fbd21a1179166b5635d4b7a6b5930cf34b803a7361e0297b04f84dc820db04" +checksum = "259b675d633a26d24efe3802a9d88858c918e6e8f062d3222d3aa02d56a2cf4c" dependencies = [ + "anyhow", "ast_node", "better_scoped_tls", - "cfg-if", + "bytes-str", "either", "from_variant", "new_debug_unreachable", @@ -772,7 +765,6 @@ dependencies = [ "rustc-hash 2.1.1", "serde", "siphasher", - "swc_allocator", "swc_atoms", "swc_eq_ignore_macros", "swc_visit", @@ -783,15 +775,16 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "8.0.1" +version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22b5c514e22bcd65176a356c0bd2de295881b97079a45b991b98c4dca666ac78" +checksum = "a573a0c72850dec8d4d8085f152d5778af35a2520c3093b242d2d1d50776da7c" dependencies = [ "bitflags", "is-macro", "num-bigint", + "once_cell", "phf", - "scoped-tls", + "rustc-hash 2.1.1", "string_enum", "swc_atoms", "swc_common", @@ -801,32 +794,30 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "10.0.1" +version = "27.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9576fd56e613f83990190778878139ab1a8d5ff0b316318ba34204407a0142a2" +checksum = "7f1a51af1a92cd4904c073b293e491bbc0918400a45d58227b34c961dd6f52d7" dependencies = [ + "bitflags", "either", - "new_debug_unreachable", "num-bigint", - "num-traits", "phf", "rustc-hash 2.1.1", + "seq-macro", "serde", - "smallvec", "smartstring", "stacker", "swc_atoms", "swc_common", "swc_ecma_ast", "tracing", - "typed-arena", ] [[package]] name = "swc_ecma_visit" -version = "8.0.0" +version = "18.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f7a65fa06d0c0f709f1df4e820ccdc4eca7b3db7f9d131545e20c2ac2f1cd23" +checksum = "a9611a72a4008d62608547a394e5d72a5245413104db096d95a52368a8cc1d63" dependencies = [ "new_debug_unreachable", "num-bigint", @@ -839,9 +830,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", @@ -850,9 +841,9 @@ dependencies = [ [[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", @@ -861,9 +852,9 @@ dependencies = [ [[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", @@ -968,12 +959,6 @@ 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 = "unicode-id-start" version = "1.3.1" @@ -988,9 +973,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "url" diff --git a/Cargo.toml b/Cargo.toml index 47b734e..1d74cad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,8 +14,8 @@ repository = "https://github.com/getsentry/js-source-scopes" [dependencies] indexmap = "2.8.0" sourcemap = "9.1.2" -swc_common = "8.0.0" -swc_ecma_parser = "10.0.1" -swc_ecma_visit = { version = "8.0.0", features = ["path"] } +swc_common = "17.0.1" +swc_ecma_parser = "27.0.7" +swc_ecma_visit = { version = "18.0.1", features = ["path"] } thiserror = "2.0.12" tracing = "0.1.36" diff --git a/src/scope_index.rs b/src/scope_index.rs index 6793a93..efce715 100644 --- a/src/scope_index.rs +++ b/src/scope_index.rs @@ -84,7 +84,7 @@ impl ScopeIndex { } /// Looks up the scope corresponding to the given `offset`. - pub fn lookup(&self, offset: u32) -> ScopeLookupResult { + pub fn lookup(&self, offset: u32) -> ScopeLookupResult<'_> { let range_idx = match self.ranges.binary_search_by_key(&offset, |r| r.0) { Ok(idx) => idx, Err(0) => 0, // this is pretty much unreachable since the first offset is 0 @@ -99,7 +99,7 @@ impl ScopeIndex { self.resolve_name(name_idx) } - fn resolve_name(&self, name_idx: u32) -> ScopeLookupResult { + fn resolve_name(&self, name_idx: u32) -> ScopeLookupResult<'_> { if name_idx == GLOBAL_SCOPE_SENTINEL { ScopeLookupResult::Unknown } else if name_idx == ANONYMOUS_SCOPE_SENTINEL { @@ -116,7 +116,7 @@ impl ScopeIndex { /// offsets. /// /// Scopes are returned in order of their starting offsets. - pub fn iter(&self) -> impl Iterator { + pub fn iter(&self) -> impl Iterator)> { self.ranges.iter().map(|r| (r.0, self.resolve_name(r.1))) } } diff --git a/src/swc.rs b/src/swc.rs index 2056516..3b10450 100644 --- a/src/swc.rs +++ b/src/swc.rs @@ -393,7 +393,7 @@ fn push_computed_prop_name(prop_name: &ast::ComputedPropName, scope_name: &mut S fn lit_as_string(lit: &ast::Lit) -> String { match lit { - ast::Lit::Str(v) => format!("\"{}\"", v.value), + ast::Lit::Str(v) => format!("{:?}", v.value), ast::Lit::Num(v) => v.value.to_string(), ast::Lit::BigInt(v) => format!("{}n", v.value), ast::Lit::Bool(v) => v.value.to_string(), @@ -406,7 +406,7 @@ fn lit_as_string(lit: &ast::Lit) -> String { fn prop_name_to_component(prop: &ast::PropName) -> NameComponent { match prop { ast::PropName::Ident(ref i) => NameComponent::ident(i.clone().into()), - ast::PropName::Str(s) => NameComponent::interp(format!("<\"{}\">", s.value)), + ast::PropName::Str(s) => NameComponent::interp(format!("<{:?}>", s.value)), ast::PropName::Num(n) => NameComponent::interp(format!("<{}>", n)), ast::PropName::Computed(_) => NameComponent::interp(""), ast::PropName::BigInt(i) => NameComponent::interp(format!("<{}n>", i.value)),