-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from svg-rust/cargo
Cargo
- Loading branch information
Showing
33 changed files
with
228 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,7 +183,7 @@ $RECYCLE.BIN/ | |
|
||
#Added by cargo | ||
|
||
/target | ||
target/ | ||
Cargo.lock | ||
|
||
.pnp.* | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,5 @@ | ||
[package] | ||
authors = ["SyMind <dacongsama@live.com>"] | ||
description = "A tool to transform SVG into React components" | ||
name = "svgr-rs" | ||
edition = "2021" | ||
license = "MIT" | ||
repository = "https://github.com/svg-rust/svgr-rs.git" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[features] | ||
node = ["dep:napi", "dep:napi-derive"] | ||
|
||
[dependencies] | ||
# 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"], optional = true } | ||
napi-derive = { version = "2.12.2", optional = true } | ||
|
||
clap = { version = "4.2.0", features = ["derive"] } | ||
regex = "1.7.3" | ||
serde = { version = "1", features = ["derive"] } | ||
swc_xml = "0.10.3" | ||
swc_core = { version = "0.74.2", features = [ | ||
"ecma_ast", | ||
"ecma_ast_serde", | ||
"common_concurrent", | ||
"bundler", | ||
"ecma_loader", | ||
"ecma_transforms", | ||
"ecma_visit", | ||
"ecma_codegen", | ||
"base_node", | ||
"__parser", | ||
] } | ||
linked-hash-map = { version = "0.5.6", features = ["serde_impl"] } | ||
linked_hash_set = "0.1.4" | ||
|
||
[build-dependencies] | ||
napi-build = "2.0.1" | ||
|
||
[dev-dependencies] | ||
testing = "0.32.5" | ||
|
||
[profile.release] | ||
lto = true | ||
[workspace] | ||
members = [ | ||
"crates/core", | ||
"crates/binding" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
authors = ["SyMind <dacongsama@live.com>"] | ||
name = "binding" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
license = "MIT" | ||
|
||
[lib] | ||
bench = false | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
# 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.74.2", features = ["base_node"] } | ||
svgr-rs = { path = "../core", features = ["node"] } | ||
|
||
[build-dependencies] | ||
napi-build = "2.0.1" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#![feature(path_file_prefix)] | ||
|
||
#![deny(clippy::all)] | ||
|
||
#[macro_use] | ||
extern crate napi_derive; | ||
|
||
use swc_core::node::get_deserialized; | ||
use svgr_rs::{transform as transform_core, Config, State}; | ||
|
||
#[napi] | ||
pub async fn transform(code: String, config: napi::bindgen_prelude::Buffer, state: Option<State>) -> napi::bindgen_prelude::Result<String> { | ||
let config: Config = get_deserialized(&config)?; | ||
let state = match state { | ||
Some(state) => state, | ||
None => Default::default() | ||
}; | ||
match transform_core(code, config, state) { | ||
Ok(result) => napi::bindgen_prelude::Result::Ok(result), | ||
Err(reason) => napi::bindgen_prelude::Result::Err(napi::bindgen_prelude::Error::from_reason(reason)), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[package] | ||
authors = ["SyMind <dacongsama@live.com>"] | ||
description = "A tool to transform SVG into React components" | ||
name = "svgr-rs" | ||
edition = "2021" | ||
license = "MIT" | ||
repository = "https://github.com/svg-rust/svgr-rs.git" | ||
version = "0.1.2" | ||
|
||
[features] | ||
node = ["dep:napi", "dep:napi-derive"] | ||
|
||
[dependencies] | ||
# 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"], optional = true } | ||
napi-derive = { version = "2.12.2", optional = true } | ||
|
||
clap = { version = "4.2.0", features = ["derive"] } | ||
regex = "1.7.3" | ||
serde = { version = "1", features = ["derive"] } | ||
swc_xml = "0.10.3" | ||
swc_core = { version = "0.74.2", features = [ | ||
"ecma_ast", | ||
"ecma_ast_serde", | ||
"common_concurrent", | ||
"bundler", | ||
"ecma_loader", | ||
"ecma_transforms", | ||
"ecma_visit", | ||
"ecma_codegen", | ||
"__parser", | ||
] } | ||
linked-hash-map = { version = "0.5.6", features = ["serde_impl"] } | ||
linked_hash_set = "0.1.4" | ||
|
||
[dev-dependencies] | ||
testing = "0.32.5" | ||
|
||
[profile.release] | ||
lto = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../README.md |
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.