Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
akarras committed Feb 2, 2024
1 parent 00a58e0 commit fb1da5a
Show file tree
Hide file tree
Showing 21 changed files with 652 additions and 365 deletions.
766 changes: 502 additions & 264 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ members = [
resolver = "2"

[workspace.dependencies]
axum = {version = "0.7.4", features = ["ws", "json"]}
axum-extra = {version = "0.9.2", features = ["cookie", "cookie-private", "typed-header"]}
tokio = {version = "1", features = ["full"]}
tracing = "0.1.36"
tracing-subscriber = "0.3"
futures = "0.3.24"
anyhow = "1.0.72"
leptos = { version = "0.5.7", default-features = false, features = [
leptos = { version = "0.6.4", default-features = false, features = [
"serde",
"nightly"
] }
leptos_axum = { version = "0.5.7" }
leptos_router = { version = "0.5.7", default-features = false, features = ["nightly"] }
leptos_meta = { version = "0.5.7", default-features = false, features = ["nightly"] }
leptos-use = { verion = "0.9.0", features = ["serde"] }
leptos_axum = { version = "0.6.4" }
leptos_router = { version = "0.6.4", default-features = false, features = ["nightly"] }
leptos_meta = { version = "0.6.4", default-features = false, features = ["nightly"] }
leptos-use = { git = "https://github.com/Synphonyte/leptos-use.git", features = ["serde"] }
chrono = "0.4.23"
itertools = "0.12.0"
image = "0.24.6"
Expand All @@ -37,9 +39,10 @@ yoke = "0.7.1"
xiv-gen = {path = "./xiv-gen", features = ["item", "item_ui_category", "item_search_category", "class_job", "recipe",
"class_job_category", "base_param", "item_sort_category"]}
icondata = "0.3"
leptos_icons = {version = "0.2.1" }
leptos_icons = {version = "0.3.0" }
cfg-if = "1.0.0"
git-const = "1.1.0"
gloo-net = {version = "0.5.0", features = ["http", "websocket"]}

[patch.crates-io]
#leptos = { git = "https://github.com/leptos-rs/leptos.git" }
Expand Down
7 changes: 4 additions & 3 deletions ultros-frontend/ultros-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ leptos = { workspace = true, features = ["nightly"] }
leptos_meta = { workspace = true, features = ["nightly"] }
leptos_router = { workspace = true, features = ["nightly"] }
leptos_axum = { workspace = true, optional = true }
axum = { workspace = true, optional = true }
leptos-use = { workspace = true }
xiv-gen-db = {path = "../../xiv-gen-db"}
xiv-gen.workspace = true
sublime_fuzzy = "0.7"
reqwest = {version = "0.11.0", optional = true, default-features = false, features = ["json", "rustls-tls", "brotli", "gzip", "deflate"]}
gloo-net = {version = "0.4", optional = true, features = ["http", "websocket"]}
gloo = {version = "0.10.0", optional = true}
gloo-net = {workspace = true, optional = true}
gloo = {version = "0.11.0", optional = true}
web-sys = {version = "0.3", optional = true, features = ["AbortController", "Clipboard", "Window", "Navigator", "HtmlCanvasElement", "HtmlDivElement", "HtmlElement", "HtmlDocument"]}
ultros-api-types = {path = "../../ultros-api-types"}
ultros-db = {path = "../../ultros-db", optional = true}
Expand Down Expand Up @@ -51,4 +52,4 @@ percent-encoding = "2.3.0"
[features]
default = ["ssr"] # this is mostly so if I run cargo check, it has a flavor to work on
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate", "gloo", "gloo-net", "web-sys", "wasm-bindgen", "time/wasm-bindgen", "js-sys"]
ssr = ["leptos/ssr", "leptos_meta/ssr", "leptos_router/ssr", "reqwest", "leptos_axum", "web-sys", "ultros-db", "xiv-gen-db/embed", "leptos-use/ssr"]
ssr = ["leptos/ssr", "leptos_meta/ssr", "leptos_router/ssr", "reqwest", "leptos_axum", "web-sys", "ultros-db", "xiv-gen-db/embed", "leptos-use/ssr", "axum"]
33 changes: 26 additions & 7 deletions ultros-frontend/ultros-app/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ pub(crate) async fn delete_api<T>(path: &str) -> AppResult<T>
where
T: Serializable,
{
use axum::http::request::Parts;
// use the original headers of the scope
// add the hostname when using the ssr path.
use tracing::Instrument;
Expand All @@ -330,13 +331,22 @@ where
.build()
.unwrap()
});
let req_parts = use_context::<leptos_axum::RequestParts>().ok_or(AppError::ParamMissing)?;
let req_parts = use_context::<Parts>().ok_or(AppError::ParamMissing)?;
let headers = req_parts.headers;
let hostname = "http://localhost:8080";
let path = format!("{hostname}{path}");
// headers.remove("Accept-Encoding");

let request = client.delete(&path).headers(headers).build()?;
// this is only necessary because reqwest isn't updated to http 1.0- and I'm being lazy
let mut new_map = reqwest::header::HeaderMap::new();
for (name, value) in headers.into_iter().filter_map(|(name, value)| {
Some((
reqwest::header::HeaderName::from_lowercase(name?.as_str().as_bytes()).ok()?,
reqwest::header::HeaderValue::from_bytes(value.as_bytes()).ok()?,
))
}) {
new_map.insert(name, value);
}
let request = client.delete(&path).headers(new_map).build()?;
let json = client
.execute(request)
.await
Expand Down Expand Up @@ -388,6 +398,7 @@ where
{
// use the original headers of the scope
// add the hostname when using the ssr path.
use axum::http::request::Parts;
use tracing::Instrument;

static CLIENT: std::sync::OnceLock<reqwest::Client> = std::sync::OnceLock::new();
Expand All @@ -397,13 +408,21 @@ where
.build()
.unwrap()
});
let req_parts = use_context::<leptos_axum::RequestParts>().ok_or(AppError::ParamMissing)?;
let req_parts = use_context::<Parts>().ok_or(AppError::ParamMissing)?;
let headers = req_parts.headers;
let hostname = "http://localhost:8080";
let path = format!("{hostname}{path}");
// headers.remove("Accept-Encoding");

let request = client.get(&path).headers(headers).build()?;
// this is only necessary because reqwest isn't updated to http 1.0- and I'm being lazy
let mut new_map = reqwest::header::HeaderMap::new();
for (name, value) in headers.into_iter().filter_map(|(name, value)| {
Some((
reqwest::header::HeaderName::from_lowercase(name?.as_str().as_bytes()).ok()?,
reqwest::header::HeaderValue::from_bytes(value.as_bytes()).ok()?,
))
}) {
new_map.insert(name, value);
}
let request = client.get(&path).headers(new_map).build()?;
let json = client
.execute(request)
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn CheapestPrice(item_id: ItemId, #[prop(optional)] show_hq: Option<bool>) -
<span><WorldName id=AnySelector::World(listing.world_id)/></span>
</div>
}.into_view()
}).unwrap_or(view!{"----"}.into_view())
}).unwrap_or("----".into_view())
})
})}
</Suspense>
Expand Down
27 changes: 3 additions & 24 deletions ultros-frontend/ultros-app/src/components/recently_viewed.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
use std::collections::VecDeque;

