Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the WebAssembly Targets #263

Merged
merged 2 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Format the code
  • Loading branch information
CryZe committed Nov 21, 2019
commit efdc355a4bfd2e223120201532cdf7b804f6ce74
4 changes: 2 additions & 2 deletions capi/src/hotkey_config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The configuration to use for a Hotkey System. It describes with keys to use
//! as hotkeys for the different actions.

use super::{output_vec, str, Json, get_file, release_file};
use super::{get_file, output_vec, release_file, str, Json};
use crate::setting_value::OwnedSettingValue;
use livesplit_core::HotkeyConfig;
use serde_json;
Expand Down Expand Up @@ -59,7 +59,7 @@ pub unsafe extern "C" fn HotkeyConfig_parse_json(settings: Json) -> NullableOwne
HotkeyConfig::from_json(settings).ok().map(Box::new)
}

/// Attempts to parse a hotkey configuration from a given file. <NULL> is
/// Attempts to parse a hotkey configuration from a given file. <NULL> is
/// returned it couldn't be parsed. This will not close the file descriptor /
/// handle.
#[no_mangle]
Expand Down
2 changes: 1 addition & 1 deletion capi/src/layout.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! A Layout allows you to combine multiple components together to visualize a
//! variety of information the runner is interested in.

use super::{output_vec, str, Json, get_file, release_file};
use super::{get_file, output_vec, release_file, str, Json};
use crate::component::OwnedComponent;
use livesplit_core::layout::{parser, LayoutSettings};
use livesplit_core::{Layout, Timer};
Expand Down
2 changes: 1 addition & 1 deletion capi/src/run.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! A Run stores the split times for a specific game and category of a runner.

use super::{output_str, output_time_span, output_vec, str, get_file, release_file};
use super::{get_file, output_str, output_time_span, output_vec, release_file, str};
use crate::parse_run_result::OwnedParseRunResult;
use crate::segment::OwnedSegment;
use livesplit_core::run::{parser, saver};
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/pb_chance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
//! The PB chance is currently calculated through the Balanced PB algorithm. The
//! PB chance is the percentile at which the Balanced PB algorithm finds the PB.

use crate::{comparison, Run, Segment, TimeSpan, Timer, TimingMethod};
use crate::platform::prelude::*;
use crate::{comparison, Run, Segment, TimeSpan, Timer, TimingMethod};

#[cfg(test)]
mod tests;
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/sum_of_segments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub mod worst;
#[cfg(test)]
mod tests;

use crate::{Segment, Time, TimeSpan, TimingMethod};
use crate::platform::prelude::*;
use crate::{Segment, Time, TimeSpan, TimingMethod};

/// Describes the shortest amount of time it takes to reach a certain segment.
/// Since there is the possibility that the shortest path is actually skipping
Expand Down
2 changes: 1 addition & 1 deletion src/comparison/balanced_pb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
//! be smoothed out throughout the whole comparison.

use super::{goal, ComparisonGenerator};
use crate::{Attempt, Segment, TimingMethod};
use crate::platform::prelude::*;
use crate::{Attempt, Segment, TimingMethod};

/// The Comparison Generator for calculating a comparison which has the same
/// final time as the runner's Personal Best. Unlike the Personal Best however,
Expand Down
2 changes: 1 addition & 1 deletion src/comparison/best_segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use super::ComparisonGenerator;
use crate::analysis::sum_of_segments::best::calculate;
use crate::{Attempt, Segment, Time, TimingMethod};
use crate::platform::prelude::*;
use crate::{Attempt, Segment, Time, TimingMethod};

/// The Comparison Generator for calculating the Best Segments of a Run.
#[derive(Copy, Clone, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/comparison/goal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//! Balanced PB comparison however is based on this, which uses the Personal
//! Best as a goal time to balance the mistakes that happened in the Personal Best.

use crate::platform::prelude::*;
use crate::{Segment, Time, TimeSpan, TimingMethod};
use ordered_float::OrderedFloat;
use crate::platform::prelude::*;

/// The default name of the goal comparison.
pub const NAME: &str = "Goal";
Expand Down
2 changes: 1 addition & 1 deletion src/comparison/median_segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//! suited to represent the current performance of a runner.

use super::ComparisonGenerator;
use crate::platform::prelude::*;
use crate::{Attempt, Segment, TimeSpan, TimingMethod};
use ordered_float::OrderedFloat;
use crate::platform::prelude::*;

/// The Comparison Generator for calculating the Median Segments of a Run. The
/// Median Segments are calculated through a weighted median that gives more
Expand Down
2 changes: 1 addition & 1 deletion src/comparison/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub use self::median_segments::MedianSegments;
pub use self::none::None;
pub use self::worst_segments::WorstSegments;

use crate::platform::prelude::*;
use crate::{Attempt, Segment, Timer};
use core::fmt::Debug;
use crate::platform::prelude::*;

