From b3033d111e6766596b58fe8c0b3a98651469f267 Mon Sep 17 00:00:00 2001 From: YM162 Date: Thu, 28 Dec 2023 15:14:12 +0100 Subject: [PATCH] Temp removal of method code. --- Cargo.lock | 31 +++++++------------ gulagcleaner_python/Cargo.toml | 2 +- gulagcleaner_python/pyproject.toml | 2 +- .../python/gulagcleaner/command_line.py | 2 +- gulagcleaner_rs/Cargo.toml | 2 +- gulagcleaner_rs/src/lib.rs | 1 + gulagcleaner_wasm/Cargo.toml | 6 ++-- gulagcleaner_wasm/src/lib.rs | 14 +++++---- 8 files changed, 29 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4dce004..35bc477 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,6 +171,7 @@ version = "0.11.0" dependencies = [ "gulagcleaner_rs", "serde", + "serde-wasm-bindgen", "wasm-bindgen", ] @@ -469,12 +470,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "ryu" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" - [[package]] name = "scopeguard" version = "1.2.0" @@ -490,6 +485,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9b713f70513ae1f8d92665bbbbda5c295c2cf1da5542881ae5eefe20c9af132" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_derive" version = "1.0.193" @@ -501,17 +507,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_json" -version = "1.0.108" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" -dependencies = [ - "itoa", - "ryu", - "serde", -] - [[package]] name = "smallvec" version = "1.11.2" @@ -583,8 +578,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", - "serde", - "serde_json", "wasm-bindgen-macro", ] diff --git a/gulagcleaner_python/Cargo.toml b/gulagcleaner_python/Cargo.toml index 60fcde6..cca62cf 100644 --- a/gulagcleaner_python/Cargo.toml +++ b/gulagcleaner_python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gulagcleaner_python" -version = "0.11.0" +version = "0.11.1" edition = "2021" authors = ["YM162 "] description = "Ad removal tool for PDFs." diff --git a/gulagcleaner_python/pyproject.toml b/gulagcleaner_python/pyproject.toml index 2642b80..6e7561c 100644 --- a/gulagcleaner_python/pyproject.toml +++ b/gulagcleaner_python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "gulagcleaner" -version = "0.11.0" +version = "0.11.1" description = "Ad removal tool for PDFs." authors = [ {name = "YM162", email = "david.fontaneda16@gmail.com"}] diff --git a/gulagcleaner_python/python/gulagcleaner/command_line.py b/gulagcleaner_python/python/gulagcleaner/command_line.py index 589151c..5a16642 100644 --- a/gulagcleaner_python/python/gulagcleaner/command_line.py +++ b/gulagcleaner_python/python/gulagcleaner/command_line.py @@ -61,7 +61,7 @@ def main(): # Check for the -v argument if arguments["version"]: - print("Current version: 0.11.0") + print("Current version: 0.11.1") return # Get the pdf_path argument diff --git a/gulagcleaner_rs/Cargo.toml b/gulagcleaner_rs/Cargo.toml index 132b127..a229f16 100644 --- a/gulagcleaner_rs/Cargo.toml +++ b/gulagcleaner_rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gulagcleaner_rs" -version = "0.11.0" +version = "0.11.1" edition = "2021" authors = ["YM162 "] description = "Ad removal tool for PDFs." diff --git a/gulagcleaner_rs/src/lib.rs b/gulagcleaner_rs/src/lib.rs index dc8066b..929d530 100644 --- a/gulagcleaner_rs/src/lib.rs +++ b/gulagcleaner_rs/src/lib.rs @@ -339,6 +339,7 @@ mod tests { //Load some pdf bytes and clean it let data = std::fs::read("../test.pdf").unwrap(); let (clean_pdf,_) = clean_pdf(data,0); + //Print the length of the pdf std::fs::write("../test_clean.pdf", clean_pdf).unwrap(); } } \ No newline at end of file diff --git a/gulagcleaner_wasm/Cargo.toml b/gulagcleaner_wasm/Cargo.toml index 946d18a..399608c 100644 --- a/gulagcleaner_wasm/Cargo.toml +++ b/gulagcleaner_wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gulagcleaner_wasm" -version = "0.11.0" +version = "0.11.1" edition = "2021" authors = ["YM162 "] description = "Ad removal tool for PDFs." @@ -15,5 +15,7 @@ crate-type = ["cdylib"] [dependencies] serde = { version = "1.0", features = ["derive"] } -wasm-bindgen = { version = "0.2", features = ["serde-serialize"] } +serde-wasm-bindgen = "0.6.3" +wasm-bindgen = "0.2" + gulagcleaner_rs = { path = "../gulagcleaner_rs" } \ No newline at end of file diff --git a/gulagcleaner_wasm/src/lib.rs b/gulagcleaner_wasm/src/lib.rs index bd23925..6676bca 100644 --- a/gulagcleaner_wasm/src/lib.rs +++ b/gulagcleaner_wasm/src/lib.rs @@ -10,11 +10,13 @@ pub struct CleaningResult { } #[wasm_bindgen] -pub fn clean_pdf(data: Vec,force_naive: u8) -> JsValue { +pub fn clean_pdf(data: Vec,force_naive: u8) -> Vec { let (clean_pdf,method_code) = gulagcleaner_rs::clean_pdf(data, force_naive); - let example = CleaningResult { - result: clean_pdf, - method: method_code, - }; - JsValue::from_serde(&example).unwrap() + // For some reason, the serde serialization messes up our data, so we just return the raw bytes until we find a fix + // let example = CleaningResult { + // result: clean_pdf, + // method: method_code, + // }; + // Ok(serde_wasm_bindgen::to_value(&example)?) + return clean_pdf; } \ No newline at end of file