use leptos::*;
#[cfg(feature = "hydrate")]
use leptos_use::storage::{use_local_storage, JsonCodec};
use leptos_use::storage::use_local_storage;

use crate::components::{search_result::ItemSearchResult, skeleton::BoxSkeleton};

#[derive(Clone, Copy)]
pub struct RecentItems {
#[cfg(feature = "hydrate")]
read_signal: Signal<VecDeque<i32>>,
#[cfg(feature = "hydrate")]
write_signal: WriteSignal<VecDeque<i32>>,
}

impl RecentItems {
#[cfg(feature = "hydrate")]
pub fn new() -> Self {
use leptos_use::utils::JsonCodec;

let (read_signal, write_signal, _delete_fn) =
use_local_storage::<VecDeque<i32>, JsonCodec>("recently_viewed");
Self {
Expand All @@ -25,22 +23,10 @@ impl RecentItems {
}
}

#[cfg(not(feature = "hydrate"))]
pub fn new() -> Self {
Self {}
}

#[cfg(feature = "hydrate")]
pub fn reader(&self) -> Signal<VecDeque<i32>> {
self.read_signal
}

#[cfg(not(feature = "hydrate"))]
pub fn reader(&self) -> Signal<VecDeque<i32>> {
create_memo(|_| VecDeque::new()).into()
}

#[cfg(feature = "hydrate")]
pub fn add_item(&self, item_id: i32) {
use itertools::Itertools;

Expand All @@ -52,13 +38,6 @@ impl RecentItems {
}
});
}