/// Defines the Personal Best comparison. This module mostly just serves for
/// providing the names of the comparison, as the Personal Best is not a
Expand Down
2 changes: 1 addition & 1 deletion src/comparison/worst_segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use super::ComparisonGenerator;
use crate::analysis::sum_of_segments::worst::calculate;
use crate::{Attempt, Segment, Time, TimingMethod};
use crate::platform::prelude::*;
use crate::{Attempt, Segment, Time, TimingMethod};

/// The Comparison Generator for calculating the Worst Segments of a Run.
#[derive(Copy, Clone, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/component/detailed_timer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use super::timer;
use crate::comparison::{self, best_segments, none};
use crate::platform::prelude::*;
use crate::settings::{
CachedImageId, Field, Gradient, ImageData, SemanticColor, SettingsDescription, Value,
};
Expand All @@ -15,7 +16,6 @@ use crate::timing::formatter::{
};
use crate::{GeneralLayoutSettings, Segment, TimeSpan, Timer, TimerPhase, TimingMethod};
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;

#[cfg(test)]
mod tests;
Expand Down
2 changes: 1 addition & 1 deletion src/component/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
//! the chosen comparison throughout the whole attempt. All the individual
//! deltas are shown as points in a graph.

use crate::platform::prelude::*;
use crate::settings::{Color, Field, SettingsDescription, Value};
use crate::{analysis, comparison, GeneralLayoutSettings, TimeSpan, Timer, TimerPhase};
use alloc::borrow::Cow;
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;

const GRAPH_EDGE_VALUE: f32 = 200.0;
const GRAPH_EDGE_MIN: f32 = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion src/component/pb_chance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
//! how well the attempt is going.

use super::key_value;
use crate::platform::prelude::*;
use crate::settings::{Color, Field, Gradient, SettingsDescription, Value};
use crate::{analysis::pb_chance, Timer};
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;

/// The PB Chance Component is a component that shows how likely it is to beat
/// the Personal Best. If there is no active attempt it shows the general chance
Expand Down
4 changes: 2 additions & 2 deletions src/component/possible_time_save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

use super::key_value;
use crate::analysis::possible_time_save;
use crate::platform::prelude::*;
use crate::settings::{Color, Field, Gradient, SettingsDescription, Value};
use crate::timing::formatter::{Accuracy, PossibleTimeSave, TimeFormatter};
use crate::{comparison, Timer, TimerPhase};
use serde::{Deserialize, Serialize};
use alloc::borrow::Cow;
use core::fmt::Write as FmtWrite;
use crate::platform::prelude::*;
use serde::{Deserialize, Serialize};

/// The Possible Time Save Component is a component that shows how much time the
/// chosen comparison could've saved for the current segment, based on the Best
Expand Down
4 changes: 2 additions & 2 deletions src/component/previous_segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
//! active time loss whenever the runner is losing time on the current segment.

use super::key_value;
use crate::platform::prelude::*;
use crate::settings::{Color, Field, Gradient, SemanticColor, SettingsDescription, Value};
use crate::timing::formatter::{Accuracy, Delta, PossibleTimeSave, TimeFormatter};
use crate::{analysis, comparison, GeneralLayoutSettings, Timer, TimerPhase};
use serde::{Deserialize, Serialize};
use alloc::borrow::Cow;
use core::fmt::Write as FmtWrite;
use crate::platform::prelude::*;
use serde::{Deserialize, Serialize};

/// The Previous Segment Component is a component that shows how much time was
/// saved or lost during the previous segment based on the chosen comparison.
Expand Down
2 changes: 1 addition & 1 deletion src/component/splits/column.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::platform::prelude::*;
use crate::{
analysis::{self, possible_time_save, split_color},
comparison,
Expand All @@ -6,7 +7,6 @@ use crate::{
GeneralLayoutSettings, Segment, TimeSpan, Timer, TimingMethod,
};
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;

/// The settings of an individual column showing timing information on each
/// split.
Expand Down
2 changes: 1 addition & 1 deletion src/component/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//! a situation where you have a label and a value.

use super::key_value;
use crate::platform::prelude::*;
use crate::settings::{Color, Field, Gradient, SettingsDescription, Value};
use alloc::borrow::Cow;
use core::mem::replace;
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;

/// The Text Component simply visualizes any given text. This can either be a
/// single centered text, or split up into a left and right text, which is
Expand Down
2 changes: 1 addition & 1 deletion src/component/title/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
//! that is being run. Additionally, the game icon, the attempt count, and the
//! total number of finished runs can be shown.

use crate::platform::prelude::*;
use crate::settings::{Alignment, Color, Field, Gradient, SettingsDescription, Value};
use crate::{
settings::{CachedImageId, Image, ImageData},
Timer, TimerPhase,
};
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;

#[cfg(test)]
mod tests;
Expand Down
2 changes: 1 addition & 1 deletion src/layout/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::component::{
possible_time_save, previous_segment, separator, splits, sum_of_best, text, timer, title,
total_playtime,
};
use crate::platform::prelude::*;
use crate::settings::{SettingsDescription, Value};
use crate::Timer;
use alloc::borrow::Cow;
use crate::platform::prelude::*;

/// A Component provides information about a run in a way that is easy to
/// visualize. This type can store any of the components provided by this crate.
Expand Down
2 changes: 1 addition & 1 deletion src/layout/component_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::component::{
possible_time_save, previous_segment, separator, splits, sum_of_best, text, timer, title,
total_playtime,
};
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;
use serde::{Deserialize, Serialize};

/// The settings for one of the components available.
#[derive(Clone, Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/layout/component_state.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::component::{
blank_space, detailed_timer, graph, key_value, separator, splits, text, timer, title,
};
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;
use serde::{Deserialize, Serialize};

