From 435ebc04e8e01476bd77c1e34fb7066985de949b Mon Sep 17 00:00:00 2001 From: John Lewis Date: Fri, 16 Feb 2024 21:47:20 -0600 Subject: [PATCH 01/22] credit dad for his "photo deck" idea --- accreditations.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 accreditations.md diff --git a/accreditations.md b/accreditations.md new file mode 100644 index 0000000..657878d --- /dev/null +++ b/accreditations.md @@ -0,0 +1 @@ +- **Blanton Lewis** - for thoughtful design recommendations. From 8145f46a363d83605f7acc9c4eec1dd701914764 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Fri, 16 Feb 2024 21:48:10 -0600 Subject: [PATCH 02/22] make a super basic gallery mockup --- crates/site-app/src/components/gallery.rs | 65 ++++++++++++++++++++--- 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/crates/site-app/src/components/gallery.rs b/crates/site-app/src/components/gallery.rs index 078980b..d39b9b5 100644 --- a/crates/site-app/src/components/gallery.rs +++ b/crates/site-app/src/components/gallery.rs @@ -15,19 +15,68 @@ pub fn Gallery() -> impl IntoView { ); view! { - "Loading..."

}> - { move || photo_groups.map(|groups| view! { -
-          
-            {format!("Photo Groups: {:#?}", groups)}
-          
-        
- })} + + { move || photo_groups.map(|groups| { + match groups { + Ok(groups) => { + view! { + + } + .into_view() + } + Err(e) => { + view! { +

"Failed to load photo groups: {e}"

+ } + .into_view() + } + } + }) }
} .into_view() } +#[component] +fn PhotoGroupList(groups: Vec) -> impl IntoView { + view! { +
+ { groups.into_iter().map(|group| { + view! { + + } + .into_view() + }).collect::>() } +
+ } + .into_view() +} + +#[component] +fn PhotoGroup(group: core_types::PhotoGroup) -> impl IntoView { + view! { +
+
+ { group.photos.into_iter().map(|photo_id| { + view! { + + } + .into_view() + }).collect::>() } +
+
+ } +} + +#[component] +fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { + view! { +
+

{ format!("{photo_id:?}") }

