changes
This commit is contained in:
parent
e2c2713633
commit
8915c7587f
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1833,9 +1833,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rayon"
|
name = "rayon"
|
||||||
version = "1.5.2"
|
version = "1.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221"
|
checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"crossbeam-deque",
|
"crossbeam-deque",
|
||||||
|
|||||||
3
build.sh
3
build.sh
@ -24,7 +24,8 @@ wasm-bindgen target/wasm32-unknown-unknown/${TYPE}/ytbn_graphing_software.wasm -
|
|||||||
|
|
||||||
if test "$TYPE" == "release"; then
|
if test "$TYPE" == "release"; then
|
||||||
echo "running wasm-opt..."
|
echo "running wasm-opt..."
|
||||||
time wasm-opt --converge -Oz --dae --dce --code-folding --const-hoisting --coalesce-locals-learning --vacuum --merge-locals --merge-blocks --fast-math --precompute --rse --low-memory-unused --traps-never-happen --ignore-implicit-traps -o pkg/ytbn_graphing_software_bg_2.wasm pkg/ytbn_graphing_software_bg.wasm
|
time wasm-opt --converge -Oz --dae --dce --code-folding --const-hoisting --coalesce-locals-learning --vacuum --merge-locals --merge-blocks --fast-math --precompute --rse --low-memory-unused --traps-never-happen --ignore-implicit-traps --once-reduction --optimize-instructions --licm --intrinsic-lowering \
|
||||||
|
-o pkg/ytbn_graphing_software_bg_2.wasm pkg/ytbn_graphing_software_bg.wasm
|
||||||
mv pkg/ytbn_graphing_software_bg_2.wasm pkg/ytbn_graphing_software_bg.wasm
|
mv pkg/ytbn_graphing_software_bg_2.wasm pkg/ytbn_graphing_software_bg.wasm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ pub fn split_function_chars(chars: &[char], split: SplitType) -> Vec<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resulting split-up data
|
// Resulting split-up data
|
||||||
let mut data: Vec<String> = vec![chars[0].to_string()];
|
let mut data: Vec<String> = std::vec::from_elem(chars[0].to_string(), 1);
|
||||||
|
|
||||||
/// Used to store info about a character
|
/// Used to store info about a character
|
||||||
struct BoolSlice {
|
struct BoolSlice {
|
||||||
@ -202,13 +202,14 @@ pub fn generate_hint<'a>(input: &str) -> &'a Hint<'a> {
|
|||||||
pub fn get_last_term(chars: &[char]) -> String {
|
pub fn get_last_term(chars: &[char]) -> String {
|
||||||
assert!(!chars.is_empty());
|
assert!(!chars.is_empty());
|
||||||
|
|
||||||
let result = split_function_chars(chars, SplitType::Term);
|
let mut result = split_function_chars(chars, SplitType::Term);
|
||||||
unsafe {
|
unsafe {
|
||||||
assume(!result.is_empty());
|
assume(!result.is_empty());
|
||||||
assume(result.len() > 0);
|
assume(result.len() > 0);
|
||||||
result.last().unwrap_unchecked()
|
let output = result.pop();
|
||||||
|
assume(output.is_some());
|
||||||
|
output.unwrap_unchecked()
|
||||||
}
|
}
|
||||||
.to_owned()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Copy)]
|
#[derive(PartialEq, Clone, Copy)]
|
||||||
|
|||||||
@ -11,6 +11,7 @@ use egui::{
|
|||||||
use emath::{Align, Align2};
|
use emath::{Align, Align2};
|
||||||
use epaint::Rounding;
|
use epaint::Rounding;
|
||||||
use instant::{Duration, Instant};
|
use instant::{Duration, Instant};
|
||||||
|
use std::intrinsics::assume;
|
||||||
use std::{io::Read, ops::BitXorAssign};
|
use std::{io::Read, ops::BitXorAssign};
|
||||||
|
|
||||||
#[cfg(threading)]
|
#[cfg(threading)]
|
||||||
@ -120,7 +121,6 @@ impl MathApp {
|
|||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(target_arch = "wasm32")] {
|
||||||
use wasm_bindgen::JsCast;
|
|
||||||
if let Some(web_info) = &cc.integration_info.web_info {
|
if let Some(web_info) = &cc.integration_info.web_info {
|
||||||
tracing::info!("Web Info: {:?}", web_info);
|
tracing::info!("Web Info: {:?}", web_info);
|
||||||
}
|
}
|
||||||
@ -133,24 +133,28 @@ impl MathApp {
|
|||||||
get_window().local_storage().expect("failed to get localstorage1").expect("failed to get localstorage2")
|
get_window().local_storage().expect("failed to get localstorage1").expect("failed to get localstorage2")
|
||||||
}
|
}
|
||||||
|
|
||||||
let loading_element = get_window().document()
|
|
||||||
.expect("Could not get web_sys document")
|
|
||||||
.get_element_by_id("loading")
|
|
||||||
.expect("Couldn't get loading indicator element")
|
|
||||||
.dyn_into::<web_sys::HtmlElement>()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
|
|
||||||
fn update_loading(loading_element: &web_sys::HtmlElement, add: i32) {
|
|
||||||
let value = loading_element.get_attribute("value").expect("unable to get loading_elements's `value`").parse::<i32>().expect("unable to parse value as i32");
|
|
||||||
loading_element.set_attribute("value", &(add + value).to_string()).expect("unable to set loading_element's `value`");
|
|
||||||
}
|
|
||||||
|
|
||||||
const DATA_NAME: &str = "YTBN-DECOMPRESSED";
|
const DATA_NAME: &str = "YTBN-DECOMPRESSED";
|
||||||
fn get_storage_decompressed() -> Option<Vec<u8>> {
|
fn get_storage_decompressed() -> Option<Vec<u8>> {
|
||||||
let data = get_localstorage().get_item(DATA_NAME).ok()??;
|
let data = get_localstorage().get_item(DATA_NAME).ok()??;
|
||||||
|
|
||||||
|
debug_assert!(!data.is_empty());
|
||||||
|
unsafe {
|
||||||
|
assume(!data.is_empty());
|
||||||
|
assume(data.len() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
let (commit, cached_data) = crate::misc::hashed_storage_read(data);
|
let (commit, cached_data) = crate::misc::hashed_storage_read(data);
|
||||||
|
|
||||||
|
debug_assert!(!commit.is_empty());
|
||||||
|
debug_assert!(!cached_data.is_empty());
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
assume(commit.len() > 0);
|
||||||
|
assume(cached_data.len() > 0);
|
||||||
|
assume(!commit.is_empty());
|
||||||
|
assume(!cached_data.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
if commit == build::SHORT_COMMIT {
|
if commit == build::SHORT_COMMIT {
|
||||||
tracing::info!("Reading decompression cache. Bytes: {}, or: {}", cached_data.len(), crate::misc::format_bytes(cached_data.len()));
|
tracing::info!("Reading decompression cache. Bytes: {}, or: {}", cached_data.len(), crate::misc::format_bytes(cached_data.len()));
|
||||||
return Some(cached_data.to_vec());
|
return Some(cached_data.to_vec());
|
||||||
@ -163,6 +167,13 @@ impl MathApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_storage_decompressed(data: &[u8]) {
|
fn set_storage_decompressed(data: &[u8]) {
|
||||||
|
debug_assert!(!data.is_empty());
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
assume(data.len() > 0);
|
||||||
|
assume(!data.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
tracing::info!("Setting decompression cache");
|
tracing::info!("Setting decompression cache");
|
||||||
let saved_data = &crate::misc::hashed_storage_create(&build::SHORT_COMMIT.as_bytes(), data);
|
let saved_data = &crate::misc::hashed_storage_create(&build::SHORT_COMMIT.as_bytes(), data);
|
||||||
tracing::info!("Bytes: {}, or: {}", saved_data.len(), crate::misc::format_bytes(data.len()));
|
tracing::info!("Bytes: {}, or: {}", saved_data.len(), crate::misc::format_bytes(data.len()));
|
||||||
@ -173,9 +184,20 @@ impl MathApp {
|
|||||||
if let Ok(Some(data)) = get_localstorage().get_item("YTBN-FUNCTIONS") {
|
if let Ok(Some(data)) = get_localstorage().get_item("YTBN-FUNCTIONS") {
|
||||||
let (commit, func_data) = crate::misc::hashed_storage_read(data);
|
let (commit, func_data) = crate::misc::hashed_storage_read(data);
|
||||||
|
|
||||||
|
debug_assert!(!commit.is_empty());
|
||||||
|
debug_assert!(!func_data.is_empty());
|
||||||
|
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
assume(commit.len() > 0);
|
||||||
|
assume(func_data.len() > 0);
|
||||||
|
assume(!commit.is_empty());
|
||||||
|
assume(!func_data.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
if commit == build::SHORT_COMMIT {
|
if commit == build::SHORT_COMMIT {
|
||||||
tracing::info!("Reading previous function data");
|
tracing::info!("Reading previous function data");
|
||||||
let function_manager: FunctionManager = bincode::deserialize(&func_data).unwrap();
|
let function_manager: FunctionManager = unsafe { bincode::deserialize(&func_data).unwrap_unchecked() };
|
||||||
return Some(function_manager);
|
return Some(function_manager);
|
||||||
} else {
|
} else {
|
||||||
tracing::info!("Previous functions are invalid due to differing commits (build: {}, previous: {})", build::SHORT_COMMIT, commit);
|
tracing::info!("Previous functions are invalid due to differing commits (build: {}, previous: {})", build::SHORT_COMMIT, commit);
|
||||||
@ -215,11 +237,15 @@ impl MathApp {
|
|||||||
data
|
data
|
||||||
};
|
};
|
||||||
|
|
||||||
let data: crate::data::TotalData =
|
debug_assert!(data_decompressed.is_empty());
|
||||||
bincode::deserialize(data_decompressed.as_slice()).unwrap();
|
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
unsafe {
|
||||||
update_loading(&loading_element, 30);
|
assume(data_decompressed.len() > 0);
|
||||||
|
assume(!data_decompressed.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
let data: crate::data::TotalData =
|
||||||
|
unsafe { bincode::deserialize(data_decompressed.as_slice()).unwrap_unchecked() };
|
||||||
|
|
||||||
tracing::info!("Reading assets...");
|
tracing::info!("Reading assets...");
|
||||||
|
|
||||||
@ -230,15 +256,8 @@ impl MathApp {
|
|||||||
// Set dark mode by default
|
// Set dark mode by default
|
||||||
cc.egui_ctx.set_visuals(Visuals::dark());
|
cc.egui_ctx.set_visuals(Visuals::dark());
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
update_loading(&loading_element, 20);
|
|
||||||
|
|
||||||
tracing::info!("Initialized! Took: {:?}", start.elapsed());
|
tracing::info!("Initialized! Took: {:?}", start.elapsed());
|
||||||
|
|
||||||
// Remove loading indicator on wasm
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
loading_element.remove();
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
functions: get_functions().unwrap_or_default(),
|
functions: get_functions().unwrap_or_default(),
|
||||||
last_info: (vec![None], None),
|
last_info: (vec![None], None),
|
||||||
|
|||||||
@ -57,50 +57,6 @@
|
|||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, 0%);
|
transform: translate(-50%, 0%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.centered {
|
|
||||||
margin-right: auto;
|
|
||||||
margin-left: auto;
|
|
||||||
display: block;
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
color: #f0f0f0;
|
|
||||||
font-size: 24px;
|
|
||||||
font-family: Ubuntu-Light, Helvetica, sans-serif;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------- */
|
|
||||||
/* Loading animation from https://loading.io/css/ */
|
|
||||||
.lds-dual-ring {
|
|
||||||
display: inline-block;
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lds-dual-ring:after {
|
|
||||||
content: " ";
|
|
||||||
display: block;
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
margin: 0px;
|
|
||||||
border-radius: 50%;
|
|
||||||
border: 3px solid #fff;
|
|
||||||
border-color: #fff transparent #fff transparent;
|
|
||||||
animation: lds-dual-ring 1.2s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes lds-dual-ring {
|
|
||||||
0% {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
100% {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -108,7 +64,6 @@
|
|||||||
<noscript>Please enable Javascript, this page uses both WebAssembly and Javascript to run.</noscript>
|
<noscript>Please enable Javascript, this page uses both WebAssembly and Javascript to run.</noscript>
|
||||||
|
|
||||||
<canvas id="canvas"></canvas>
|
<canvas id="canvas"></canvas>
|
||||||
<progress class="centered" id="loading" value="0" max="100"></progress>
|
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
delete WebAssembly.instantiateStreaming;
|
delete WebAssembly.instantiateStreaming;
|
||||||
|
|||||||
@ -4,6 +4,7 @@ var filesToCache = [
|
|||||||
'./index.html',
|
'./index.html',
|
||||||
'./ytbn_graphing_software.js',
|
'./ytbn_graphing_software.js',
|
||||||
'./ytbn_graphing_software_bg.wasm',
|
'./ytbn_graphing_software_bg.wasm',
|
||||||
|
"./favicon.ico"
|
||||||
];
|
];
|
||||||
|
|
||||||
/* Start the service worker and cache all of the app's content */
|
/* Start the service worker and cache all of the app's content */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user