Skip to content

Commit

Permalink
chore: revert rc to arc
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Sep 20, 2024
1 parent 86616b6 commit 4074a7a
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion crates/binding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ crate-type = ["cdylib"]
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
napi = { version = "2.12.0", default-features = false, features = ["napi4", "async"] }
napi-derive = { version = "2.12.2" }
swc_core = { version = "0.100.1", features = ["base_node"] }
swc_core = { version = "0.100.1", default-features = false, features = ["base_node"] }
svgr-rs = { path = "../core" }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/add_jsx_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ fn svg_prop_to_attr(key: &str, value: &str) -> Attribute {

#[cfg(test)]
mod tests {
use std::rc::Arc;
use std::sync::Arc;

use swc_core::{
common::{FileName, SourceMap},
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/hast_to_swc_ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ pub fn to_swc_ast(hast: swc_xml::ast::Document) -> Option<JSXElement> {

#[cfg(test)]
mod tests {
use std::{borrow::Borrow, path::PathBuf, rc::Arc};
use std::{borrow::Borrow, path::PathBuf, sync::Arc};

use swc_core::{
common::{FileName, SourceFile, SourceMap},
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(path_file_prefix)]
#![deny(clippy::all)]

use std::{sync::Arc};
use std::sync::Arc;

use swc_core::{
common::{comments::SingleThreadedComments, FileName, SourceMap},
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/remove_jsx_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl VisitMut for Visitor {

#[cfg(test)]
mod tests {
use std::{default::Default, rc::Arc};
use std::{default::Default, sync::Arc};

use swc_core::{
common::{FileName, SourceMap},
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/replace_jsx_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn get_attr_value(new: &str) -> JSXAttrValue {

#[cfg(test)]
mod tests {
use std::rc::Arc;
use std::sync::Arc;

use swc_core::{
common::{FileName, SourceMap},
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/svg_dynamic_title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl VisitMut for Visitor {

#[cfg(test)]
mod tests {
use std::rc::Arc;
use std::sync::Arc;

use swc_core::{
common::{FileName, SourceMap},
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/svg_em_dimensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn get_value(raw: Option<&Size>) -> JSXAttrValue {

#[cfg(test)]
mod tests {
use std::{default::Default, rc::Arc};
use std::{default::Default, sync::Arc};

use swc_core::{
common::{FileName, SourceMap},
Expand Down
33 changes: 18 additions & 15 deletions crates/core/src/transform_react_native_svg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{cell::RefCell, collections::HashMap, sync::Arc};
use std::rc::Rc;
use std::{cell::RefCell, collections::HashMap};

use linked_hash_set::LinkedHashSet;
use swc_core::common::SyntaxContext;
Expand All @@ -15,16 +16,16 @@ use swc_core::{
};

pub struct Visitor<'a> {
replaced_components: Arc<RefCell<LinkedHashSet<String>>>,
unsupported_components: Arc<RefCell<LinkedHashSet<String>>>,
replaced_components: Rc<RefCell<LinkedHashSet<String>>>,
unsupported_components: Rc<RefCell<LinkedHashSet<String>>>,
comments: &'a dyn Comments,
}

impl<'a> Visitor<'a> {
pub fn new(comments: &'a dyn Comments) -> Self {
Visitor {
replaced_components: Arc::new(RefCell::new(LinkedHashSet::new())),
unsupported_components: Arc::new(RefCell::new(LinkedHashSet::new())),
replaced_components: Rc::new(RefCell::new(LinkedHashSet::new())),
unsupported_components: Rc::new(RefCell::new(LinkedHashSet::new())),
comments,
}
}
Expand Down Expand Up @@ -66,14 +67,14 @@ impl VisitMut for Visitor<'_> {
}

struct SvgElementVisitor {
replaced_components: Arc<RefCell<LinkedHashSet<String>>>,
unsupported_components: Arc<RefCell<LinkedHashSet<String>>>,
replaced_components: Rc<RefCell<LinkedHashSet<String>>>,
unsupported_components: Rc<RefCell<LinkedHashSet<String>>>,
}

impl SvgElementVisitor {
fn new(
replaced_components: Arc<RefCell<LinkedHashSet<String>>>,
unsupported_components: Arc<RefCell<LinkedHashSet<String>>>,
replaced_components: Rc<RefCell<LinkedHashSet<String>>>,
unsupported_components: Rc<RefCell<LinkedHashSet<String>>>,
) -> Self {
SvgElementVisitor {
replaced_components,
Expand Down Expand Up @@ -105,14 +106,14 @@ impl VisitMut for SvgElementVisitor {
struct JSXElementVisitor {
element_to_component: HashMap<&'static str, &'static str>,

replaced_components: Arc<RefCell<LinkedHashSet<String>>>,
unsupported_components: Arc<RefCell<LinkedHashSet<String>>>,
replaced_components: Rc<RefCell<LinkedHashSet<String>>>,
unsupported_components: Rc<RefCell<LinkedHashSet<String>>>,
}

impl JSXElementVisitor {
fn new(
replaced_components: Arc<RefCell<LinkedHashSet<String>>>,
unsupported_components: Arc<RefCell<LinkedHashSet<String>>>,
replaced_components: Rc<RefCell<LinkedHashSet<String>>>,
unsupported_components: Rc<RefCell<LinkedHashSet<String>>>,
) -> Self {
JSXElementVisitor {
element_to_component: get_element_to_component(),
Expand Down Expand Up @@ -191,12 +192,12 @@ fn get_element_to_component() -> HashMap<&'static str, &'static str> {
}

struct ImportDeclVisitor {
replaced_components: Arc<RefCell<LinkedHashSet<String>>>,
replaced_components: Rc<RefCell<LinkedHashSet<String>>>,
import_decl_span: Option<Span>,
}

impl ImportDeclVisitor {
fn new(replaced_components: Arc<RefCell<LinkedHashSet<String>>>) -> Self {
fn new(replaced_components: Rc<RefCell<LinkedHashSet<String>>>) -> Self {
ImportDeclVisitor {
replaced_components,
import_decl_span: None,
Expand Down Expand Up @@ -249,6 +250,8 @@ impl VisitMut for ImportDeclVisitor {

#[cfg(test)]
mod tests {
use std::sync::Arc;

use swc_core::{
common::{comments::SingleThreadedComments, FileName, SourceMap},
ecma::{
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/transform_svg_component/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub fn transform(

#[cfg(test)]
mod tests {
use std::{borrow::Borrow, rc::Arc};
use std::{borrow::Borrow, sync::Arc};

use swc_core::{
common::{FileName, SourceMap},
Expand Down

0 comments on commit 4074a7a

Please sign in to comment.