/// The state object for one of the components available.
#[derive(Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/layout/editor/state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::Editor;
use crate::platform::prelude::*;
use crate::settings::SettingsDescription;
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;

/// Represents the current state of the Layout Editor in order to visualize it
/// properly.
Expand Down
2 changes: 1 addition & 1 deletion src/layout/general_settings.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::LayoutDirection;
use crate::platform::prelude::*;
use crate::settings::{Color, Field, Gradient, SettingsDescription, Value};
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;

/// The general settings of the layout that apply to all components.
#[derive(Clone, Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/layout/layout_settings.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{ComponentSettings, GeneralSettings};
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;
use serde::{Deserialize, Serialize};

/// Describes a whole layout by its settings in a way that can easily be
/// serialized and deserialized.
Expand Down
2 changes: 1 addition & 1 deletion src/layout/layout_state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{ComponentState, LayoutDirection};
use crate::platform::prelude::*;
use crate::settings::{Color, Gradient};
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;

/// The state object describes the information to visualize for the layout.
#[derive(Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub use self::layout_settings::LayoutSettings;
pub use self::layout_state::LayoutState;

use crate::component::{previous_segment, splits, timer, title};
use crate::timing::Timer;
use crate::platform::prelude::*;
use crate::timing::Timer;

/// A Layout allows you to combine multiple components together to visualize a
/// variety of information the runner is interested in.
Expand Down
3 changes: 1 addition & 2 deletions src/platform/wasm/web/time.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ordered_float::OrderedFloat;
use std::ops::Sub;
use web_sys::window;
use std::time::Duration;
use web_sys::window;

#[derive(Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Debug)]
pub struct Instant(OrderedFloat<f64>);
Expand All @@ -27,4 +27,3 @@ impl Sub for Instant {
Duration::new(secs, nanos)
}
}

5 changes: 2 additions & 3 deletions src/run/editor/cleaning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
//! them seem wrong.

use crate::analysis::sum_of_segments::{best, track_branch, Prediction};
use crate::platform::prelude::*;
use crate::platform::Local;
use crate::timing::formatter::{Short, TimeFormatter};
use crate::{Attempt, Run, Segment, TimeSpan, TimingMethod};
use crate::platform::Local;
use core::fmt;
use core::mem::replace;
use crate::platform::prelude::*;

/// A Sum of Best Cleaner allows you to interactively remove potential issues in
/// the Segment History that lead to an inaccurate Sum of Best. If you skip a
Expand Down Expand Up @@ -101,7 +101,6 @@ impl fmt::Display for PotentialCleanUp<'_> {
write!(
f,
" in a run on {}",
// TODO: Is this even correct? What does this do on no_std-ish platforms like wasm-unknown?!
ended.time.with_timezone(&Local).format("%F")
)?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/run/editor/fuzzy_list.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::platform::prelude::*;
use alloc::collections::BinaryHeap;
use core::usize;
use crate::platform::prelude::*;

/// With a Fuzzy List, you can implement a fuzzy searching algorithm. The list
/// stores all the items that can be searched for. With the `search` method you
Expand Down
2 changes: 1 addition & 1 deletion src/run/editor/state.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::{Editor, SegmentRow, TimingMethod};
use crate::comparison::personal_best;
use crate::platform::prelude::*;
use crate::run::RunMetadata;
use crate::settings::{CachedImageId, ImageData};
use crate::timing::formatter::none_wrapper::EmptyWrapper;
use crate::timing::formatter::{Accuracy, Short, TimeFormatter};
use serde::{Deserialize, Serialize};
use crate::platform::prelude::*;

/// Represents the current state of the Run Editor in order to visualize it
/// properly.
Expand Down
8 changes: 4 additions & 4 deletions src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ pub use segment::Segment;
pub use segment_history::SegmentHistory;

use crate::comparison::{default_generators, personal_best, ComparisonGenerator};
use crate::platform::prelude::*;
use crate::{settings::Image, AtomicDateTime, Time, TimeSpan, TimingMethod};
use alloc::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::string::String as PathBuf;
use core::cmp::max;
use ordered_float::OrderedFloat;
use hashbrown::HashSet;
use ordered_float::OrderedFloat;
#[cfg(feature = "std")]
use std::path::PathBuf;
#[cfg(not(feature = "std"))]
use alloc::string::String as PathBuf;
use crate::platform::prelude::*;

/// A Run stores the split times for a specific game and category of a runner.
///
Expand Down
Loading