-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move running the solutions to use web workers, not blocking the main …
…rendering
- Loading branch information
Showing
13 changed files
with
337 additions
and
86 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use chrono::Local; | ||
use yew_agent::prelude::*; | ||
|
||
use aoc_solver::{solution::Solver, y2020::Y2020, y2021::Y2021, y2022::Y2022, y2023::Y2023}; | ||
|
||
#[oneshot] | ||
pub async fn SolutionTask(input: (u32, u8)) -> (String, i64) { | ||
let (year, day) = input; | ||
|
||
let start = Local::now(); | ||
|
||
let output = match year { | ||
2020 => Y2020::run_solution(day, None), | ||
2021 => Y2021::run_solution(day, None), | ||
2022 => Y2022::run_solution(day, None), | ||
2023 => Y2023::run_solution(day, None), | ||
_ => vec!["Missing year".to_string()], | ||
}; | ||
|
||
let duration = (Local::now() - start).num_milliseconds(); | ||
|
||
(output.join("\n"), duration) | ||
} |
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,21 @@ | ||
use yew::prelude::*; | ||
|
||
use aoc_web::{footer::Footer, router::Router}; | ||
|
||
#[function_component(App)] | ||
fn app() -> Html { | ||
html! { | ||
<> | ||
<Router/> | ||
<Footer /> | ||
</> | ||
} | ||
} | ||
|
||
fn main() { | ||
let document = gloo::utils::document(); | ||
let container = document.query_selector("#aoc").unwrap().unwrap(); | ||
|
||
yew::Renderer::<App>::with_root(container).render(); | ||
wasm_logger::init(wasm_logger::Config::default()); | ||
} |
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 @@ | ||
use yew_agent::Registrable; | ||
|
||
use aoc_web::agent::SolutionTask; | ||
|
||
fn main() { | ||
SolutionTask::registrar().register(); | ||
} |
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,16 @@ | ||
use yew::prelude::*; | ||
|
||
#[function_component(Footer)] | ||
pub fn footer() -> Html { | ||
html! { | ||
<footer> | ||
<small> | ||
{"Made by "} | ||
<a href="https://github.com/Cadiac">{"Cadiac"}</a> | ||
{". Source code can be be found "} | ||
<a href="https://github.com/Cadiac/adventofcode">{"here"}</a> | ||
{"."} | ||
</small> | ||
</footer> | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pub mod agent; | ||
pub mod footer; | ||
pub mod header; | ||
pub mod home; | ||
pub mod navlink; | ||
pub mod router; | ||
pub mod solution; | ||
pub mod year; | ||
|
||
pub mod y2020; | ||
pub mod y2021; | ||
pub mod y2022; | ||
pub mod y2023; |
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
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