#[cfg(not(feature = "hydrate"))]
pub fn add_item(&self, _item_id: i32) {
use log::warn;

warn!("added item to recently view ssr side.");
}
}

#[component]
Expand Down
51 changes: 42 additions & 9 deletions ultros-frontend/ultros-app/src/components/related_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,32 @@ use crate::{

use super::{cheapest_price::*, gil::*, small_item_display::*};

/// Matches against items that start with the same prefix
/// "Diadochos" -> "Diadochos Helmet" etc
fn prefix_item_iterator(item: &'static Item) -> impl Iterator<Item = &'static Item> {
let items = &xiv_gen_db::data().items;
let prefix = item.name.split_once(' ').map(|(prefix, _)| prefix);
items.values().filter(move |f| {
if let Some(prefix) = prefix {
f.name.starts_with(prefix) && f.item_search_category.0 != 0 && f.level_item.0 == item.level_item.0
} else {
false
}
})
}

fn suffix_item_iterator(item: &'static Item) -> impl Iterator<Item = &'static Item> {
let items = &xiv_gen_db::data().items;
let suffix = item.name.rsplit_once(' ').map(|(_, suffix)| suffix);
items.values().filter(move |f| {
if let Some(suffix) = suffix {
f.name.ends_with(suffix) && f.item_search_category.0 != 0 && f.level_item.0 == item.level_item.0
} else {
false
}
})
}

/// This iterator will attempt to find related items using the classjobcategory && ilvl
fn item_set_iter(item: &'static Item) -> impl Iterator<Item = &'static Item> {
let items = &xiv_gen_db::data().items;
Expand All @@ -20,7 +46,7 @@ fn item_set_iter(item: &'static Item) -> impl Iterator<Item = &'static Item> {
&& item.class_job_category.0 == i.class_job_category.0
&& item.level_item.0 == i.level_item.0
&& i.key_id != item.key_id
&& item.item_search_category.0 != 0
&& item.item_search_category.0 > 0
})
.sorted_by_key(|i| i.key_id.0)
}
Expand Down Expand Up @@ -126,32 +152,39 @@ fn Recipe(recipe: &'static Recipe) -> impl IntoView {
pub fn RelatedItems(#[prop(into)] item_id: Signal<i32>) -> impl IntoView {
let db = xiv_gen_db::data();
let item = create_memo(move |_| db.items.get(&ItemId(item_id())));
let item_set = create_memo(move |_| {
let item_set = move || {
item()
.map(|item| {
item_set_iter(item)
.chain(prefix_item_iterator(item))
.chain(suffix_item_iterator(item))
.unique_by(|i| i.key_id)
.filter(|i| i.item_search_category.0 > 0)
.map(|item| {
view! {
<SmallItemDisplay item/>
<div class="flex flex-col gap-1 rounded p-1 border bg-size-200 transition-all duration-500 bg-pos-0 hover:bg-pos-100 border-violet-950 from-violet-950 via-neutral-950 to-yellow-300 bg-gradient-to-tr text-xl">
<SmallItemDisplay item/>
<div class="min-w-60">"price: "<CheapestPrice item_id=item.key_id /></div>
</div>
}
})
.take(30)
.take(15)
.collect::<Vec<_>>()
})
.unwrap_or_default()
});
};
let recipes = create_memo(move |_| {
recipe_tree_iter(ItemId(item_id()))
.map(|recipe| view! {<Recipe recipe/>})
.take(10)
.take(30)
.collect::<Vec<_>>()
});

view! { <div class="content-well flex-column" class:hidden=move || item_set().is_empty()>
view! { <div class="content-well flex-col flex-wrap p-2" class:hidden=move || item_set().is_empty()>
<span class="content-title">"related items"</span>
<div class="flex-column">{item_set}</div>
<div class="flex-row flex-wrap gap-1">{item_set}</div>
</div>
<div class="content-well flex-column" class:hidden=move || recipes().is_empty()>
<div class="content-well flex-col p-2" class:hidden=move || recipes().is_empty()>
<span class="content-title">"crafting recipes"</span>
<div class="flex-wrap">{recipes}</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions ultros-frontend/ultros-app/src/global_state/cookies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ pub(crate) fn get_cookies() -> Option<CookieJar> {

#[cfg(feature = "ssr")]
pub(crate) fn get_cookies() -> Option<CookieJar> {
use leptos_axum::RequestParts;
let cookies = use_context::<RequestParts>()?;
let cookie = cookies.headers.get("Cookie")?;
use axum::http::request::Parts;
let request_parts = use_context::<Parts>()?;
let cookie = request_parts.headers.get("Cookie")?;
let value = cookie.to_str().ok()?.to_string();
let mut cookie_jar = CookieJar::new();
for cookie in Cookie::split_parse_encoded(value) {
Expand Down
6 changes: 3 additions & 3 deletions ultros-frontend/ultros-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ wasm-bindgen = "0.2"
console_log = "1.0.0"
console_error_panic_hook = "0.1"
leptos_meta = { workspace = true, default-features = false }
gloo-net = "0.4.0"
gloo-net.workspace = true
xiv-gen-db = {path = "../../xiv-gen-db"}
xiv-gen = {path = "../../xiv-gen"}
futures = "0.3"
serde = {version = "1", features = ["derive"]}
serde-wasm-bindgen = "0.5"
serde-wasm-bindgen = "0.6.3"
serde_bytes = "0.11"
serde_json = "1"
anyhow.workspace = true
rexie = "0.4"
rexie = "0.5"

[features]
default = ["hydrate"]
Expand Down
13 changes: 8 additions & 5 deletions ultros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ edition = "2021"
universalis = {path = "../universalis", features = ["websocket"]}
ultros-db = {path = "../ultros-db"}
anyhow = {workspace = true}
axum = {version = "0.6.0", features = ["ws", "headers", "json"]}
axum-extra = {version = "0.7.4", features = ["cookie", "cookie-private"]}
axum.workspace = true
axum-extra.workspace = true
axum-macros = "0.4.1"
cookie = "0.18"
xiv-gen-db = {path = "../xiv-gen-db", features = ["embed"]}
poise = {version = "0.5.6"}
chrono = "0.4.23"
Expand All @@ -31,23 +33,24 @@ thiserror = "1.0.36"
metrics = "0.22.0"
metrics-exporter-prometheus = {version = "0.13.0", default-features = false}
serde_with = "3.0.0"
tower-http = {version = "0.3.5", features = ["full"]}
tower-http = {version = "0.5.1", features = ["full"]}
sha2 = "0.10.6"
base64 = "0.21.0"
smallvec = {version = "1.10.0", features = ["const_generics", "const_new", "union"]}
itertools = "0.11.0"
itertools = "0.12.0"
sitemap-rs = "0.2.0"
ultros-api-types = {path = "../ultros-api-types"}
ultros-xiv-icons = {path = "../ultros-frontend/ultros-xiv-icons"}
leptos = {workspace = true, features = ["ssr"]}
leptos_axum.workspace = true
leptos_router = {workspace = true, features = ["ssr"]}
ultros-app = {path = "../ultros-frontend/ultros-app", features = ["ssr"]}
hyper = "0.14.24"
hyper = "1.1.0"
tokio-stream = {version = "0.1.12", features = ["sync"]}
ultros-charts = {path = "../ultros-frontend/ultros-charts", features = ["image"]}
plotters-svg = {version = "0.3.2", features = ["bitmap_encoder"]}
resvg = "0.33.0"
image.workspace = true
isocountry = "0.3.2"
git-const.workspace = true
http-body-util = "0.1.0"
Loading

0 comments on commit fb1da5a

Please sign in to comment.