+
+ } +} + #[server] pub async fn get_user_photo_groups( user_id: core_types::UserRecordId, From 3ce3df6639821ecf25667596350fefa9ce1f2e03 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Fri, 16 Feb 2024 21:48:43 -0600 Subject: [PATCH 03/22] add container queries to tailwind --- crates/site-app/style/tailwind/package.json | 1 + crates/site-app/style/tailwind/yarn.lock | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/crates/site-app/style/tailwind/package.json b/crates/site-app/style/tailwind/package.json index f67a454..ea5640d 100644 --- a/crates/site-app/style/tailwind/package.json +++ b/crates/site-app/style/tailwind/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "main": "tailwind.config.js", "dependencies": { + "@tailwindcss/container-queries": "^0.1.1", "daisyui": "^4.6.2", "postcss": "^8.4.35" } diff --git a/crates/site-app/style/tailwind/yarn.lock b/crates/site-app/style/tailwind/yarn.lock index 0e32a79..b32924c 100644 --- a/crates/site-app/style/tailwind/yarn.lock +++ b/crates/site-app/style/tailwind/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@tailwindcss/container-queries@^0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@tailwindcss/container-queries/-/container-queries-0.1.1.tgz#9a759ce2cb8736a4c6a0cb93aeb740573a731974" + integrity sha512-p18dswChx6WnTSaJCSGx6lTmrGzNNvm2FtXmiO6AuA1V4U5REyoqwmT6kgAsIMdjo07QdAfYXHJ4hnMtfHzWgA== + camelcase-css@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/camelcase-css/-/camelcase-css-2.0.1.tgz#ee978f6947914cc30c6b44741b6ed1df7f043fd5" From 844dc635c967965bed39f0326660ea418213c580 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Fri, 16 Feb 2024 21:52:43 -0600 Subject: [PATCH 04/22] update yarn hash in flake --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 15ea5d3..031c6f5 100644 --- a/flake.nix +++ b/flake.nix @@ -87,7 +87,7 @@ # an offline yarn registry for the tailwind packages style-js-packages-yarn-registry = pkgs.fetchYarnDeps { yarnLock = ./crates/site-app/style/tailwind/yarn.lock; - hash = "sha256-nqOJBcjX+dFl/XkBH+HfRO6Ce+CErm3YkQjG1W+aUPw="; + hash = "sha256-uYcqauHqsk58oWtA2uUYsJ2OuW8o2Rh6KrW88fK9UfE="; # hash = ""; }; From add111cd38075ea25c40ec458fd58930969c82d9 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 13:07:17 -0600 Subject: [PATCH 05/22] feat: impl Copy on `core_types` record IDs --- crates/core_types/src/artifact.rs | 4 ++-- crates/core_types/src/auth.rs | 2 +- crates/core_types/src/photo.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/core_types/src/artifact.rs b/crates/core_types/src/artifact.rs index 397468b..3824d0d 100644 --- a/crates/core_types/src/artifact.rs +++ b/crates/core_types/src/artifact.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; pub const PRIVATE_ARTIFACT_TABLE: &str = "private_artifact"; pub const PUBLIC_ARTIFACT_TABLE: &str = "public_artifact"; -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, Copy)] #[cfg_attr(feature = "ssr", serde(from = "crate::conv::UlidOrThing"))] pub struct PrivateArtifactRecordId(pub ulid::Ulid); @@ -14,7 +14,7 @@ pub struct PrivateArtifact { pub contents: Option, } -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, Copy)] #[cfg_attr(feature = "ssr", serde(from = "crate::conv::UlidOrThing"))] pub struct PublicArtifactRecordId(pub ulid::Ulid); diff --git a/crates/core_types/src/auth.rs b/crates/core_types/src/auth.rs index 8c55e9f..ee73cc0 100644 --- a/crates/core_types/src/auth.rs +++ b/crates/core_types/src/auth.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize}; pub const USER_TABLE: &str = "user"; -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone, Copy)] #[cfg_attr(feature = "ssr", serde(from = "crate::conv::UlidOrThing"))] pub struct UserRecordId(pub ulid::Ulid); diff --git a/crates/core_types/src/photo.rs b/crates/core_types/src/photo.rs index 18f6dad..5278e8c 100644 --- a/crates/core_types/src/photo.rs +++ b/crates/core_types/src/photo.rs @@ -8,7 +8,7 @@ use crate::{ auth::UserRecordId, }; -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, Copy)] #[cfg_attr(feature = "ssr", serde(from = "crate::conv::UlidOrThing"))] pub struct PhotoRecordId(pub ulid::Ulid); @@ -26,7 +26,7 @@ pub struct PhotoArtifacts { pub thumbnail: PublicArtifact, } -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, Copy)] #[cfg_attr(feature = "ssr", serde(from = "crate::conv::UlidOrThing"))] pub struct PhotoGroupRecordId(pub ulid::Ulid); From 427e2e58e6ca5b6a1a73230e1c5bb80d0a731bf9 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 13:07:53 -0600 Subject: [PATCH 06/22] feat: impl IntoResource on `core_types` IDs --- crates/core_types/src/conv.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/core_types/src/conv.rs b/crates/core_types/src/conv.rs index cf6ff86..38b0e18 100644 --- a/crates/core_types/src/conv.rs +++ b/crates/core_types/src/conv.rs @@ -1,6 +1,9 @@ use serde::Deserialize; use surreal_id::NewId; -use surrealdb::sql::{Id, Thing}; +use surrealdb::{ + opt::{IntoResource, Resource}, + sql::{Id, Thing}, +}; use crate::{ PhotoGroupRecordId, PhotoRecordId, PrivateArtifactRecordId, @@ -64,3 +67,19 @@ impl AsThing for T { } } } + +macro_rules! impl_into_resource { + ($type:ty) => { + impl IntoResource> for $type { + fn into_resource(self) -> Result { + Ok(Resource::RecordId(self.as_thing())) + } + } + }; +} + +impl_into_resource!(UserRecordId); +impl_into_resource!(PhotoRecordId); +impl_into_resource!(PhotoGroupRecordId); +impl_into_resource!(PrivateArtifactRecordId); +impl_into_resource!(PublicArtifactRecordId); From dbd92efe23ef585dabf832b343a8bd2f1f9a4573 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 13:08:35 -0600 Subject: [PATCH 07/22] feat: add `clients` crate to `site-app` under `ssr` --- Cargo.lock | 1 + crates/site-app/Cargo.toml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 23f7dd6..48b7b03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4157,6 +4157,7 @@ dependencies = [ "bl", "bytes", "cfg-if", + "clients", "core_types", "http 1.0.0", "leptos", diff --git a/crates/site-app/Cargo.toml b/crates/site-app/Cargo.toml index d3308a3..e51c201 100644 --- a/crates/site-app/Cargo.toml +++ b/crates/site-app/Cargo.toml @@ -25,6 +25,7 @@ core_types = { path = "../core_types" } validation = { path = "../validation" } auth = { path = "../auth", optional = true } +clients = { path = "../clients", optional = true } bl = { path = "../bl", optional = true } [features] @@ -32,6 +33,6 @@ default = [] hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"] ssr = [ "leptos/ssr", "leptos_meta/ssr", "leptos_router/ssr", "dep:leptos_axum", - "auth", "bl", "bytes" + "auth", "bl", "bytes", "clients" ] From f8d0cf1a1b71f7ef84b3975624b737b86d4c4db4 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 13:14:19 -0600 Subject: [PATCH 08/22] feat: photos naively displayed --- crates/site-app/src/components/gallery.rs | 17 ++---- crates/site-app/src/components/mod.rs | 1 + crates/site-app/src/components/photo.rs | 72 +++++++++++++++++++++++ 3 files changed, 77 insertions(+), 13 deletions(-) create mode 100644 crates/site-app/src/components/photo.rs diff --git a/crates/site-app/src/components/gallery.rs b/crates/site-app/src/components/gallery.rs index d39b9b5..fac3d20 100644 --- a/crates/site-app/src/components/gallery.rs +++ b/crates/site-app/src/components/gallery.rs @@ -11,7 +11,7 @@ pub fn Gallery() -> impl IntoView { let photo_groups = create_resource( move || (), - move |_| get_user_photo_groups(user.id.clone()), + move |_| fetch_user_photo_groups(user.id.clone()), ); view! { @@ -40,7 +40,7 @@ pub fn Gallery() -> impl IntoView { #[component] fn PhotoGroupList(groups: Vec) -> impl IntoView { view! { -
+
{ groups.into_iter().map(|group| { view! { @@ -59,7 +59,7 @@ fn PhotoGroup(group: core_types::PhotoGroup) -> impl IntoView {
{ group.photos.into_iter().map(|photo_id| { view! { - + } .into_view() }).collect::>() } @@ -68,17 +68,8 @@ fn PhotoGroup(group: core_types::PhotoGroup) -> impl IntoView { } } -#[component] -fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { - view! { -
-

{ format!("{photo_id:?}") }

-
- } -} - #[server] -pub async fn get_user_photo_groups( +pub async fn fetch_user_photo_groups( user_id: core_types::UserRecordId, ) -> Result, ServerFnError> { bl::get_user_photo_groups(user_id).await.map_err(|e| { diff --git a/crates/site-app/src/components/mod.rs b/crates/site-app/src/components/mod.rs index 98283d2..8d1768d 100644 --- a/crates/site-app/src/components/mod.rs +++ b/crates/site-app/src/components/mod.rs @@ -1,4 +1,5 @@ pub mod form; pub mod gallery; pub mod navigation; +pub mod photo; pub mod photo_upload; diff --git a/crates/site-app/src/components/photo.rs b/crates/site-app/src/components/photo.rs new file mode 100644 index 0000000..2ae1790 --- /dev/null +++ b/crates/site-app/src/components/photo.rs @@ -0,0 +1,72 @@ +use leptos::*; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct PhotoDisplayParams { + url: String, + alt: String, + size: (u32, u32), +} + +#[component] +pub fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { + let photo = create_resource(move || (), move |_| fetch_photo(photo_id)); + + view! { +
+ + { move || match photo() { + Some(Ok(photo)) => { + Some(view! { + {photo.alt} + } + .into_view()) + } + Some(Err(e)) => { + Some(view! { +

"Failed to load photo: {e}"

+ } + .into_view()) + } + None => None, + } } +
+
+ } +} + +#[server] +pub async fn fetch_photo( + photo_id: core_types::PhotoRecordId, +) -> Result { + use core_types::NewId; + + let surreal_client = clients::surreal::SurrealRootClient::new() + .await + .map_err(|e| { + ServerFnError::new(format!("Failed to create surreal client: {e:?}")) + })?; + + (*surreal_client) + .use_ns("main") + .use_db("main") + .await + .map_err(|e| { + ServerFnError::new(format!("Failed to use namespace/db: {e:?}")) + })?; + + let photo: Option = + (*surreal_client).select(photo_id).await.map_err(|e| { + ServerFnError::new(format!("Failed to select photo: {e:?}")) + })?; + + let photo = photo.ok_or_else(|| { + ServerFnError::new(format!("Photo not found: {photo_id:?}")) + })?; + + Ok(PhotoDisplayParams { + url: photo.artifacts.thumbnail.url, + alt: "Photo".to_string(), + size: (0, 0), + }) +} From 07e1bf1d79fa5b5b69d87813e53f6d02f95ec291 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 13:18:56 -0600 Subject: [PATCH 09/22] feat: refactor photo artifacts --- crates/core_types/src/photo.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/core_types/src/photo.rs b/crates/core_types/src/photo.rs index 5278e8c..7f1f3d8 100644 --- a/crates/core_types/src/photo.rs +++ b/crates/core_types/src/photo.rs @@ -4,8 +4,7 @@ pub const PHOTO_TABLE: &str = "photo"; pub const PHOTO_GROUP_TABLE: &str = "photo_group"; use crate::{ - artifact::{PrivateArtifact, PublicArtifact}, - auth::UserRecordId, + auth::UserRecordId, PrivateArtifactRecordId, PublicArtifactRecordId, }; #[derive(Clone, Debug, Deserialize, Serialize, Copy)] @@ -22,8 +21,20 @@ pub struct Photo { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct PhotoArtifacts { - pub original: PrivateArtifact, - pub thumbnail: PublicArtifact, + pub original: PrivateImageArtifact, + pub thumbnail: PublicImageArtifact, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct PublicImageArtifact { + pub artifact_id: PublicArtifactRecordId, + pub size: (u32, u32), +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct PrivateImageArtifact { + pub artifact_id: PrivateArtifactRecordId, + pub size: (u32, u32), } #[derive(Clone, Debug, Deserialize, Serialize, Copy)] From f1b62373d791f786ea7abc485945e7ebf81fc10b Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 13:27:36 -0600 Subject: [PATCH 10/22] fix: compiles after refactoring photo artifacts --- crates/bl/src/lib.rs | 10 ++++++++-- crates/site-app/src/components/photo.rs | 25 +++++++++++++++++++------ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/crates/bl/src/lib.rs b/crates/bl/src/lib.rs index d6d094d..6729ab7 100644 --- a/crates/bl/src/lib.rs +++ b/crates/bl/src/lib.rs @@ -71,8 +71,14 @@ pub async fn upload_single_photo( photographer: user_id.clone(), owner: user_id.clone(), artifacts: PhotoArtifacts { - original: original_artifact, - thumbnail: thumbnail_artifact, + original: core_types::PrivateImageArtifact { + artifact_id: original_artifact.id, + size: (original_image.width(), original_image.height()), + }, + thumbnail: core_types::PublicImageArtifact { + artifact_id: thumbnail_artifact.id, + size: (thumbnail_image.width(), thumbnail_image.height()), + }, }, }; diff --git a/crates/site-app/src/components/photo.rs b/crates/site-app/src/components/photo.rs index 2ae1790..5bc7e27 100644 --- a/crates/site-app/src/components/photo.rs +++ b/crates/site-app/src/components/photo.rs @@ -10,7 +10,8 @@ pub struct PhotoDisplayParams { #[component] pub fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { - let photo = create_resource(move || (), move |_| fetch_photo(photo_id)); + let photo = + create_resource(move || (), move |_| fetch_photo_thumbnail(photo_id)); view! {
@@ -36,11 +37,9 @@ pub fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { } #[server] -pub async fn fetch_photo( +pub async fn fetch_photo_thumbnail( photo_id: core_types::PhotoRecordId, ) -> Result { - use core_types::NewId; - let surreal_client = clients::surreal::SurrealRootClient::new() .await .map_err(|e| { @@ -64,9 +63,23 @@ pub async fn fetch_photo( ServerFnError::new(format!("Photo not found: {photo_id:?}")) })?; + let thumbnail_artifact: Option = + (*surreal_client) + .select(photo.artifacts.thumbnail.artifact_id) + .await + .map_err(|e| { + ServerFnError::new(format!( + "Failed to select thumbnail artifact: {e:?}" + )) + })?; + + let thumbnail_artifact = thumbnail_artifact.ok_or_else(|| { + ServerFnError::new("Thumbnail artifact not found".to_string()) + })?; + Ok(PhotoDisplayParams { - url: photo.artifacts.thumbnail.url, + url: thumbnail_artifact.url, alt: "Photo".to_string(), - size: (0, 0), + size: photo.artifacts.thumbnail.size, }) } From 627460fbd99388fa1ec2bcc9cf84f54bb416ad49 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 13:27:55 -0600 Subject: [PATCH 11/22] fix: fixed error formatting in photo component --- crates/site-app/src/components/photo.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/site-app/src/components/photo.rs b/crates/site-app/src/components/photo.rs index 5bc7e27..37c136c 100644 --- a/crates/site-app/src/components/photo.rs +++ b/crates/site-app/src/components/photo.rs @@ -25,7 +25,7 @@ pub fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { } Some(Err(e)) => { Some(view! { -

