diff --git a/Cargo.lock b/Cargo.lock index 831dca0..c32d92f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -415,7 +415,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad" dependencies = [ "const_format_proc_macros", - "konst", ] [[package]] @@ -867,12 +866,12 @@ checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59" [[package]] name = "exmex" -version = "0.17.5" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf72d771d16d46af27985c8daa1ea6557ea4bcbd51f90a85285acdcd56072331" +checksum = "114e4321fcb0242ffe3092e29a7a41c11fc119f1fa8e61cd21b72a68dd004aaa" dependencies = [ "lazy_static", - "num", + "num-traits", "regex", "smallvec", ] @@ -989,7 +988,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4944f16eb6a05b4b2b79986b4786867bb275f52882adea798f17cc2588f25b2" dependencies = [ "dunce", - "rand 0.9.2", + "rand", ] [[package]] @@ -1421,37 +1420,12 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "json5" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dadca0807203e4dad79bc9229663ea382d7e809eeb2213496a1ae4aff0069d6" -dependencies = [ - "serde", - "ucd-trie", -] - [[package]] name = "khronos_api" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" -[[package]] -name = "konst" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "330f0e13e6483b8c34885f7e6c9f19b1a7bd449c673fbb948a51c99d66ef74f4" -dependencies = [ - "konst_macro_rules", -] - -[[package]] -name = "konst_macro_rules" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" - [[package]] name = "lazy_static" version = "1.5.0" @@ -1697,39 +1671,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - [[package]] name = "num-conv" version = "0.1.0" @@ -1746,37 +1687,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -2168,18 +2078,19 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "phf" -version = "0.11.3" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" dependencies = [ "phf_shared", + "serde", ] [[package]] name = "phf_codegen" -version = "0.11.3" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" +checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1" dependencies = [ "phf_generator", "phf_shared", @@ -2187,19 +2098,19 @@ dependencies = [ [[package]] name = "phf_generator" -version = "0.11.3" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" dependencies = [ + "fastrand", "phf_shared", - "rand 0.8.5", ] [[package]] name = "phf_shared" -version = "0.11.3" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" dependencies = [ "siphasher", ] @@ -2423,15 +2334,6 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "rand_core 0.6.4", -] - [[package]] name = "rand" version = "0.9.2" @@ -2439,7 +2341,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ "rand_chacha", - "rand_core 0.9.3", + "rand_core", ] [[package]] @@ -2449,15 +2351,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.3", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" - [[package]] name = "rand_core" version = "0.9.3" @@ -3192,12 +3088,6 @@ dependencies = [ "tz-rs", ] -[[package]] -name = "ucd-trie" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" - [[package]] name = "unicode-ident" version = "1.0.22" @@ -4102,7 +3992,6 @@ dependencies = [ "benchmarks", "bincode", "cfg-if", - "const_format", "eframe", "egui", "egui_plot", @@ -4110,7 +3999,6 @@ dependencies = [ "epaint", "instant", "itertools 0.14.0", - "json5", "lol_alloc", "parsing", "run_script", diff --git a/Cargo.toml b/Cargo.toml index 8147ef0..f5f9c2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,9 +48,6 @@ epaint = { git = "https://github.com/titaniumtown/egui.git", default-features = emath = { git = "https://github.com/titaniumtown/egui.git", default-features = false } egui_plot = { version = "0.34.0", default-features = false } - -shadow-rs = { version = "1.4", default-features = false } -const_format = { version = "0.2", default-features = false, features = ["fmt"] } cfg-if = "1" ruzstd = "0.8" tracing = "0.1" @@ -76,7 +73,6 @@ serde = "1" serde_json = "1" zstd = { version = "0.13", default-features = false, features = ["pkg-config"] } run_script = "0.11" -json5 = "1.0" itertools = "0.14" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/build.rs b/build.rs index 727867c..c538db5 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,8 @@ +use epaint::{ + text::{FontData, FontDefinitions, FontTweak}, + FontFamily, +}; +use run_script::ScriptOptions; use std::{ collections::BTreeMap, env, @@ -7,14 +12,6 @@ use std::{ sync::Arc, }; -use epaint::{ - FontFamily, - text::{FontData, FontDefinitions, FontTweak}, -}; - -use run_script::ScriptOptions; -use shadow_rs::ShadowBuilder; - include!(concat!( env!("CARGO_MANIFEST_DIR"), "/src/unicode_helper.rs" @@ -73,9 +70,6 @@ fn main() { // rebuild if new commit or contents of `assets` folder changed println!("cargo:rerun-if-changed=.git/logs/HEAD"); println!("cargo:rerun-if-changed=assets/*"); - ShadowBuilder::builder() - .build() - .expect("Could not initialize shadow_rs"); let mut main_chars: Vec = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzsu0123456789?.,!(){}[]-_=+-/<>'\\ :^*`@#$%&|~;" diff --git a/src/consts.rs b/src/consts.rs index 2a278af..6845778 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -1,18 +1,4 @@ -use const_format::formatc; use epaint::Color32; -use shadow_rs::shadow; -shadow!(build); - -/// Constant string that has a string containing information about the build. -pub const BUILD_INFO: &str = formatc!( - "Commit: {} ({})\nBuild Date: {}\nPackage Version: {}\nRust Channel: {}\nRust Version: {}", - &build::SHORT_COMMIT, - &build::BRANCH, - &build::BUILD_TIME, - &build::PKG_VERSION, - &build::RUST_CHANNEL, - &build::RUST_VERSION, -); pub const FONT_SIZE: f32 = 14.0; diff --git a/src/lib.rs b/src/lib.rs index 3f43f39..1882e6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,8 +14,8 @@ pub use crate::{ function_entry::{FunctionEntry, Riemann}, math_app::AppSettings, misc::{ - EguiHelper, HashBytes, hashed_storage_create, hashed_storage_read, newtons_method, - option_vec_printer, step_helper, + hashed_storage_create, hashed_storage_read, newtons_method, option_vec_printer, + step_helper, EguiHelper, }, unicode_helper::{to_chars_array, to_unicode_hash}, }; diff --git a/src/math_app.rs b/src/math_app.rs index 1391f88..a607e6e 100644 --- a/src/math_app.rs +++ b/src/math_app.rs @@ -1,5 +1,5 @@ use crate::{ - consts::{BUILD_INFO, COLORS, DEFAULT_INTEGRAL_NUM, DEFAULT_MAX_X, DEFAULT_MIN_X, build}, + consts::{COLORS, DEFAULT_INTEGRAL_NUM, DEFAULT_MAX_X, DEFAULT_MIN_X}, function_entry::Riemann, function_manager::FunctionManager, misc::option_vec_printer, @@ -138,8 +138,6 @@ impl MathApp { #[cfg(not(threading))] tracing::info!("Threading: Disabled"); - tracing::info!("commit: {}", build::SHORT_COMMIT); - tracing::info!("Initializing..."); let start = Instant::now(); @@ -150,26 +148,24 @@ impl MathApp { fn get_storage_decompressed() -> Option> { let data = get_localstorage().get_item(DATA_NAME).ok()??; - let (commit, cached_data) = crate::misc::hashed_storage_read(&data)?; + let cached_data = crate::misc::hashed_storage_read(&data)?; + + tracing::info!("Reading decompression cache. Bytes: {}", cached_data.len()); + return Some(cached_data); - if commit == unsafe { std::mem::transmute::<&str, crate::misc::HashBytes>(build::SHORT_COMMIT) } { - tracing::info!("Reading decompression cache. Bytes: {}", cached_data.len()); - return Some(cached_data); - } else { - None - } } fn load_functions() -> Option { let data = get_localstorage().get_item(FUNC_NAME).ok()??; - let (commit, func_data) = crate::misc::hashed_storage_read(&data)?; + let func_data = crate::misc::hashed_storage_read(&data)?; - if commit == unsafe { std::mem::transmute::<&str, &[u8]>(build::SHORT_COMMIT) } { - tracing::info!("Reading previous function data"); - let function_manager: FunctionManager = bincode::deserialize(&func_data).ok()?; + + tracing::info!("Reading previous function data"); + if let Ok(Some(function_manager)) = bincode::deserialize(&func_data) { return Some(function_manager); } else { - None + tracing::info!("Unable to load functionManager instance"); + return None; } } @@ -191,12 +187,8 @@ impl MathApp { #[cfg(target = "wasm32")] { tracing::info!("Setting decompression cache"); - let commit: crate::misc::HashBytes = const { - unsafe { - std::mem::transmute::<&str, crate::misc::HashBytes>(build::SHORT_COMMIT) - } - }; - let saved_data = commit.hashed_storage_create(data); + + let saved_data = hashed_storage_create(data); tracing::info!("Bytes: {}", saved_data.len()); get_localstorage() .set_item(DATA_NAME, saved_data) @@ -362,11 +354,9 @@ impl MathApp { #[cfg(target_arch = "wasm32")] { tracing::info!("Saving function data"); - use crate::misc::{HashBytes, hashed_storage_create}; - let hash: HashBytes = - unsafe { std::mem::transmute::<&str, HashBytes>(build::SHORT_COMMIT) }; + use crate::misc::hashed_storage_create; + let saved_data = hashed_storage_create( - hash, &bincode::serialize(&self.functions) .expect("unable to deserialize functions"), ); @@ -520,8 +510,6 @@ impl App for MathApp { .resizable(false) .collapsible(false) .show(ctx, |ui| { - ui.add(egui::Label::new(BUILD_INFO)); - if let Some(ref took) = self.last_info.1 { ui.label(took); } diff --git a/src/misc.rs b/src/misc.rs index feb4366..8353dc0 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -1,4 +1,5 @@ -use base64::{Engine as _, engine::general_purpose}; +use base64::engine::general_purpose; +use base64::Engine; use egui_plot::{Line, PlotPoint, PlotPoints, Points}; use emath::Pos2; use itertools::Itertools; @@ -150,34 +151,14 @@ pub fn step_helper(max_i: usize, min_x: f64, step: f64) -> Vec { .collect() } -pub const HASH_LENGTH: usize = 8; - -/// Represents bytes used to represent hash info -pub type HashBytes = [u8; HASH_LENGTH]; - #[allow(dead_code)] -pub fn hashed_storage_create(hashbytes: HashBytes, data: &[u8]) -> String { - let combined_data = [hashbytes.to_vec(), data.to_vec()].concat(); - general_purpose::STANDARD.encode(combined_data) +pub fn hashed_storage_create(data: &[u8]) -> String { + general_purpose::STANDARD.encode(data) } #[allow(dead_code)] -pub fn hashed_storage_read(data: &str) -> Option<(HashBytes, Vec)> { - // Decode base64 data - let decoded_bytes = general_purpose::STANDARD.decode(data).ok()?; - - // Make sure data is long enough to decode - if HASH_LENGTH > decoded_bytes.len() { - return None; - } - - // Split hash and data - let (hash_bytes, data_bytes) = decoded_bytes.split_at(HASH_LENGTH); - - // Convert hash bytes to HashBytes - let hash: HashBytes = hash_bytes.try_into().ok()?; - - Some((hash, data_bytes.to_vec())) +pub fn hashed_storage_read(data: &str) -> Option> { + general_purpose::STANDARD.decode(data).ok() } include!(concat!(env!("OUT_DIR"), "/valid_chars.rs")); diff --git a/tests/misc.rs b/tests/misc.rs index 70abb58..c947d08 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -69,23 +69,10 @@ fn hashed_storage() { .chars() .map(|c| c as u8) .collect::>(); - let storage_tmp: [u8; 8] = commit - .as_slice() - .try_into() - .expect("cannot turn into [u8; 8]"); - let storage = hashed_storage_create(storage_tmp, data.as_slice()); + let storage = hashed_storage_create(data.as_slice()); let read = hashed_storage_read(&storage); - assert_eq!( - read.map(|(a, b)| (a.to_vec(), b.to_vec())), - Some((commit.to_vec(), data.to_vec())) - ); -} - -#[test] -fn invalid_hashed_storage() { - use ytbn_graphing_software::hashed_storage_read; - assert_eq!(hashed_storage_read("aaaa"), None); + assert_eq!(read, Some(data.to_vec())); } // #[test]