-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rework of API and internal structures (#21)
* tweak * fmt * tweak2 * Remove once cell * Remove fields * Fix empty string sourcemap issue * feature-gate-sourcemap * tweak * update deps * bump version
- Loading branch information
Showing
28 changed files
with
1,373 additions
and
1,501 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = false |
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 |
---|---|---|
@@ -1,26 +1,19 @@ | ||
use string_wizard::{MagicString, SourceMapOptions, UpdateOptions}; | ||
|
||
fn main() { | ||
let demo = "<div>\n hello, world\n</div>"; | ||
let mut s = MagicString::new(demo); | ||
let demo = "<div>\n hello, world\n</div>"; | ||
let mut s = MagicString::new(demo); | ||
|
||
let update_options = UpdateOptions { | ||
keep_original: true, | ||
..Default::default() | ||
}; | ||
s.prepend("import React from 'react';\n") | ||
.update_with(1, 2, "v", update_options.clone()) | ||
.update_with(3, 4, "d", update_options.clone()) | ||
.update_with(demo.len() - 4, demo.len() - 1, "h1", update_options.clone()); | ||
let update_options = UpdateOptions { keep_original: true, ..Default::default() }; | ||
s.prepend("import React from 'react';\n") | ||
.update_with(1, 2, "v", update_options.clone()) | ||
.update_with(3, 4, "d", update_options.clone()) | ||
.update_with(demo.len() - 4, demo.len() - 1, "h1", update_options.clone()); | ||
|
||
let sm = s.source_map(SourceMapOptions { | ||
include_content: true, | ||
..Default::default() | ||
}); | ||
let sm = s.source_map(SourceMapOptions { include_content: true, ..Default::default() }); | ||
|
||
std::fs::write("./demo.map.json", sm.to_json_string().unwrap()) | ||
.unwrap(); | ||
std::fs::write("./demo.jsx", s.to_string()).unwrap(); | ||
std::fs::write("./demo.map.json", sm.to_json_string()).unwrap(); | ||
std::fs::write("./demo.jsx", s.to_string()).unwrap(); | ||
|
||
println!("{:#?}", s.to_string()); | ||
println!("{:#?}", s.to_string()); | ||
} |
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,7 @@ | ||
tab_spaces = 2 | ||
|
||
# This is also the setting used by [rustc](https://github.com/rust-lang/rust/blob/master/rustfmt.toml) | ||
use_small_heuristics = "Max" | ||
|
||
# Use field initialize shorthand if possible | ||
use_field_init_shorthand = true |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.