"Failed to load photo: {e}"

+

{ format!("Failed to load photo: {e}") }

} .into_view()) } From cf481b39e200e2b28774c94b8c4f309358aed13c Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 13:28:05 -0600 Subject: [PATCH 12/22] fix: remove old debug printing --- crates/core_types/src/conv.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/core_types/src/conv.rs b/crates/core_types/src/conv.rs index 38b0e18..ec88aba 100644 --- a/crates/core_types/src/conv.rs +++ b/crates/core_types/src/conv.rs @@ -60,7 +60,6 @@ pub trait AsThing { impl AsThing for T { fn as_thing(&self) -> Thing { - println!("converting to thing: {:?}", self.get_inner_string()); Thing { tb: T::TABLE.to_string(), id: Id::String(self.get_inner_string()), From 83fb6881e96f62b5640b31baeabb3a70fdae3fcf Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 13:30:04 -0600 Subject: [PATCH 13/22] fix: added protocol to public artifact urls --- crates/artifact/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/artifact/src/lib.rs b/crates/artifact/src/lib.rs index 4661586..99b5627 100644 --- a/crates/artifact/src/lib.rs +++ b/crates/artifact/src/lib.rs @@ -36,7 +36,7 @@ impl Artifact for PublicArtifact { id: id.clone(), contents, url: format!( - "s3.{}.amazonaws.com/{}/{}", + "https://s3.{}.amazonaws.com/{}/{}", std::env::var("AWS_DEFAULT_REGION").unwrap(), ARTIFACT_PUBLIC_LTS_BUCKET, id.0 From 0b639392577db201d53b9eae59cc43d0a731121f Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 14:12:17 -0600 Subject: [PATCH 14/22] feat: ship thumbnail as base64 --- Cargo.lock | 147 ++++++++++++++++++++++++ Cargo.toml | 5 +- crates/bl/Cargo.toml | 2 +- crates/site-app/Cargo.toml | 5 +- crates/site-app/src/components/photo.rs | 41 +++++-- 5 files changed, 190 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 48b7b03..a0f592c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1274,6 +1274,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -1382,6 +1392,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1967,6 +1992,19 @@ dependencies = [ "tokio-rustls", ] +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper 0.14.28", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "hyper-util" version = "0.1.3" @@ -2524,6 +2562,12 @@ dependencies = [ "serde_test", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + [[package]] name = "lock_api" version = "0.4.11" @@ -2706,6 +2750,24 @@ dependencies = [ "getrandom", ] +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" @@ -2879,12 +2941,50 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +dependencies = [ + "bitflags 2.4.2", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "owo-colors" version = "3.5.0" @@ -3455,11 +3555,13 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.28", "hyper-rustls", + "hyper-tls", "ipnet", "js-sys", "log", "mime", "mime_guess", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -3472,6 +3574,7 @@ dependencies = [ "sync_wrapper", "system-configuration", "tokio", + "tokio-native-tls", "tokio-rustls", "tokio-util", "tower-service", @@ -3720,6 +3823,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustls" version = "0.21.7" @@ -4154,16 +4270,19 @@ name = "site-app" version = "0.1.0" dependencies = [ "auth", + "base64", "bl", "bytes", "cfg-if", "clients", "core_types", "http 1.0.0", + "image", "leptos", "leptos_axum", "leptos_meta", "leptos_router", + "reqwest", "serde", "server_fn", "thiserror", @@ -4547,6 +4666,18 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tempfile" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "term" version = "0.7.0" @@ -4686,6 +4817,16 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.24.1" @@ -5202,6 +5343,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index 57ba758..93e7d3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,18 +13,21 @@ codegen-units = 1 [workspace.dependencies] axum = { version = "0.7.4", features = ["macros"] } axum-login = "0.13" +base64 = { version = "0.21" } bytes = "1.5.0" cfg-if = "1" color-eyre = "0.6" console_error_panic_hook = "0.1.7" console_log = "1" http = "1" +image = "0.24" leptos = { version = "0.6", features = ["nightly", "experimental-islands"] } leptos_axum = { version = "0.6", features = ["experimental-islands"] } leptos_meta = { version = "0.6", features = ["nightly"] } leptos_router = { version = "0.6", features = ["nightly"] } -server_fn = { version = "0.6", features = ["multipart"] } log = "0.4" +reqwest = { version = "0.11" } +server_fn = { version = "0.6", features = ["multipart"] } serde = { version = "1", features = ["derive"] } simple_logger = "4.2.0" surrealdb = { version = "1" } diff --git a/crates/bl/Cargo.toml b/crates/bl/Cargo.toml index 3e4b71f..ca5d6b1 100644 --- a/crates/bl/Cargo.toml +++ b/crates/bl/Cargo.toml @@ -12,9 +12,9 @@ artifact = { path = "../artifact" } bytes.workspace = true color-eyre.workspace = true +image.workspace = true thiserror.workspace = true surrealdb.workspace = true serde.workspace = true ulid.workspace = true -image = "0.24.8" diff --git a/crates/site-app/Cargo.toml b/crates/site-app/Cargo.toml index e51c201..5d5f8a1 100644 --- a/crates/site-app/Cargo.toml +++ b/crates/site-app/Cargo.toml @@ -17,6 +17,9 @@ cfg-if.workspace = true thiserror.workspace = true serde.workspace = true bytes = { workspace = true, optional = true } +base64 = { workspace = true, optional = true } +image = { workspace = true, optional = true } +reqwest = { workspace = true, optional = true } validator = "0.16.1" web-sys = { version = "0.3", features = [ "Window", "EventTarget" ] } @@ -33,6 +36,6 @@ default = [] hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"] ssr = [ "leptos/ssr", "leptos_meta/ssr", "leptos_router/ssr", "dep:leptos_axum", - "auth", "bl", "bytes", "clients" + "auth", "base64", "bl", "bytes", "clients", "image", "reqwest" ] diff --git a/crates/site-app/src/components/photo.rs b/crates/site-app/src/components/photo.rs index 37c136c..4503544 100644 --- a/crates/site-app/src/components/photo.rs +++ b/crates/site-app/src/components/photo.rs @@ -2,8 +2,8 @@ use leptos::*; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] -pub struct PhotoDisplayParams { - url: String, +pub struct PhotoThumbnailDisplayParams { + data: String, alt: String, size: (u32, u32), } @@ -19,7 +19,9 @@ pub fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { { move || match photo() { Some(Ok(photo)) => { Some(view! { - {photo.alt} + {photo.alt} } .into_view()) } @@ -39,7 +41,7 @@ pub fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { #[server] pub async fn fetch_photo_thumbnail( photo_id: core_types::PhotoRecordId, -) -> Result { +) -> Result { let surreal_client = clients::surreal::SurrealRootClient::new() .await .map_err(|e| { @@ -77,9 +79,34 @@ pub async fn fetch_photo_thumbnail( ServerFnError::new("Thumbnail artifact not found".to_string()) })?; - Ok(PhotoDisplayParams { - url: thumbnail_artifact.url, - alt: "Photo".to_string(), + // fetch the artifact using the url + let thumbnail_image = reqwest::get(thumbnail_artifact.url) + .await + .map_err(|e| { + ServerFnError::new(format!("Failed to fetch thumbnail: {e:?}")) + })? + .bytes() + .await + .map_err(|e| { + ServerFnError::new(format!("Failed to fetch thumbnail: {e:?}")) + })?; + + let thumbnail_image = + image::load_from_memory(&thumbnail_image).map_err(|e| { + ServerFnError::new(format!("Failed to load thumbnail as image: {e:?}")) + })?; + let mut buffer = Vec::new(); + let mut encoder = + image::codecs::jpeg::JpegEncoder::new_with_quality(&mut buffer, 95); + encoder.encode_image(&thumbnail_image).map_err(|e| { + ServerFnError::new(format!("Failed to encode thumbnail: {e:?}")) + })?; + + let data = format!("data:image/jpeg;base64,{}", base64::encode(&buffer)); + + Ok(PhotoThumbnailDisplayParams { + data, + alt: "Thumbnail".to_string(), size: photo.artifacts.thumbnail.size, }) } From 33a07abff53620139a8726130e879106b7920b00 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 14:13:52 -0600 Subject: [PATCH 15/22] fix: better commenting in photo fetcher --- crates/site-app/src/components/photo.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/site-app/src/components/photo.rs b/crates/site-app/src/components/photo.rs index 4503544..2de4061 100644 --- a/crates/site-app/src/components/photo.rs +++ b/crates/site-app/src/components/photo.rs @@ -42,12 +42,12 @@ pub fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { pub async fn fetch_photo_thumbnail( photo_id: core_types::PhotoRecordId, ) -> Result { + // prep the surreal client let surreal_client = clients::surreal::SurrealRootClient::new() .await .map_err(|e| { ServerFnError::new(format!("Failed to create surreal client: {e:?}")) })?; - (*surreal_client) .use_ns("main") .use_db("main") @@ -56,15 +56,16 @@ pub async fn fetch_photo_thumbnail( ServerFnError::new(format!("Failed to use namespace/db: {e:?}")) })?; + // select the photo let photo: Option = (*surreal_client).select(photo_id).await.map_err(|e| { ServerFnError::new(format!("Failed to select photo: {e:?}")) })?; - let photo = photo.ok_or_else(|| { ServerFnError::new(format!("Photo not found: {photo_id:?}")) })?; + // select the thumbnail artifact let thumbnail_artifact: Option = (*surreal_client) .select(photo.artifacts.thumbnail.artifact_id) @@ -74,7 +75,6 @@ pub async fn fetch_photo_thumbnail( "Failed to select thumbnail artifact: {e:?}" )) })?; - let thumbnail_artifact = thumbnail_artifact.ok_or_else(|| { ServerFnError::new("Thumbnail artifact not found".to_string()) })?; @@ -91,10 +91,13 @@ pub async fn fetch_photo_thumbnail( ServerFnError::new(format!("Failed to fetch thumbnail: {e:?}")) })?; + // load using the image crate let thumbnail_image = image::load_from_memory(&thumbnail_image).map_err(|e| { ServerFnError::new(format!("Failed to load thumbnail as image: {e:?}")) })?; + + // encode to jpeg bytes let mut buffer = Vec::new(); let mut encoder = image::codecs::jpeg::JpegEncoder::new_with_quality(&mut buffer, 95); @@ -102,6 +105,7 @@ pub async fn fetch_photo_thumbnail( ServerFnError::new(format!("Failed to encode thumbnail: {e:?}")) })?; + // encode to base64 let data = format!("data:image/jpeg;base64,{}", base64::encode(&buffer)); Ok(PhotoThumbnailDisplayParams { From 0564726817e26194d6f8d73eef8c31e952ff41c9 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 14:28:39 -0600 Subject: [PATCH 16/22] fix: properly encode thumbnail in `bl` --- crates/bl/src/lib.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/bl/src/lib.rs b/crates/bl/src/lib.rs index 6729ab7..e6487bc 100644 --- a/crates/bl/src/lib.rs +++ b/crates/bl/src/lib.rs @@ -6,6 +6,7 @@ use core_types::{ AsThing, NewId, Photo, PhotoArtifacts, PhotoGroup, PhotoGroupUploadMeta, PrivateArtifact, PublicArtifact, }; +use image::ImageEncoder; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize, thiserror::Error)] @@ -47,7 +48,7 @@ pub async fn upload_single_photo( )) })?; - // create a thumbnail and upload it as an artifact + // create a thumbnail image let aspect_ratio = original_image.width() as f32 / original_image.height() as f32; let thumbnail_size = thumbnail_size(aspect_ratio); @@ -57,7 +58,17 @@ pub async fn upload_single_photo( thumbnail_size.1, image::imageops::FilterType::Lanczos3, ); - let thumbnail_bytes: Bytes = thumbnail_image.as_bytes().to_vec().into(); + + // encode as png to bytes + let mut thumbnail_bytes = Vec::new(); + let encoder = image::codecs::png::PngEncoder::new(&mut thumbnail_bytes); + thumbnail_image.write_with_encoder(encoder).map_err(|e| { + PhotoUploadError::InvalidImage(format!( + "Failed to encode thumbnail image: {e:?}" + )) + })?; + + let thumbnail_bytes: Bytes = thumbnail_bytes.into(); let thumbnail_artifact = PublicArtifact::new(Some(thumbnail_bytes)); thumbnail_artifact.upload_and_push().await.map_err(|e| { PhotoUploadError::ArtifactCreationError(format!( From fd97b25d6b0597d0810ef889b008917daa6f6068 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 14:29:07 -0600 Subject: [PATCH 17/22] fix: remove redundant `data:` header --- crates/site-app/src/components/photo.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/site-app/src/components/photo.rs b/crates/site-app/src/components/photo.rs index 2de4061..3e545bd 100644 --- a/crates/site-app/src/components/photo.rs +++ b/crates/site-app/src/components/photo.rs @@ -106,7 +106,7 @@ pub async fn fetch_photo_thumbnail( })?; // encode to base64 - let data = format!("data:image/jpeg;base64,{}", base64::encode(&buffer)); + let data = base64::encode(&buffer); Ok(PhotoThumbnailDisplayParams { data, From f7d711640c713420f0b6916dc81965080788d997 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 14:32:43 -0600 Subject: [PATCH 18/22] fix: properly encode with `base64` --- crates/site-app/src/components/photo.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/site-app/src/components/photo.rs b/crates/site-app/src/components/photo.rs index 3e545bd..64aac4b 100644 --- a/crates/site-app/src/components/photo.rs +++ b/crates/site-app/src/components/photo.rs @@ -42,6 +42,8 @@ pub fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { pub async fn fetch_photo_thumbnail( photo_id: core_types::PhotoRecordId, ) -> Result { + use base64::prelude::*; + // prep the surreal client let surreal_client = clients::surreal::SurrealRootClient::new() .await @@ -106,7 +108,7 @@ pub async fn fetch_photo_thumbnail( })?; // encode to base64 - let data = base64::encode(&buffer); + let data = BASE64_STANDARD.encode(&buffer); Ok(PhotoThumbnailDisplayParams { data, From ed10a7053ae9bca95aaa363da45e91d49689e9b7 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 14:40:53 -0600 Subject: [PATCH 19/22] feat: switch to avif for b64 thumbnails --- Cargo.lock | 452 +++++++++++++++++++++++- Cargo.toml | 2 +- crates/site-app/src/components/photo.rs | 9 +- 3 files changed, 454 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a0f592c..1024208 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -115,6 +115,29 @@ dependencies = [ "num-traits", ] +[[package]] +name = "arbitrary" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db55d72333851e17d572bec876e390cd3b11eb1ef53ae821dd9f3b653d2b4569" + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "argon2" version = "0.5.3" @@ -132,6 +155,9 @@ name = "arrayvec" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +dependencies = [ + "serde", +] [[package]] name = "artifact" @@ -314,6 +340,30 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "av1-grain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6678909d8c5d46a42abcf571271e15fdbc0a225e3646cf23762cd415046c78bf" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom", + "num-rational", + "serde", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876c75a42f6364451a033496a14c44bffe41f5f4a8236f697391f11024e596d2" +dependencies = [ + "arrayvec", +] + [[package]] name = "axum" version = "0.7.4" @@ -485,6 +535,18 @@ version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +[[package]] +name = "bitstream-io" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e445576659fd04a57b44cbd00aa37aaa815ebefa0aa3cb677a6b5e63d883074f" + +[[package]] +name = "bitstream-io" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c9989a51171e2e81038ab168b6ae22886fe9ded214430dbb4f41c28cf176da" + [[package]] name = "bitvec" version = "1.0.1" @@ -586,6 +648,21 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "built" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9c056b9ed43aee5e064b683aa1ec783e19c6acec7559e3ae931b7490472fbe" +dependencies = [ + "cargo-lock", +] + +[[package]] +name = "built" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d17f4d6e4dc36d1a02fbedc2753a096848e7c1b0772f7654eab8e2c927dd53" + [[package]] name = "bumpalo" version = "3.14.0" @@ -671,6 +748,18 @@ version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +[[package]] +name = "cargo-lock" +version = "8.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031718ddb8f78aa5def78a09e90defe30151d1f6c672f937af4dd916429ed996" +dependencies = [ + "semver", + "serde", + "toml 0.5.11", + "url", +] + [[package]] name = "cc" version = "1.0.83" @@ -738,6 +827,16 @@ dependencies = [ "unicode-security", ] +[[package]] +name = "cfg-expr" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa50868b64a9a6fda9d593ce778849ea8715cd2a3d2cc17ffdb4a2f2f2f1961d" +dependencies = [ + "smallvec", + "target-lexicon", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -879,7 +978,7 @@ dependencies = [ "nom", "pathdiff", "serde", - "toml", + "toml 0.5.11", ] [[package]] @@ -2091,9 +2190,17 @@ dependencies = [ "num-traits", "png", "qoi", + "ravif", + "rgb", "tiff", ] +[[package]] +name = "imgref" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44feda355f4159a7c757171a77de25daf6411e217b4cabd03bd6650690468126" + [[package]] name = "indenter" version = "0.3.3" @@ -2140,6 +2247,17 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "interpolator" version = "0.5.0" @@ -2535,6 +2653,27 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libfuzzer-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf184a4b6b274f82a5df6b357da6055d3e82272327bba281c28bbba6f1664ef" +dependencies = [ + "arbitrary 0.4.7", + "cc", +] + +[[package]] +name = "libfuzzer-sys" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a96cfd5557eb82f2b83fed4955246c988d331975a002961b07c81584d107e7f7" +dependencies = [ + "arbitrary 1.3.2", + "cc", + "once_cell", +] + [[package]] name = "libm" version = "0.2.8" @@ -2585,6 +2724,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + [[package]] name = "lru" version = "0.11.1" @@ -2632,6 +2780,16 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + [[package]] name = "md-5" version = "0.10.6" @@ -2750,6 +2908,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "nasm-rs" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4d98d0065f4b1daf164b3eafb11974c94662e5e2396cf03f32d0bb5c17da51" +dependencies = [ + "rayon", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -2793,6 +2960,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + [[package]] name = "num-bigint" version = "0.4.4" @@ -2827,6 +3000,28 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-derive" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "num-integer" version = "0.1.46" @@ -2847,6 +3042,18 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.18" @@ -3233,7 +3440,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit", + "toml_edit 0.21.1", ] [[package]] @@ -3293,6 +3500,25 @@ dependencies = [ "yansi", ] +[[package]] +name = "profiling" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135ede8821cf6376eb7a64148901e1690b788c11ae94dc297ae917dbc91dc0e" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" +dependencies = [ + "quote", + "syn 2.0.48", +] + [[package]] name = "psl-types" version = "2.0.11" @@ -3337,6 +3563,12 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quick-xml" version = "0.31.0" @@ -3426,6 +3658,96 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rav1e" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16c383692a5e7abd9f6d1eddb1a5e0269f859392387883361bb09e5555852ec1" +dependencies = [ + "arbitrary 0.4.7", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io 1.10.0", + "built 0.5.2", + "cc", + "cfg-if", + "interpolate_name", + "itertools 0.10.5", + "libc", + "libfuzzer-sys 0.3.5", + "log", + "maybe-rayon", + "nasm-rs", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive 0.3.3", + "num-traits", + "once_cell", + "paste", + "rand", + "rand_chacha", + "rust_hawktracer", + "rustc_version", + "simd_helpers", + "system-deps", + "thiserror", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "rav1e" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +dependencies = [ + "arbitrary 1.3.2", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io 2.2.0", + "built 0.7.1", + "cc", + "cfg-if", + "interpolate_name", + "itertools 0.12.1", + "libc", + "libfuzzer-sys 0.4.7", + "log", + "maybe-rayon", + "nasm-rs", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive 0.4.1", + "num-traits", + "once_cell", + "paste", + "profiling", + "rand", + "rand_chacha", + "simd_helpers", + "system-deps", + "thiserror", + "v_frame", +] + +[[package]] +name = "ravif" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d44feba0b8a381a5efa2c0baf8dace8418904403260233f4a614503b018fc288" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e 0.6.6", + "rav1e 0.7.1", + "rayon", + "rgb", +] + [[package]] name = "rayon" version = "1.8.1" @@ -3624,6 +3946,15 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "rgb" +version = "0.8.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" +dependencies = [ + "bytemuck", +] + [[package]] name = "ring" version = "0.16.20" @@ -3793,6 +4124,28 @@ dependencies = [ "serde_json", ] +[[package]] +name = "rust_hawktracer" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3480a29b927f66c6e06527be7f49ef4d291a01d694ec1fe85b0de71d6b02ac1" +dependencies = [ + "rust_hawktracer_normal_macro", + "rust_hawktracer_proc_macro", +] + +[[package]] +name = "rust_hawktracer_normal_macro" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a570059949e1dcdc6f35228fa389f54c2c84dfe0c94c05022baacd56eacd2e9" + +[[package]] +name = "rust_hawktracer_proc_macro" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb626abdbed5e93f031baae60d72032f56bc964e11ac2ff65f2ba3ed98d6d3e1" + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -4063,6 +4416,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_test" version = "1.0.176" @@ -4229,6 +4591,15 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + [[package]] name = "simdutf8" version = "0.1.4" @@ -4660,12 +5031,31 @@ dependencies = [ "libc", ] +[[package]] +name = "system-deps" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2d580ff6a20c55dfb86be5f9c238f67835d0e81cbdea8bf5680e0897320331" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml 0.8.10", + "version-compare", +] + [[package]] name = "tap" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "target-lexicon" +version = "0.12.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" + [[package]] name = "tempfile" version = "3.10.0" @@ -4877,11 +5267,26 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.6", +] + [[package]] name = "toml_datetime" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -4891,7 +5296,20 @@ checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.3", "toml_datetime", - "winnow", + "winnow 0.5.39", +] + +[[package]] +name = "toml_edit" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +dependencies = [ + "indexmap 2.2.3", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.1", ] [[package]] @@ -5287,6 +5705,19 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "v_frame" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c372e4e6fad129795fb86fda6021b258948560b39883b80ed00510a7d19846b0" +dependencies = [ + "cfg-if", + "noop_proc_macro", + "num-derive 0.4.1", + "num-traits", + "profiling", +] + [[package]] name = "validation" version = "0.1.0" @@ -5349,6 +5780,12 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version-compare" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" + [[package]] name = "version_check" version = "0.9.4" @@ -5685,6 +6122,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d90f4e0f530c4c69f62b80d839e9ef3855edc9cba471a160c4d692deed62b401" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" diff --git a/Cargo.toml b/Cargo.toml index 93e7d3c..0b64baa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ color-eyre = "0.6" console_error_panic_hook = "0.1.7" console_log = "1" http = "1" -image = "0.24" +image = { version = "0.24", features = [ "avif-encoder" ] } leptos = { version = "0.6", features = ["nightly", "experimental-islands"] } leptos_axum = { version = "0.6", features = ["experimental-islands"] } leptos_meta = { version = "0.6", features = ["nightly"] } diff --git a/crates/site-app/src/components/photo.rs b/crates/site-app/src/components/photo.rs index 64aac4b..e993099 100644 --- a/crates/site-app/src/components/photo.rs +++ b/crates/site-app/src/components/photo.rs @@ -99,15 +99,14 @@ pub async fn fetch_photo_thumbnail( ServerFnError::new(format!("Failed to load thumbnail as image: {e:?}")) })?; - // encode to jpeg bytes + // encode to avif bytes let mut buffer = Vec::new(); - let mut encoder = - image::codecs::jpeg::JpegEncoder::new_with_quality(&mut buffer, 95); - encoder.encode_image(&thumbnail_image).map_err(|e| { + let encoder = image::codecs::avif::AvifEncoder::new(&mut buffer); + thumbnail_image.write_with_encoder(encoder).map_err(|e| { ServerFnError::new(format!("Failed to encode thumbnail: {e:?}")) })?; - // encode to base64 + // encode avif bytes to base64 let data = BASE64_STANDARD.encode(&buffer); Ok(PhotoThumbnailDisplayParams { From 66704de45ab2a834f0cbd06b3fbd55560439afc3 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 15:05:53 -0600 Subject: [PATCH 20/22] fix: use dedicated API to fetch artifact instead of reqwest --- Cargo.lock | 146 +----------------------- Cargo.toml | 1 - crates/site-app/Cargo.toml | 4 +- crates/site-app/src/components/photo.rs | 30 ++--- 4 files changed, 19 insertions(+), 162 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1024208..1e6e976 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1373,16 +1373,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "event-listener" version = "2.5.3" @@ -1491,21 +1481,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.1" @@ -2091,19 +2066,6 @@ dependencies = [ "tokio-rustls", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.28", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "hyper-util" version = "0.1.3" @@ -2701,12 +2663,6 @@ dependencies = [ "serde_test", ] -[[package]] -name = "linux-raw-sys" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" - [[package]] name = "lock_api" version = "0.4.11" @@ -2917,24 +2873,6 @@ dependencies = [ "rayon", ] -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "new_debug_unreachable" version = "1.0.4" @@ -3148,50 +3086,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "openssl" -version = "0.10.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" -dependencies = [ - "bitflags 2.4.2", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "openssl-sys" -version = "0.9.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "owo-colors" version = "3.5.0" @@ -3877,13 +3777,11 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.28", "hyper-rustls", - "hyper-tls", "ipnet", "js-sys", "log", "mime", "mime_guess", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -3896,7 +3794,6 @@ dependencies = [ "sync_wrapper", "system-configuration", "tokio", - "tokio-native-tls", "tokio-rustls", "tokio-util", "tower-service", @@ -4176,19 +4073,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "0.38.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" -dependencies = [ - "bitflags 2.4.2", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - [[package]] name = "rustls" version = "0.21.7" @@ -4640,6 +4524,7 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" name = "site-app" version = "0.1.0" dependencies = [ + "artifact", "auth", "base64", "bl", @@ -4653,7 +4538,6 @@ dependencies = [ "leptos_axum", "leptos_meta", "leptos_router", - "reqwest", "serde", "server_fn", "thiserror", @@ -5056,18 +4940,6 @@ version = "0.12.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" -[[package]] -name = "tempfile" -version = "3.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" -dependencies = [ - "cfg-if", - "fastrand", - "rustix", - "windows-sys 0.52.0", -] - [[package]] name = "term" version = "0.7.0" @@ -5207,16 +5079,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.24.1" @@ -5774,12 +5636,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version-compare" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index 0b64baa..b7b2870 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ leptos_axum = { version = "0.6", features = ["experimental-islands"] } leptos_meta = { version = "0.6", features = ["nightly"] } leptos_router = { version = "0.6", features = ["nightly"] } log = "0.4" -reqwest = { version = "0.11" } server_fn = { version = "0.6", features = ["multipart"] } serde = { version = "1", features = ["derive"] } simple_logger = "4.2.0" diff --git a/crates/site-app/Cargo.toml b/crates/site-app/Cargo.toml index 5d5f8a1..b15b56a 100644 --- a/crates/site-app/Cargo.toml +++ b/crates/site-app/Cargo.toml @@ -19,7 +19,6 @@ serde.workspace = true bytes = { workspace = true, optional = true } base64 = { workspace = true, optional = true } image = { workspace = true, optional = true } -reqwest = { workspace = true, optional = true } validator = "0.16.1" web-sys = { version = "0.3", features = [ "Window", "EventTarget" ] } @@ -27,6 +26,7 @@ web-sys = { version = "0.3", features = [ "Window", "EventTarget" ] } core_types = { path = "../core_types" } validation = { path = "../validation" } +artifact = { path = "../artifact", optional = true } auth = { path = "../auth", optional = true } clients = { path = "../clients", optional = true } bl = { path = "../bl", optional = true } @@ -36,6 +36,6 @@ default = [] hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"] ssr = [ "leptos/ssr", "leptos_meta/ssr", "leptos_router/ssr", "dep:leptos_axum", - "auth", "base64", "bl", "bytes", "clients", "image", "reqwest" + "artifact", "auth", "base64", "bl", "bytes", "clients", "image" ] diff --git a/crates/site-app/src/components/photo.rs b/crates/site-app/src/components/photo.rs index e993099..3cd4ca2 100644 --- a/crates/site-app/src/components/photo.rs +++ b/crates/site-app/src/components/photo.rs @@ -42,6 +42,7 @@ pub fn Photo(photo_id: core_types::PhotoRecordId) -> impl IntoView { pub async fn fetch_photo_thumbnail( photo_id: core_types::PhotoRecordId, ) -> Result { + use artifact::Artifact; use base64::prelude::*; // prep the surreal client @@ -77,25 +78,26 @@ pub async fn fetch_photo_thumbnail( "Failed to select thumbnail artifact: {e:?}" )) })?; - let thumbnail_artifact = thumbnail_artifact.ok_or_else(|| { + let mut thumbnail_artifact = thumbnail_artifact.ok_or_else(|| { ServerFnError::new("Thumbnail artifact not found".to_string()) })?; - // fetch the artifact using the url - let thumbnail_image = reqwest::get(thumbnail_artifact.url) - .await - .map_err(|e| { - ServerFnError::new(format!("Failed to fetch thumbnail: {e:?}")) - })? - .bytes() - .await - .map_err(|e| { - ServerFnError::new(format!("Failed to fetch thumbnail: {e:?}")) - })?; + // download the thumbnail artifact and get the content + thumbnail_artifact.download().await.map_err(|e| { + ServerFnError::new(format!("Failed to download thumbnail: {e:?}")) + })?; + let thumbnail_artifact_content = match thumbnail_artifact.contents { + Some(content) => content, + None => { + return Err(ServerFnError::new( + "Thumbnail artifact content not found".to_string(), + )) + } + }; // load using the image crate - let thumbnail_image = - image::load_from_memory(&thumbnail_image).map_err(|e| { + let thumbnail_image = image::load_from_memory(&thumbnail_artifact_content) + .map_err(|e| { ServerFnError::new(format!("Failed to load thumbnail as image: {e:?}")) })?; From 86ab7807246c8583192168f1bd255b493eeca59d Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 15:07:36 -0600 Subject: [PATCH 21/22] cargo update --- Cargo.lock | 285 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 159 insertions(+), 126 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e6e976..a8bb1eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,6 +44,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" dependencies = [ "cfg-if", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -135,7 +136,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -243,7 +244,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -260,7 +261,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -298,7 +299,7 @@ dependencies = [ "attribute-derive-macro", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -314,7 +315,7 @@ dependencies = [ "proc-macro2", "quote", "quote-use", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -450,7 +451,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -623,7 +624,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", "syn_derive", ] @@ -665,9 +666,9 @@ checksum = "38d17f4d6e4dc36d1a02fbedc2753a096848e7c1b0772f7654eab8e2c927dd53" [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" [[package]] name = "bytecheck" @@ -772,9 +773,9 @@ dependencies = [ [[package]] name = "cedar-policy" -version = "2.4.3" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ff2003d0aba0a4b2e5212660321d63dc7c36efe636d6ca1882d489cbc0bef8" +checksum = "3d91e3b10a0f7f2911774d5e49713c4d25753466f9e11d1cd2ec627f8a2dc857" dependencies = [ "cedar-policy-core", "cedar-policy-validator", @@ -789,9 +790,9 @@ dependencies = [ [[package]] name = "cedar-policy-core" -version = "2.4.3" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c52f9666c7cb1b6f14a6e77d3ffcffa20fd3e1012ac8dcc393498c33ff632c3" +checksum = "cd2315591c6b7e18f8038f0a0529f254235fd902b6c217aabc04f2459b0d9995" dependencies = [ "either", "ipnet", @@ -812,9 +813,9 @@ dependencies = [ [[package]] name = "cedar-policy-validator" -version = "2.4.3" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a63c1a72bcafda800830cbdde316162074b341b7d59bd4b1cea6156f22dfa7" +checksum = "e756e1b2a5da742ed97e65199ad6d0893e9aa4bd6b34be1de9e70bd1e6adc7df" dependencies = [ "cedar-policy-core", "itertools 0.10.5", @@ -1152,12 +1153,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.5" +version = "0.20.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc5d6b04b3fd0ba9926f945895de7d806260a2d7431ba82e7edaecb043c4c6b8" +checksum = "c376d08ea6aa96aafe61237c7200d1241cb177b7d3a542d791f2d118e9cbb955" dependencies = [ - "darling_core 0.20.5", - "darling_macro 0.20.5", + "darling_core 0.20.6", + "darling_macro 0.20.6", ] [[package]] @@ -1176,16 +1177,16 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.5" +version = "0.20.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e48a959bcd5c761246f5d090ebc2fbf7b9cd527a492b07a67510c108f1e7e3" +checksum = "33043dcd19068b8192064c704b3f83eb464f91f1ff527b44a4e2b08d9cdb8855" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -1201,13 +1202,13 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.5" +version = "0.20.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1545d67a2149e1d93b7e5c7752dce5a7426eb5d1357ddcfd89336b94444f77" +checksum = "c5a91391accf613803c2a9bf9abccdbaa07c54b4244a5b64883f9c3c137c86be" dependencies = [ - "darling_core 0.20.5", + "darling_core 0.20.6", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -1258,14 +1259,14 @@ checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] name = "deunicode" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae2a35373c5c74340b79ae6780b498b2b183915ec5dacf263aac5a099bf485a" +checksum = "b6e854126756c496b8c81dec88f9a706b15b875c5849d4097a3854476b9fdf94" [[package]] name = "diff" @@ -1584,7 +1585,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -1678,6 +1679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567495020b114f1ce9bed679b29975aa0bfae06ac22beacd5cfde5dabe7b05d6" dependencies = [ "approx", + "arbitrary 1.3.2", "num-traits", "rstar", "serde", @@ -1901,9 +1903,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" +checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" [[package]] name = "hex" @@ -2217,7 +2219,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2469,7 +2471,7 @@ dependencies = [ "quote", "rstml", "serde", - "syn 2.0.48", + "syn 2.0.49", "walkdir", ] @@ -2505,7 +2507,7 @@ dependencies = [ "quote", "rstml", "server_fn_macro", - "syn 2.0.48", + "syn 2.0.49", "tracing", "uuid", ] @@ -2568,7 +2570,7 @@ dependencies = [ "leptos_integration_utils", "leptos_meta", "linear-map", - "lru 0.11.1", + "lru", "once_cell", "percent-encoding", "regex", @@ -2698,15 +2700,6 @@ dependencies = [ "hashbrown 0.14.3", ] -[[package]] -name = "lru" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2c024b41519440580066ba82aab04092b333e09066a5eb86c7c4890df31f22" -dependencies = [ - "hashbrown 0.14.3", -] - [[package]] name = "manyhow" version = "0.8.1" @@ -2716,7 +2709,7 @@ dependencies = [ "manyhow-macros", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2782,7 +2775,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2951,13 +2944,13 @@ dependencies = [ [[package]] name = "num-derive" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3014,9 +3007,9 @@ dependencies = [ [[package]] name = "num_threads" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" dependencies = [ "libc", ] @@ -3251,7 +3244,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3289,15 +3282,15 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "png" -version = "0.17.11" +version = "0.17.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f6c3c3e617595665b8ea2ff95a86066be38fb121ff920a9c0eb282abcd1da5a" +checksum = "78c2378060fb13acff3ba0325b83442c1d2c44fbb76df481160ddc1687cce160" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -3331,7 +3324,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3395,16 +3388,16 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", "version_check", "yansi", ] [[package]] name = "profiling" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d135ede8821cf6376eb7a64148901e1690b788c11ae94dc297ae917dbc91dc0e" +checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" dependencies = [ "profiling-procmacros", ] @@ -3416,7 +3409,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" dependencies = [ "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3479,6 +3472,18 @@ dependencies = [ "serde", ] +[[package]] +name = "quick_cache" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58c20af3800cee5134b79a3bd4a3d4b583c16ccfa5f53338f46400851a5b3819" +dependencies = [ + "ahash 0.8.8", + "equivalent", + "hashbrown 0.14.3", + "parking_lot", +] + [[package]] name = "quote" version = "1.0.35" @@ -3496,7 +3501,7 @@ checksum = "a7b5abe3fe82fdeeb93f44d66a7b444dedf2e4827defb0a8e69c437b2de2ef94" dependencies = [ "quote", "quote-use-macros", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3508,7 +3513,7 @@ dependencies = [ "derive-where", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3619,7 +3624,7 @@ dependencies = [ "nasm-rs", "new_debug_unreachable", "noop_proc_macro", - "num-derive 0.4.1", + "num-derive 0.4.2", "num-traits", "once_cell", "paste", @@ -3714,7 +3719,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3806,12 +3811,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "retain_mut" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c31b5c4033f8fdde8700e4657be2c497e7288f01515be52168c631e2e4d4086" - [[package]] name = "revision" version = "0.5.0" @@ -3836,11 +3835,11 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf996fc5f61f1dbec35799b5c00c6dda12e8862e8cb782ed24e10d0292e60ed3" dependencies = [ - "darling 0.20.5", + "darling 0.20.6", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3934,13 +3933,12 @@ dependencies = [ [[package]] name = "roaring" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6106b5cf8587f5834158895e9715a3c6c9716c8aefab57f1f7680917191c7873" +checksum = "a1c77081a55300e016cb86f2864415b7518741879db925b8d488a0ee0d2da6bf" dependencies = [ "bytemuck", "byteorder", - "retain_mut", "serde", ] @@ -3990,7 +3988,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.48", + "syn 2.0.49", "syn_derive", "thiserror", ] @@ -4075,12 +4073,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", - "ring 0.16.20", + "ring 0.17.7", "rustls-webpki", "sct", ] @@ -4220,9 +4218,9 @@ checksum = "58bf37232d3bb9a2c4e641ca2a11d83b5062066f88df7fed36c28772046d65ba" [[package]] name = "semver" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" dependencies = [ "serde", ] @@ -4238,9 +4236,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] @@ -4258,20 +4256,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "indexmap 2.2.3", "itoa", @@ -4281,9 +4279,9 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" +checksum = "ebd154a240de39fdebcf5775d2675c204d7c13cf39a4c697be6493c8e734337c" dependencies = [ "itoa", "serde", @@ -4332,9 +4330,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.4.0" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" +checksum = "15d167997bd841ec232f5b2b8e0e26606df2e7caa4c31b95ea9ca52b200bd270" dependencies = [ "base64", "chrono", @@ -4342,6 +4340,7 @@ dependencies = [ "indexmap 1.9.3", "indexmap 2.2.3", "serde", + "serde_derive", "serde_json", "serde_with_macros", "time", @@ -4349,14 +4348,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.4.0" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" +checksum = "865f9743393e638991566a8b7a479043c2c8da94a33e0a31f18214c9cae0a64d" dependencies = [ - "darling 0.20.5", + "darling 0.20.6", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -4405,7 +4404,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", "xxhash-rust", ] @@ -4416,7 +4415,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "752ed78ec49132d154b922cf5ab6485680cab039a75740c48ea2db621ad481da" dependencies = [ "server_fn_macro", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -4754,9 +4753,48 @@ dependencies = [ [[package]] name = "surrealdb" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f295e08202d723ffd628b057fee207938804bccae60c49316197fed898d85536" +checksum = "7b4c189541c759c763d4f5859a853afe85773baa0c95891f262425ff422394b0" +dependencies = [ + "async-channel", + "bincode", + "chrono", + "dmp", + "flume", + "futures", + "futures-concurrency", + "geo 0.27.0", + "indexmap 2.2.3", + "once_cell", + "path-clean", + "pharos", + "reqwest", + "revision", + "ring 0.17.7", + "rust_decimal", + "rustls", + "semver", + "serde", + "serde_json", + "surrealdb-core", + "thiserror", + "tokio", + "tokio-tungstenite", + "tracing", + "trice", + "url", + "uuid", + "wasm-bindgen-futures", + "wasmtimer", + "ws_stream_wasm", +] + +[[package]] +name = "surrealdb-core" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf33ccbc2348089fab502d38198f86762fc951ec90413fbd63f9195e76e6e08" dependencies = [ "addr", "any_ascii", @@ -4772,36 +4810,32 @@ dependencies = [ "chrono", "deunicode", "dmp", - "flume", "fst", "futures", - "futures-concurrency", "fuzzy-matcher", "geo 0.27.0", + "geo-types", "hex", - "indexmap 2.2.3", "ipnet", "lexicmp", - "lru 0.12.2", "md-5", "nanoid", "nom", "num_cpus", "object_store 0.8.0", "once_cell", - "path-clean", "pbkdf2", "pharos", "pin-project-lite", + "quick_cache", "radix_trie", "rand", "regex", - "reqwest", "revision", + "ring 0.17.7", "roaring", "rust-stemmers", "rust_decimal", - "rustls", "scrypt", "semver", "serde", @@ -4814,7 +4848,6 @@ dependencies = [ "surrealdb-jsonwebtoken", "thiserror", "tokio", - "tokio-tungstenite", "tracing", "trice", "ulid", @@ -4867,9 +4900,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" dependencies = [ "proc-macro2", "quote", @@ -4885,7 +4918,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -4968,7 +5001,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5076,7 +5109,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5158,7 +5191,7 @@ checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.3", "toml_datetime", - "winnow 0.5.39", + "winnow 0.5.40", ] [[package]] @@ -5341,7 +5374,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5429,7 +5462,7 @@ checksum = "563b3b88238ec95680aef36bdece66896eaa7ce3c0f1b4f39d38fb2435261352" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5575,7 +5608,7 @@ checksum = "c372e4e6fad129795fb86fda6021b258948560b39883b80ed00510a7d19846b0" dependencies = [ "cfg-if", "noop_proc_macro", - "num-derive 0.4.1", + "num-derive 0.4.2", "num-traits", "profiling", ] @@ -5694,7 +5727,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", "wasm-bindgen-shared", ] @@ -5728,7 +5761,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5971,9 +6004,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.39" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] @@ -6027,9 +6060,9 @@ dependencies = [ [[package]] name = "xxhash-rust" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53be06678ed9e83edb1745eb72efc0bbcd7b5c3c35711a860906aed827a13d61" +checksum = "927da81e25be1e1a2901d59b81b37dd2efd1fc9c9345a55007f09bf5a2d3ee03" [[package]] name = "yansi" @@ -6054,7 +6087,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] From 80aa2807b80ddbf8d3b73e8a51b9d825fa6ddfd3 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sat, 17 Feb 2024 16:36:12 -0600 Subject: [PATCH 22/22] fix: add `nasm` to `x86_64-linux` build deps --- flake.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flake.nix b/flake.nix index 031c6f5..66e40fb 100644 --- a/flake.nix +++ b/flake.nix @@ -66,6 +66,9 @@ pkgs.tailwindcss pkgs.yarn pkgs.yarn2nix-moretea.fixup_yarn_lock + ] ++ pkgs.lib.optionals (system == "x86_64-linux") [ + # extra packages only for x86_64-linux + pkgs.nasm ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ # Additional darwin specific inputs can be set here pkgs.libiconv