From 6ecbefbcf6511976e468189a3641c7d43a2d672a Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Wed, 14 Oct 2026 23:24:03 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9=C3=A9criture=20de=20lara-bermite=20en?= =?UTF-8?q?=20Rust=20(Axum,=20Leptos,=20Tailwind)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Application de suivi de la pluviométrie et de la météo, portée depuis Laravel + React vers Leptos 0.8 (SSR + hydratation) sur Axum, avec Tailwind CSS v4 et SQLite. - Pages : accueil (chiffres clés, comparaison mois par mois avec l'an dernier), pluviométrie (graphique par jour/semaine/mois/année), liste des mesures (édition en place), météo OpenWeatherMap, profil (emplacement, thème clair/sombre), authentification et réinitialisation du mot de passe par e-mail. - Sessions tower-sessions en SQLite ; mots de passe Argon2, les hash bcrypt de Laravel restent valides et sont convertis à la connexion. - Import unique des données MySQL de lara-bermite (bin import_mysql). - PWA : manifest et service worker « réseau d'abord ». - Makefile de cross-compilation aarch64 et service systemd pour le Pi. Co-Authored-By: Claude Opus 5.5 --- .env.example | 11 + .gitignore | 5 + Cargo.lock | 4122 +++++++++++++++++++++++++++ Cargo.toml | 95 + Makefile | 86 + README.md | 60 + build.rs | 5 + deploy/bermite.service | 25 + migrations/0001_init.sql | 42 + public/apple-touch-icon-180x180.png | Bin 0 -> 1270 bytes public/favicon.ico | Bin 0 -> 15086 bytes public/favicon.svg | 109 + public/images/icons/01d.svg | 45 + public/images/icons/02d.svg | 55 + public/images/icons/03d.svg | 48 + public/images/icons/03n.svg | 48 + public/images/icons/04d.svg | 62 + public/images/icons/09d.svg | 116 + public/images/icons/10d.svg | 102 + public/images/icons/weather.svg | 52 + public/manifest.webmanifest | 18 + public/maskable-icon-512x512.png | Bin 0 -> 2871 bytes public/offline.html | 21 + public/pwa-192x192.png | Bin 0 -> 1503 bytes public/pwa-512x512.png | Bin 0 -> 3143 bytes public/pwa-64x64.png | Bin 0 -> 620 bytes public/robots.txt | 2 + public/sw.js | 59 + src/app.rs | 282 ++ src/auth.rs | 390 +++ src/bin/import_mysql.rs | 127 + src/chart.rs | 304 ++ src/components.rs | 325 +++ src/errors.rs | 72 + src/icons.rs | 101 + src/lib.rs | 27 + src/location.rs | 101 + src/mail.rs | 65 + src/main.rs | 95 +- src/pages/auth.rs | 210 ++ src/pages/home.rs | 29 + src/pages/mod.rs | 5 + src/pages/profile.rs | 217 ++ src/pages/rainfall.rs | 474 +++ src/pages/weather.rs | 210 ++ src/profile.rs | 77 + src/rainfall.rs | 258 ++ src/rainfall/graph.rs | 353 +++ src/server.rs | 246 ++ src/ui.rs | 251 ++ src/weather.rs | 382 +++ style/tailwind.css | 83 + 52 files changed, 9870 insertions(+), 2 deletions(-) create mode 100644 .env.example create mode 100644 Cargo.lock create mode 100644 Makefile create mode 100644 README.md create mode 100644 build.rs create mode 100644 deploy/bermite.service create mode 100644 migrations/0001_init.sql create mode 100644 public/apple-touch-icon-180x180.png create mode 100644 public/favicon.ico create mode 100644 public/favicon.svg create mode 100644 public/images/icons/01d.svg create mode 100644 public/images/icons/02d.svg create mode 100644 public/images/icons/03d.svg create mode 100644 public/images/icons/03n.svg create mode 100644 public/images/icons/04d.svg create mode 100644 public/images/icons/09d.svg create mode 100644 public/images/icons/10d.svg create mode 100644 public/images/icons/weather.svg create mode 100644 public/manifest.webmanifest create mode 100644 public/maskable-icon-512x512.png create mode 100644 public/offline.html create mode 100644 public/pwa-192x192.png create mode 100644 public/pwa-512x512.png create mode 100644 public/pwa-64x64.png create mode 100644 public/robots.txt create mode 100644 public/sw.js create mode 100644 src/app.rs create mode 100644 src/auth.rs create mode 100644 src/bin/import_mysql.rs create mode 100644 src/chart.rs create mode 100644 src/components.rs create mode 100644 src/errors.rs create mode 100644 src/icons.rs create mode 100644 src/lib.rs create mode 100644 src/location.rs create mode 100644 src/mail.rs create mode 100644 src/pages/auth.rs create mode 100644 src/pages/home.rs create mode 100644 src/pages/mod.rs create mode 100644 src/pages/profile.rs create mode 100644 src/pages/rainfall.rs create mode 100644 src/pages/weather.rs create mode 100644 src/profile.rs create mode 100644 src/rainfall.rs create mode 100644 src/rainfall/graph.rs create mode 100644 src/server.rs create mode 100644 src/ui.rs create mode 100644 src/weather.rs create mode 100644 style/tailwind.css diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9f8f3cd --- /dev/null +++ b/.env.example @@ -0,0 +1,11 @@ +DATABASE_URL=sqlite:bermite.db +# URL publique, utilisée dans le lien de réinitialisation du mot de passe. +APP_URL=http://127.0.0.1:3004 +OPEN_WEATHER_MAP_API_KEY= +# Sans SMTP_HOST, le lien de réinitialisation est seulement écrit dans les logs. +SMTP_HOST= +SMTP_PORT=465 +SMTP_USERNAME= +SMTP_PASSWORD= +MAIL_FROM="Bermite " +REGISTRATION_ENABLED=false diff --git a/.gitignore b/.gitignore index ea8c4bf..217604b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ /target +/dist +.env +*.db +*.db-shm +*.db-wal diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..daf340f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,4122 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "any_spawner" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1384d3fe1eecb464229fcf6eebb72306591c56bf27b373561489458a7c73027d" +dependencies = [ + "futures", + "thiserror 2.0.21", + "tokio", + "wasm-bindgen-futures", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "argon2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072" +dependencies = [ + "base64ct", + "blake2", + "cpufeatures 0.2.17", + "password-hash", +] + +[[package]] +name = "async-lock" +version = "3.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-once-cell" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288f83726785267c6f2ef073a3d83dc3f9b81464e9f99898240cced85fce35a" + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "attribute-derive" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f9ef7a68684657ce9da341c934c73b63df7a3585a61e366d84c84ed5d3d167" +dependencies = [ + "attribute-derive-macro", + "manyhow", + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "attribute-derive-macro" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300d426e5e73549125bb8e4649bdd5508f82c94ddf898fb0517246e71dfb8e98" +dependencies = [ + "collection_literals", + "interpolator", + "manyhow", + "proc-macro-utils", + "proc-macro2", + "quote", + "quote-use", + "syn 3.0.6", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "axum" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" +dependencies = [ + "axum-core", + "base64 0.22.1", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "multer", + "percent-encoding", + "pin-project-lite", + "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sha1", + "sync_wrapper", + "tokio", + "tokio-tungstenite", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "base16" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d27c3610c36aee21ce8ac510e6224498de4228ad772a171ed65643a24693a5a8" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + +[[package]] +name = "bcrypt" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abaf6da45c74385272ddf00e1ac074c7d8a6c1a1dda376902bd6a427522a8b2c" +dependencies = [ + "base64 0.22.1", + "blowfish", + "getrandom 0.3.4", + "subtle", + "zeroize", +] + +[[package]] +name = "bermite_rs" +version = "0.1.0" +dependencies = [ + "argon2", + "axum", + "bcrypt", + "chrono", + "console_error_panic_hook", + "dotenvy", + "hex", + "leptos", + "leptos_axum", + "leptos_meta", + "leptos_router", + "lettre", + "reqwest", + "serde", + "serde_json", + "sha2", + "sqlx", + "tokio", + "tower-sessions", + "tower-sessions-sqlx-store", + "wasm-bindgen", +] + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blowfish" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e412e2cd0f2b2d93e02543ceae7917b3c70331573df19ee046bcbc35e45e87d7" +dependencies = [ + "byteorder", + "cipher", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "camino" +version = "1.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbad30e4b4c14a39e3cc8aed085a12a327257c316619c93581e017bc52be591" + +[[package]] +name = "cc" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f74872d07caf508b30a21f6836e7d7016a2eaf7d9ff4f48deaa58cd8a0407630" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "rand_core 0.10.1", +] + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "codee" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9dbbdc4b4d349732bc6690de10a9de952bd39ba6a065c586e26600b6b0b91f5" +dependencies = [ + "serde", + "serde_json", + "thiserror 2.0.21", +] + +[[package]] +name = "collection_literals" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2550f75b8cfac212855f6b1885455df8eaee8fe8e246b647d69146142e016084" + +[[package]] +name = "config" +version = "0.15.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e9fbc53afcec54441422f1c596cd054655b32e70e1cbac956651b7b175a404" +dependencies = [ + "convert_case 0.6.0", + "pathdiff", + "serde_core", + "toml", + "winnow", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "const-str" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18f12cc9948ed9604230cdddc7c86e270f9401ccbe3c2e98a4378c5e7632212f" + +[[package]] +name = "const_format" +version = "0.2.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4481a617ad9a412be3b97c5d403fef8ed023103368908b9c50af598ff467cc1e" +dependencies = [ + "const_format_proc_macros", + "konst", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "const_str_slice_concat" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67855af358fcb20fac58f9d714c94e2b228fe5694c1c9b4ead4a366343eda1b" + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "convert_case" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "affbf0190ed2caf063e3def54ff444b449371d55c58e513a95ab98eca50adb49" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "convert_case_extras" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589c70f0faf8aa9d17787557d5eae854d7755cac50f5c3d12c81d3d57661cebb" +dependencies = [ + "convert_case 0.11.0", +] + +[[package]] +name = "cookie" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "217698eaf96b4a3f0bc4f3662aaa55bdf913cd54d7204591faa790070c6d0853" + +[[package]] +name = "crossbeam-queue" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03e8bd762f7479489c70ed6c768ddca99d7296857de437a68dcb2a94365b3fae" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "derive-where" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e2b94854e8576378ccda7c8de8a66ed8b4e8acbd2c50ec3418ea6c8aaf4b567" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "drain_filter_polyfill" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "669a445ee724c5c69b1b06fe0b63e70a1c84bc9bb7d9696cd4f4e3ec45050408" + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" +dependencies = [ + "serde", +] + +[[package]] +name = "either_of" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5060e0a4cbf26a87550792688ade88e6b8aec9208613631a7a363bda7bc2d4cd" +dependencies = [ + "paste", + "pin-project-lite", +] + +[[package]] +name = "email-encoding" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "420b9da095f052ea597503e39073b5b3c522f7db933fbac202d91d24492693fd" +dependencies = [ + "base64 0.23.1", + "memchr", +] + +[[package]] +name = "email_address" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449" + +[[package]] +name = "encoding_rs" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "erased" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1731451909bde27714eacba19c2566362a7f35224f52b153d3f42cf60f72472" + +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "find-msvc-tools" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" + +[[package]] +name = "flume" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" +dependencies = [ + "futures-core", + "futures-sink", + "spin", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 6.0.0", + "rand_core 0.10.1", + "wasm-bindgen", +] + +[[package]] +name = "gloo-net" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06f627b1a58ca3d42b45d6104bf1e1a03799df472df00988b6ba21accc10580" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "gloo-utils", + "http", + "js-sys", + "pin-project", + "serde", + "serde_json", + "thiserror 1.0.69", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "gloo-utils" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa" +dependencies = [ + "js-sys", + "serde", + "serde_json", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "guardian" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17e2ac29387b1aa07a1e448f7bb4f35b500787971e965b02842b900afa5c8f6f" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown 0.15.5", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "hostname" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd" +dependencies = [ + "cfg-if", + "libc", + "windows-link", +] + +[[package]] +name = "html-escape" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9356095b4b41197bba32173600e1582792cda618f65d12f68e2e77d273413c5" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "http-range-header" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hydration_context" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "285b05858fe7d58c5eff059f7b46c228fd86996d996c59eb35fc0340d174f640" +dependencies = [ + "futures", + "js-sys", + "or_poisoned", + "pin-project-lite", + "serde", + "throw_error", + "wasm-bindgen", +] + +[[package]] +name = "hyper" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c" +dependencies = [ + "atomic-waker", + "bytes", + "futures-core", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" +dependencies = [ + "base64 0.23.1", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" + +[[package]] +name = "icu_properties" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" + +[[package]] +name = "icu_provider" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "interpolator" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71dd52191aae121e8611f1e8dc3e324dd0dd1dee1e6dd91d10ee07a3cfb4d9d8" + +[[package]] +name = "inventory" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" +dependencies = [ + "rustversion", +] + +[[package]] +name = "ipnet" +version = "2.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "konst" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128133ed7824fcd73d6e7b17957c5eb7bacb885649bd8c69708b2331a10bcefb" +dependencies = [ + "konst_macro_rules", +] + +[[package]] +name = "konst_macro_rules" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" +dependencies = [ + "spin", +] + +[[package]] +name = "leptos" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713ee6895e3d1126ea9781280d01414f5643f3f201a949b71efffac07d735f00" +dependencies = [ + "any_spawner", + "base64 0.22.1", + "cfg-if", + "either_of", + "futures", + "getrandom 0.4.3", + "hydration_context", + "leptos_config", + "leptos_dom", + "leptos_hot_reload", + "leptos_macro", + "leptos_server", + "oco_ref", + "or_poisoned", + "paste", + "rand 0.9.5", + "reactive_graph", + "rustc-hash", + "rustc_version", + "send_wrapper", + "serde", + "serde_json", + "serde_qs", + "server_fn", + "slotmap", + "tachys", + "thiserror 2.0.21", + "throw_error", + "typed-builder", + "typed-builder-macro", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm_split_helpers", + "web-sys", +] + +[[package]] +name = "leptos_axum" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "513e2dd5fe81512b53304429b9ca77cceb954d23af88921c0c33119380f07cbe" +dependencies = [ + "any_spawner", + "axum", + "futures", + "hydration_context", + "leptos", + "leptos_integration_utils", + "leptos_macro", + "leptos_meta", + "leptos_router", + "or_poisoned", + "server_fn", + "tachys", + "tokio", + "tower", + "tower-http", +] + +[[package]] +name = "leptos_config" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c06f751315bccc0d193fab302ac01d25bcfcd97474d4676440e7e3250dc3fc3" +dependencies = [ + "config", + "regex", + "serde", + "thiserror 2.0.21", + "typed-builder", +] + +[[package]] +name = "leptos_dom" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35742e9ed8f8aaf9e549b454c68a7ac0992536e06856365639b111f72ab07884" +dependencies = [ + "js-sys", + "or_poisoned", + "reactive_graph", + "send_wrapper", + "tachys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "leptos_hot_reload" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d84989bd3d604e66adbfe13a32bec2ea47bdcb6c9fcd643f784facbb32f6ef10" +dependencies = [ + "anyhow", + "camino", + "indexmap", + "or_poisoned", + "proc-macro2", + "quote", + "rstml", + "serde", + "syn 3.0.6", + "walkdir", +] + +[[package]] +name = "leptos_integration_utils" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd93f4fd62ee9845cc50b0925272bccce6fd18e8168c4ad8a4f50eef9a93f747" +dependencies = [ + "futures", + "hydration_context", + "leptos", + "leptos_config", + "leptos_meta", + "leptos_router", + "reactive_graph", +] + +[[package]] +name = "leptos_macro" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0902af1e6947ffc7e906b7003a165f76f178dc711a47b74241025090b0c32a72" +dependencies = [ + "attribute-derive", + "cfg-if", + "convert_case 0.11.0", + "convert_case_extras", + "html-escape", + "itertools", + "leptos_hot_reload", + "prettyplease", + "proc-macro2", + "quote", + "rstml", + "rustc_version", + "server_fn_macro", + "syn 3.0.6", + "uuid", +] + +[[package]] +name = "leptos_meta" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "987b1a07addba2647da43c0689408cccc0f428236b714ea606127b9e347d35d8" +dependencies = [ + "futures", + "indexmap", + "leptos", + "or_poisoned", + "send_wrapper", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "leptos_router" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f92787ebcb5f25af6a67513dacfd75cbffce5bda3f361e2e947c3fc4e3adc14b" +dependencies = [ + "any_spawner", + "either_of", + "futures", + "gloo-net", + "js-sys", + "leptos", + "leptos_router_macro", + "or_poisoned", + "percent-encoding", + "reactive_graph", + "rustc_version", + "send_wrapper", + "tachys", + "thiserror 2.0.21", + "url", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "leptos_router_macro" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb5c81012dcab0d5cc032a2da0a364a18ce74a0fbeb88f091e9b53a0679bc85" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "leptos_server" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "202b2d1261c22d886f307934760a6bb566444f68f39b24f6f10defdc23633049" +dependencies = [ + "any_spawner", + "base64 0.22.1", + "codee", + "futures", + "hydration_context", + "or_poisoned", + "reactive_graph", + "send_wrapper", + "serde", + "serde_json", + "server_fn", + "tachys", +] + +[[package]] +name = "lettre" +version = "0.11.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2c646bd5cc763b1087b15493e29a64be6147ba8f19342004fa52048ee596eae" +dependencies = [ + "async-trait", + "base64 0.23.1", + "email-encoding", + "email_address", + "fastrand", + "futures-io", + "futures-util", + "hostname", + "httpdate", + "idna", + "mime", + "nom", + "percent-encoding", + "quoted_printable", + "rustls", + "socket2", + "tokio", + "tokio-rustls", + "url", + "webpki-roots", +] + +[[package]] +name = "libc" +version = "0.2.190" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +dependencies = [ + "bitflags", + "libc", + "plain", + "redox_syscall 0.9.4", +] + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", + "serde", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "lru-slab" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" + +[[package]] +name = "manyhow" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c69ea6e469ca785c846b25dd69eac9e9c916b51d8ada1f212866787ee1da12d" +dependencies = [ + "manyhow-macros", + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "manyhow-macros" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22fc5c1b2c4000056dae3619fea36e79ce79dabfee4907d2dcad6612b189e370" +dependencies = [ + "proc-macro-utils", + "proc-macro2", + "quote", +] + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "mio" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "multer" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http", + "httparse", + "memchr", + "mime", + "spin", + "version_check", +] + +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + +[[package]] +name = "next_tuple" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60993920e071b0c9b66f14e2b32740a4e27ffc82854dcd72035887f336a09a28" + +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" +dependencies = [ + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.8", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "oco_ref" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed0423ff9973dea4d6bd075934fdda86ebb8c05bdf9d6b0507067d4a1226371d" +dependencies = [ + "serde", + "thiserror 2.0.21", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "or_poisoned" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c04f5d74368e4d0dfe06c45c8627c81bd7c317d52762d118fb9b3076f6420fd" + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link", +] + +[[package]] +name = "password-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0" +dependencies = [ + "proc-macro2", + "syn 3.0.6", +] + +[[package]] +name = "proc-macro-utils" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaf08a13de400bc215877b5bdc088f241b12eb42f0a548d3390dc1c56bb7071" +dependencies = [ + "proc-macro2", + "quote", + "smallvec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proc-macro2-diagnostics" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df921e1ef974ebc8dd9effdb0c037a96928ae8cbf871438e02d6fd67204b595e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", + "version_check", +] + +[[package]] +name = "quinn" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.21", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe" +dependencies = [ + "bytes", + "getrandom 0.4.3", + "lru-slab", + "rand 0.10.3", + "rand_pcg", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.21", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.61.2", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "quote-use" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48356e493823dc3c1d7e9fc7b3ff204ecec48afbdd718fc4134091b88eb63f3d" +dependencies = [ + "quote", + "quote-use-macros", +] + +[[package]] +name = "quote-use-macros" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cf1c5de6a7cc231c71e03c77aa4c7019097859ea7029156b54d2894a8430704" +dependencies = [ + "proc-macro-utils", + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "quoted_printable" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478e0585659a122aa407eb7e3c0e1fa51b1d8a870038bd29f0cf4a8551eea972" + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core 0.10.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rand_pcg" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a" +dependencies = [ + "rand_core 0.10.1", +] + +[[package]] +name = "reactive_graph" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79f11fac67625645add76313dab8dae510fca0654d96ef98fd8f961a7d2e22c1" +dependencies = [ + "any_spawner", + "async-lock", + "futures", + "guardian", + "hydration_context", + "indexmap", + "or_poisoned", + "paste", + "pin-project-lite", + "rustc-hash", + "rustc_version", + "send_wrapper", + "serde", + "slotmap", + "thiserror 2.0.21", + "web-sys", +] + +[[package]] +name = "reactive_stores" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a29e469b556f25486678e9f5f65fa21a0351d98affde9a7eea9fee286bf8ebd6" +dependencies = [ + "guardian", + "indexmap", + "itertools", + "or_poisoned", + "paste", + "reactive_graph", + "reactive_stores_macro", + "rustc-hash", + "send_wrapper", +] + +[[package]] +name = "reactive_stores_macro" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d11f1b82859d94577892b8037c35f8a4f066cbb3864583e22e68def0af49a88" +dependencies = [ + "convert_case 0.11.0", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "737970939a87c6fa31e7acad13307bccbb017a073b695b6089a2c484f929e20e" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rmp" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ba8be72d372b2c9b35542551678538b562e7cf86c3315773cae48dfbfe7790c" +dependencies = [ + "num-traits", +] + +[[package]] +name = "rmp-serde" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f81bee8c8ef9b577d1681a70ebbc962c232461e397b22c208c43c04b67a155" +dependencies = [ + "rmp", + "serde", +] + +[[package]] +name = "rsa" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rstml" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6bd1bfba3c4c0b57aae906204d9e5744f3f65800ce6c75bd4cc162f2c26f3aa" +dependencies = [ + "derive-where", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 3.0.6", + "thiserror 2.0.21", +] + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" +dependencies = [ + "futures-core", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "serde_json" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + +[[package]] +name = "serde_qs" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3faaf9e727533a19351a43cc5a8de957372163c7d35cc48c90b75cdda13c352" +dependencies = [ + "percent-encoding", + "serde", + "thiserror 2.0.21", +] + +[[package]] +name = "serde_spanned" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "server_fn" +version = "0.8.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8559dd05af1b5b7e363a150616589d5a88af5187273f7f331ba0dae8922812" +dependencies = [ + "axum", + "base64 0.22.1", + "bytes", + "const-str", + "const_format", + "futures", + "gloo-net", + "http", + "http-body-util", + "hyper", + "inventory", + "js-sys", + "or_poisoned", + "pin-project-lite", + "rustc_version", + "rustversion", + "send_wrapper", + "serde", + "serde_json", + "serde_qs", + "server_fn_macro_default", + "thiserror 2.0.21", + "throw_error", + "tokio", + "tower", + "tower-layer", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "xxhash-rust", +] + +[[package]] +name = "server_fn_macro" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce79d7b6ab93f7994e5ff4999eb962f2aea370d7c3b91986eb75da738a8e65f9" +dependencies = [ + "const_format", + "convert_case 0.11.0", + "proc-macro2", + "quote", + "rustc_version", + "syn 3.0.6", + "xxhash-rust", +] + +[[package]] +name = "server_fn_macro_default" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9a4f81a0d855f279c3448243138a55cbfdd9851da9341b9c1e5971b90089e61" +dependencies = [ + "server_fn_macro", + "syn 3.0.6", +] + +[[package]] +name = "sha1" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "slotmap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "spin" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlx" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6" +dependencies = [ + "base64 0.22.1", + "bytes", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashbrown 0.15.5", + "hashlink", + "indexmap", + "log", + "memchr", + "once_cell", + "percent-encoding", + "serde", + "serde_json", + "sha2", + "smallvec", + "thiserror 2.0.21", + "time", + "tokio", + "tokio-stream", + "tracing", + "url", +] + +[[package]] +name = "sqlx-macros" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2d452988ccaacfbf5e0bdbc348fb91d7c8af5bee192173ac3636b5fb6e6715d" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 2.0.119", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19a9c1841124ac5a61741f96e1d9e2ec77424bf323962dd894bdb93f37d5219b" +dependencies = [ + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 2.0.119", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526" +dependencies = [ + "atoi", + "base64 0.22.1", + "bitflags", + "byteorder", + "bytes", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand 0.8.8", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror 2.0.21", + "time", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46" +dependencies = [ + "atoi", + "base64 0.22.1", + "bitflags", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand 0.8.8", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror 2.0.21", + "time", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea" +dependencies = [ + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "serde_urlencoded", + "sqlx-core", + "thiserror 2.0.21", + "time", + "tracing", + "url", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "stringprep" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", + "unicode-properties", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "tachys" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e47e2220bb9d2a3be976a22a0fb7685a0b84499bb11ea5cb3bbc82907675ac68" +dependencies = [ + "any_spawner", + "async-trait", + "const_str_slice_concat", + "drain_filter_polyfill", + "either_of", + "erased", + "futures", + "html-escape", + "indexmap", + "itertools", + "js-sys", + "next_tuple", + "oco_ref", + "or_poisoned", + "paste", + "reactive_graph", + "reactive_stores", + "rustc-hash", + "rustc_version", + "send_wrapper", + "slotmap", + "throw_error", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "throw_error" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0ed6038fcbc0795aca7c92963ddda636573b956679204e044492d2b13c8f64" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "time" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + +[[package]] +name = "tokio" +version = "1.53.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e95f91fcc7a621e8b030f6aa23c71fe9838ae2fb4d8118b75602a328f5144044" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d06f0b082ba57c26b79407372e57cf2a1e28124f78e9479fe80322cf53420b" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f72a05e828585856dacd553fba484c242c46e391fb0e58917c942ee9202915c" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "1.1.8+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-cookies" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "151b5a3e3c45df17466454bb74e9ecedecc955269bdedbf4d150dfa393b55a36" +dependencies = [ + "axum-core", + "cookie", + "futures-util", + "http", + "parking_lot", + "pin-project-lite", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "http-range-header", + "httpdate", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "tokio", + "tokio-util", + "tower", + "tower-layer", + "tower-service", + "url", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tower-sessions" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a05911f23e8fae446005fe9b7b97e66d95b6db589dc1c4d59f6a2d4d4927d3" +dependencies = [ + "async-trait", + "http", + "time", + "tokio", + "tower-cookies", + "tower-layer", + "tower-service", + "tower-sessions-core", + "tower-sessions-memory-store", + "tracing", +] + +[[package]] +name = "tower-sessions-core" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce8cce604865576b7751b7a6bc3058f754569a60d689328bb74c52b1d87e355b" +dependencies = [ + "async-trait", + "axum-core", + "base64 0.22.1", + "futures", + "http", + "parking_lot", + "rand 0.8.8", + "serde", + "serde_json", + "thiserror 2.0.21", + "time", + "tokio", + "tracing", +] + +[[package]] +name = "tower-sessions-memory-store" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb05909f2e1420135a831dd5df9f5596d69196d0a64c3499ca474c4bd3d33242" +dependencies = [ + "async-trait", + "time", + "tokio", + "tower-sessions-core", +] + +[[package]] +name = "tower-sessions-sqlx-store" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e054622079f57fc1a7d6a6089c9334f963d62028fe21dc9eddd58af9a78480b3" +dependencies = [ + "async-trait", + "rmp-serde", + "sqlx", + "thiserror 1.0.69", + "time", + "tower-sessions-core", +] + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "tungstenite" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c01152af293afb9c7c2a57e4b559c5620b421f6d133261c60dd2d0cdb38e6b8" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.9.5", + "sha1", + "thiserror 2.0.21", +] + +[[package]] +name = "typed-builder" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31aa81521b70f94402501d848ccc0ecaa8f93c8eb6999eb9747e72287757ffda" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076a02dc54dd46795c2e9c8282ed40bcfb1e22747e955de9389a1de28190fb26" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicase" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357cc3acc6a036009fd6c973ed009037c732d60d0b4f6c673e9041497482a28f" + +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + +[[package]] +name = "unicode-ident" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" + +[[package]] +name = "unicode-normalization" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97277d36b9c3ace13e58fa6e753f8b0bbbf302a18dd193240d70f9e29681059a" +dependencies = [ + "getrandom 0.4.3", + "js-sys", + "wasm-bindgen", +] + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ef4c5d3d2cdf5c54f4231181768f5510842e350db025faf1f7163b1030ed928" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.6", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-streams" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "wasm_split_helpers" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab578aae2fe2916edaea06843187d50f87b0965622da0ceef648edca27b385ba" +dependencies = [ + "async-once-cell", + "wasm_split_macros", +] + +[[package]] +name = "wasm_split_macros" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e653af7ee4a9ef0fce481a9ec6f43cb78de20d0cdb4f4f5862e1dc6e407e6c8" +dependencies = [ + "base16", + "quote", + "sha2", + "syn 2.0.119", +] + +[[package]] +name = "web-sys" +version = "0.3.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fbddc4a036f00ec4f18c83445bd3115cb306a91da554919a099d9222fe4a7f8" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "whoami" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d" +dependencies = [ + "libredox", + "wasite", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "xxhash-rust" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "550a2b930b62486a393c52d5c3b84bff264b28aa437ed64694d31e93b1757af7" + +[[package]] +name = "yoke" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86502bf56ac7c77571a32e2647bb2a15894565e981fb2a48d7bde2d91c965a9d" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5457206954b06561e2608c7e19cf58b1926586d999c246eebe4502f7e2039d1a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/Cargo.toml b/Cargo.toml index e510aae..0a33ba7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,4 +3,99 @@ name = "bermite_rs" version = "0.1.0" edition = "2024" +[lib] +crate-type = ["cdylib", "rlib"] + +[[bin]] +name = "bermite_rs" +path = "src/main.rs" + +# Import unique des données de lara-bermite (MySQL) vers SQLite. +[[bin]] +name = "import_mysql" +path = "src/bin/import_mysql.rs" +required-features = ["ssr", "import"] + [dependencies] +leptos = "0.8" +leptos_meta = "0.8" +leptos_router = "0.8" +serde = { version = "1", features = ["derive"] } +chrono = { version = "0.4", default-features = false, features = ["clock", "serde", "std", "wasmbind"] } + +# Client (WASM) +console_error_panic_hook = { version = "0.1", optional = true } +wasm-bindgen = { version = "=0.2.128", optional = true } + +# Serveur uniquement +axum = { version = "0.8", optional = true } +leptos_axum = { version = "0.8", optional = true } +tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "time"], optional = true } +sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio", "sqlite", "migrate", "macros"], optional = true } +tower-sessions = { version = "0.14", optional = true } +tower-sessions-sqlx-store = { version = "0.15", features = ["sqlite"], optional = true } +argon2 = { version = "0.5", optional = true } +bcrypt = { version = "0.17", optional = true } +sha2 = { version = "0.10", optional = true } +hex = { version = "0.4", optional = true } +dotenvy = { version = "0.15", optional = true } +reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"], optional = true } +lettre = { version = "0.11", default-features = false, features = ["builder", "hostname", "smtp-transport", "tokio1", "tokio1-rustls-tls"], optional = true } +serde_json = { version = "1", optional = true } + +[dev-dependencies] +tokio = { version = "1", features = ["rt-multi-thread", "macros"] } + +[features] +hydrate = [ + "leptos/hydrate", + "dep:console_error_panic_hook", + "dep:wasm-bindgen", +] +ssr = [ + "dep:axum", + "dep:tokio", + "dep:leptos_axum", + "dep:sqlx", + "dep:tower-sessions", + "dep:tower-sessions-sqlx-store", + "dep:argon2", + "dep:bcrypt", + "dep:sha2", + "dep:hex", + "dep:dotenvy", + "dep:reqwest", + "dep:lettre", + "dep:serde_json", + "leptos/ssr", + "leptos_meta/ssr", + "leptos_router/ssr", +] +import = ["sqlx/mysql"] + +# Profil optimisé en taille pour le bundle WASM en release +[profile.wasm-release] +inherits = "release" +opt-level = 'z' +lto = true +codegen-units = 1 +panic = "abort" + +[package.metadata.leptos] +output-name = "bermite_rs" +bin-target = "bermite_rs" +site-root = "target/site" +site-pkg-dir = "pkg" +tailwind-input-file = "style/tailwind.css" +# Fichiers copiés tels quels à la racine du site (icônes, manifest, service worker…) +assets-dir = "public" +site-addr = "127.0.0.1:3004" +reload-port = 3005 +browserquery = "defaults" +# Passer à "PROD" en production : active notamment le cookie de session `Secure` +env = "DEV" +bin-features = ["ssr"] +bin-default-features = false +lib-features = ["hydrate"] +lib-default-features = false +lib-profile-release = "wasm-release" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..572095e --- /dev/null +++ b/Makefile @@ -0,0 +1,86 @@ +# Build de bermite_rs pour Raspberry Pi (aarch64, Raspberry Pi OS 64 bits). +# +# Le front (wasm) ne dépend pas de l'architecture : il est construit par +# cargo-leptos. Le serveur est cross-compilé avec cargo-zigbuild, car sqlx +# compile SQLite en C et a donc besoin d'un compilateur C pour aarch64. +# +# make setup installe la cible Rust et cargo-zigbuild (zig à installer à part) +# make dev lance le serveur de développement (rechargement automatique) +# make test lance les tests +# make pi produit dist/ prêt à copier sur le Pi +# make deploy copie dist/ vers $(PI_HOST):$(PI_DIR) et redémarre le service +# make import MYSQL_URL=mysql://user:pass@127.0.0.1/lara-bermite +# importe les données de lara-bermite dans bermite.db (une seule fois) + +APP := bermite_rs +SERVICE := bermite +TARGET := aarch64-unknown-linux-gnu +# Version de glibc visée : 2.28 couvre Buster, Bullseye et Bookworm. +GLIBC := 2.28 +DIST := dist +SITE_ADDR := 127.0.0.1:3004 + +PI_HOST ?= raspiweb +PI_DIR ?= /home/pi/Scripts/$(SERVICE) + +BIN := target/$(TARGET)/release/$(APP) + +.PHONY: all dev test pi setup front server dist deploy import clean + +all: pi + +dev: + cargo leptos watch + +test: + cargo test --features ssr + +setup: + rustup target add $(TARGET) wasm32-unknown-unknown + cargo install --locked cargo-zigbuild + @command -v zig >/dev/null || echo "⚠ zig introuvable : installez-le (ex. 'sudo snap install zig --classic --beta' ou https://ziglang.org/download/)" + +pi: dist + +front: + cargo leptos build --release --frontend-only + +server: + LEPTOS_OUTPUT_NAME=$(APP) cargo zigbuild --release \ + --target $(TARGET).$(GLIBC) \ + --bin $(APP) --no-default-features --features ssr + +dist: front server + rm -rf $(DIST) + mkdir -p $(DIST) + cp $(BIN) $(DIST)/ + cp -r target/site $(DIST)/site + cp deploy/$(SERVICE).service $(DIST)/ + printf '%s\n' \ + 'LEPTOS_ENV=PROD' \ + 'LEPTOS_SITE_ROOT=site' \ + 'LEPTOS_SITE_PKG_DIR=pkg' \ + 'LEPTOS_SITE_ADDR=$(SITE_ADDR)' \ + 'DATABASE_URL=sqlite:bermite.db' \ + 'APP_URL=https://bermite.rodev.fr' \ + 'OPEN_WEATHER_MAP_API_KEY=' \ + 'SMTP_HOST=' \ + 'SMTP_PORT=465' \ + 'SMTP_USERNAME=' \ + 'SMTP_PASSWORD=' \ + 'MAIL_FROM="Bermite "' \ + 'REGISTRATION_ENABLED=false' > $(DIST)/.env.example + @echo "✔ $(DIST)/ prêt — sur le Pi : cp .env.example .env, compléter, puis ./$(APP)" + +deploy: dist + ssh $(PI_HOST) 'mkdir -p $(PI_DIR)' + rsync -av --exclude '.env' --exclude '*.db*' $(DIST)/ $(PI_HOST):$(PI_DIR)/ + ssh $(PI_HOST) 'sudo systemctl restart $(SERVICE)' + +import: + @test -n "$(MYSQL_URL)" || (echo "usage : make import MYSQL_URL=mysql://user:pass@hote/base" && exit 2) + cargo run --release --bin import_mysql --features ssr,import -- "$(MYSQL_URL)" sqlite:bermite.db + +clean: + rm -rf $(DIST) + cargo clean --target $(TARGET) diff --git a/README.md b/README.md new file mode 100644 index 0000000..cd65a28 --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +# Bermite (Rust) + +Réécriture de [lara-bermite](../../domotique/lara-bermite) (Laravel + React) en Rust : +**Axum**, **Leptos 0.8** (rendu serveur + hydratation) et **Tailwind CSS v4**, avec SQLite. + +Application de suivi de la pluviométrie et de la météo (OpenWeatherMap) : + +| URL | Page | +| --- | --- | +| `/` | cumuls mensuels de l'année et de l'an dernier, ajout d'une mesure | +| `/pluviometrie` | graphique par jour / semaine / mois / année, total, 5 dernières mesures | +| `/pluviometrie/mesures` | liste paginée, édition en place, suppression | +| `/meteo` | météo actuelle et prévisions à 5 jours (détail par tranche de 3 h) | +| `/profile` | emplacement des prévisions, thème clair / sombre, déconnexion | +| `/connexion`, `/mot-de-passe-oubliee`, `/changer-le-mot-de-passe/:token` | authentification | +| `/sinscrire` | inscription, seulement si `REGISTRATION_ENABLED=true` | + +C'est aussi une PWA installable (manifest + service worker « réseau d'abord » pour +consulter hors ligne les pages déjà vues). + +## Développement + +```sh +cp .env.example .env # puis renseigner OPEN_WEATHER_MAP_API_KEY +make dev # cargo leptos watch → http://127.0.0.1:3004 +make test # cargo test --features ssr +``` + +Sans `SMTP_HOST`, le lien de réinitialisation du mot de passe est écrit dans les logs. + +## Reprise des données de lara-bermite + +```sh +make import MYSQL_URL='mysql://utilisateur:motdepasse@127.0.0.1/lara-bermite' +``` + +Copie `users`, `locations` et `rainfalls` (identifiants conservés) dans `bermite.db`, +et refuse de s'exécuter si la base contient déjà des utilisateurs. Les mots de passe +bcrypt de Laravel restent valides ; ils sont convertis en Argon2 à la connexion suivante. + +## Déploiement sur le Raspberry Pi + +```sh +make pi # dist/ : binaire aarch64 (cargo-zigbuild) + site/ + service systemd +make deploy # rsync vers raspiweb:/home/pi/Scripts/bermite puis redémarrage +``` + +Première installation sur le Pi : copier `dist/.env.example` en `.env` et le compléter, +y placer `bermite.db` (issue de `make import`), installer `bermite.service` dans +`/etc/systemd/system/`, puis faire pointer le vhost nginx de bermite.rodev.fr vers +`127.0.0.1:3004`. + +## Organisation du code + +- `src/main.rs` — serveur Axum : base, sessions (tower-sessions en SQLite, 7 jours), routes Leptos +- `src/server.rs` — configuration, contexte, mots de passe (Argon2 + bcrypt hérité), jetons +- `src/auth.rs`, `src/rainfall.rs`, `src/weather.rs`, `src/location.rs`, `src/profile.rs` — server functions +- `src/rainfall/graph.rs` — regroupement des mesures (fonctions pures, testées) +- `src/app.rs`, `src/pages/`, `src/components.rs`, `src/ui.rs`, `src/chart.rs` — interface +- `src/bin/import_mysql.rs` — import depuis MySQL diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..b1c6784 --- /dev/null +++ b/build.rs @@ -0,0 +1,5 @@ +fn main() { + // `sqlx::migrate!()` embarque les migrations à la compilation : sans cette ligne, + // ajouter un nouveau fichier dans `migrations/` ne déclenche pas de recompilation. + println!("cargo:rerun-if-changed=migrations"); +} diff --git a/deploy/bermite.service b/deploy/bermite.service new file mode 100644 index 0000000..f64e52c --- /dev/null +++ b/deploy/bermite.service @@ -0,0 +1,25 @@ +[Unit] +Description=Bermite (serveur Leptos) +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +User=pi +Group=pi +# Le binaire lit .env et sert site/ relativement à ce dossier. +WorkingDirectory=/home/pi/Scripts/bermite +ExecStart=/home/pi/Scripts/bermite/bermite_rs +Restart=on-failure +RestartSec=5 + +# Durcissement : seul le dossier de l'application est accessible en écriture +# (pour la base SQLite). +NoNewPrivileges=true +PrivateTmp=true +ProtectSystem=strict +ProtectHome=read-only +ReadWritePaths=/home/pi/Scripts/bermite + +[Install] +WantedBy=multi-user.target diff --git a/migrations/0001_init.sql b/migrations/0001_init.sql new file mode 100644 index 0000000..fec2fc1 --- /dev/null +++ b/migrations/0001_init.sql @@ -0,0 +1,42 @@ +-- Schéma initial, repris de lara-bermite (users, locations, rainfalls, password_reset_tokens). + +CREATE TABLE users ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + email TEXT NOT NULL UNIQUE, + -- Argon2id, ou bcrypt (`$2y$…`) pour les comptes importés de Laravel pas encore reconnectés. + password_hash TEXT NOT NULL, + theme TEXT NOT NULL DEFAULT 'system', + created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE locations ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE, + latitude REAL NOT NULL, + longitude REAL NOT NULL, + created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX locations_user_id ON locations (user_id); + +CREATE TABLE rainfalls ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE, + -- Format AAAA-MM-JJ : l'ordre lexicographique est l'ordre chronologique. + date TEXT NOT NULL, + -- Hauteur d'eau en mm. + value INTEGER NOT NULL CHECK (value BETWEEN 1 AND 1000), + created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX rainfalls_user_id_date ON rainfalls (user_id, date); + +-- Un seul jeton actif par adresse ; seul son SHA-256 est stocké. +CREATE TABLE password_reset_tokens ( + email TEXT PRIMARY KEY, + token_hash TEXT NOT NULL, + created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP +); diff --git a/public/apple-touch-icon-180x180.png b/public/apple-touch-icon-180x180.png new file mode 100644 index 0000000000000000000000000000000000000000..b6f16ea66dcbba8461adda1aaa117f7edf5754df GIT binary patch literal 1270 zcmZ{kZ8#GM0LRB-UP3!GHrhy`E;}`E%eeN^HX(&}w<1N4F?ES6rV(mFEO}|_w9Q7T zPPw=+DvxtrUCqq<(hZf(%Z4q^OYC^=>)nU{%ZLB-|M<%d2_~AEKurJufEk&DKfIRp z>oNkaxryccngd`Vfnfx#Mx)c|rjo-nlM{u7?3R{RZR?}q!TuRe=H8fX57uVJXGz~D z0RTYdy7U^-4$}dE4Vh&8zOWRTYKWfn5V6s4cvxhl(?PfqB1jkB?JJPta(VEIRMnke zr1$=YXas?S$s{b#dcN6d+J9E1&L)T>2PT`M#=N&}72Cjqj?TUeYOjpD^IMmd+EfDi zcm;z%2M&Vw<2pmzuHyLMyOm&fb7<)73m2tHQpGJpcS_Bi1QkS`NT;2{*E3qb%P)io zTQR5sY8JQ_Yw3?QMMq|@I@T>Qm_VpTfZBI2$CiA3Hs{RYV!vD94B(30 zp`ATF$cpZ%lmb==T|hZu2vJsVFm9%87jyG1paBM#(Sg{hAujkwO*Z-<)`?d2h37Y@ z=T>!F6MY0f-S&L64ofT*Ru@;{YNZ8>;77U10mLlU>p)>7Q`(&OlZi)<#MtT_19gvY z6X#Yg&(N2;zvMf*?Y$hQr|w@#@)i|hN#RT-voXH25~wDaV*2ld&Zhpa}XnDzuD=+uS@mS z-v&b1Vyw2RgkNLg=R%qn1hQjINqWnB9e%eG!H$pDz&*lSURRj*%VtY`ZX#pHPV}C! z+pS0RHe$;!A}bsjkdq(h4Th^fsA)uFRe(I!5ELo*Goy<&FWd&Em8>svr{+0{npS22 zH&23qV&j{+#+&+|47YY7OWwGiZ>J8VI7d0BmgAm1FPq3;CGO{VEuNZp=&sN6kVa^I zZmN(O9daL0B)5&waRGdOYb7^cw(I)j9A;?Lzh(i|kqAsC^_B6c0rv!{ zpL!;QqDn6&sS(JCEAwRjF+=0h7xoj-7E+WCDSZ$CU)xP&x80k`3X;X`Wag)1?DNx!{ zh)bM+TO>+Uk>es&Bo9 zVYZ{eO0+>2rWuLK6TcNnvha671M^)29*?KW@AsF?cbrbAv&rFbIDylqVr_12{*cS* z{H@F7s#eS9D+T_$fwL27wH71tk9nLp+-sEz+ehCwO06HZCz@& z+smx9EoK|6;boE}tq}z2K3SIAMN#|-C6;A>2K<+g_V;rrPn4;3W|YR@dFcVP*#!Cx zK@jeeq-Z1Pojfns@I1d7Z9YFVH1y#@@FrUVR~D z(AWPWk&C+fWHz~?(P%Yzzi);A$jF80yXW4GTWOm|oA+~-0q<^^Ac%u`@X~!pg^mL( z$6&*j=RNRmDU@fi`(tjb%VslbJ>-48*!&9}kLIC@&y3uqUto_})p-nY{;v_};(p@n7zX#9Fsl;ri6V}@0#oE7;b2a-sRc&Si*-1** zM${V!AJpR2d&U`R6=XQ4r_Wrd96oD zySI*g_<}Um_yCu%b0gi)l!t$uiPtDUGBQ$zIpIWFk9YEStNO=T80)-s{Qu||FU{af z&R4^HAbi9KuUR={c+x8V2rplr9nR#BTg6Z3 z06qKzXT`}EUJ}Q*Kf^^gJj&{=F;;9ysA~C_v391}&ujk?C#K)OHH;?jA$&X++}gI7!>?MAfzFUx`+4g5NUT`+ zy+L-b7E>*ttyZWtPortW?u``%<(z5rK{Paf;gM#vy#dk^XyruD@# zw(Pcbw&B6>4Y}xCuPx3Q^{}Pa&1Aqk;C6LI#)>p&)%kG09-e&4@V!%lefoBu7q{Zv z{U^xtZ=~1o+=X`(q&*yZf24@If64EE^D6t}6&vtBTc`|}vnLt?;ZNqH=R*6C&T#JC zk+%#1w%@&pFE12Fq5Yx54M-=g%Ha)itS7)d;cHO}@+B6ETif6My^%6cFx=+B84Pj= z2C}@3Hb3_Tgyq`4^X-}J*|#~e#vS6;d4u8gz947!1=y7gGZO=xZ^5w=j$; ztx45`Ci<7BC?bqBE(1z@h=MP}l#QB8pQf8DJDEqfmDk$eNSr%G7G=FG(dNTw6Q+i4XHr-Twa6a(J2*+?*N7ysXORO z#NUf{Zq$QBu~~|%t99Uc3vhfjmA66uud8)eg5pj{6Yf@gQyrV`vS{xd(7gq$qXuA@;jK;)Wqg%ZW?-x_`Ht3^OjhPe0J&Y%PKHpV4OF{po zT7I}gu^Bd@;xiJXpz_|{-VVg(Kdm>2zq0Z=*k#eqWblWS<2woda`JPEzoT^g`0dL|8uf<~UB*hDjf&&pXDN^h=w^A4kJ-tn*pLaJ__$yq%By6wlQ9)bySyZnblN!q?VK z-&%U_ANIK~SN>+PoRfp%B>CU>zsQeo?&L0NzUlVp@rV7b0e{vi2CXknPv-7dC1c-z z=)&!K7;wkrE5LEo3I;RT36ELq0lq8KxfqYfZ^rxZnBh?UczUu^+-B=8E~?SF>gP(* z0Q;7n{Ms_iNyKQ3=QG_A(DFWUMoPp0I(KtX3vmmsywSo#wy$ z1wNjmKhTn|9(&NQjQFdu9P$INdoYJM4f#^xJJQN&^i1m&_OkPO7-0X1zspkx4h!Rk z@7c(28wmf%h-YRw_QcBM{x#bc{&`H~{NK+}_8>dt-Z*+wCLgmr?GNw`-wJyOK_5Q_ z#XUKGwJXR~L-x^}+KIzhB59_Wg;0-W*8r&^HlOIN#|H;iq043-jjc!_9u$|1A4ruul8QdsdLig z;iKZEdmrV7oNauCItJuwf(#cj$58iD^*pidY3v(&Dn%>(kdCyobBA7^wfBU*?U@i|4ic>6zXO1TW9@#!*jo|RBdlY>F$I#FuEBrl)qx#{Tt3h5BtBPTyNGV km%5~{lVqPsJ#dw_Q^J4qQR=b5UyCH9l7cejShD^90nDrM + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/images/icons/01d.svg b/public/images/icons/01d.svg new file mode 100644 index 0000000..56cdf58 --- /dev/null +++ b/public/images/icons/01d.svg @@ -0,0 +1,45 @@ + + + + + + diff --git a/public/images/icons/02d.svg b/public/images/icons/02d.svg new file mode 100644 index 0000000..812edb3 --- /dev/null +++ b/public/images/icons/02d.svg @@ -0,0 +1,55 @@ + + + + + + + + + diff --git a/public/images/icons/03d.svg b/public/images/icons/03d.svg new file mode 100644 index 0000000..354d262 --- /dev/null +++ b/public/images/icons/03d.svg @@ -0,0 +1,48 @@ + + + + + + + + diff --git a/public/images/icons/03n.svg b/public/images/icons/03n.svg new file mode 100644 index 0000000..354d262 --- /dev/null +++ b/public/images/icons/03n.svg @@ -0,0 +1,48 @@ + + + + + + + + diff --git a/public/images/icons/04d.svg b/public/images/icons/04d.svg new file mode 100644 index 0000000..fcf1c89 --- /dev/null +++ b/public/images/icons/04d.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + diff --git a/public/images/icons/09d.svg b/public/images/icons/09d.svg new file mode 100644 index 0000000..8b572da --- /dev/null +++ b/public/images/icons/09d.svg @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/images/icons/10d.svg b/public/images/icons/10d.svg new file mode 100644 index 0000000..c04e441 --- /dev/null +++ b/public/images/icons/10d.svg @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/images/icons/weather.svg b/public/images/icons/weather.svg new file mode 100644 index 0000000..e54e563 --- /dev/null +++ b/public/images/icons/weather.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest new file mode 100644 index 0000000..99ed390 --- /dev/null +++ b/public/manifest.webmanifest @@ -0,0 +1,18 @@ +{ + "name": "Bermite", + "short_name": "Bermite", + "description": "Application de suivi météo et de pluviométrie", + "lang": "fr", + "id": "/", + "start_url": "/", + "scope": "/", + "display": "standalone", + "theme_color": "#1d4ed8", + "background_color": "#ffffff", + "icons": [ + { "src": "/pwa-64x64.png", "sizes": "64x64", "type": "image/png" }, + { "src": "/pwa-192x192.png", "sizes": "192x192", "type": "image/png" }, + { "src": "/pwa-512x512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" }, + { "src": "/maskable-icon-512x512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" } + ] +} diff --git a/public/maskable-icon-512x512.png b/public/maskable-icon-512x512.png new file mode 100644 index 0000000000000000000000000000000000000000..c017f022d6bf99d91ad16b40f6d5c77e8ea78c4a GIT binary patch literal 2871 zcmd5;c~q0v5})t;LN;WRMFb&HmWms31qID#iwc!WR4S+}skPGQf|Mcz0duuJ(E>u% zs(tzhuBcU@s4ODn^Pm+y$3oq(EGCG`ssu?05|jHr-{0@NzkAQQ^P9WOoS8dw=FS1x zie)xJHz5GngoTEz0w7tI1U|(={dw;O7Mx|_kxSkU4q}Y^QzGB>_2%W~)z{a*D?jzm z;+{S11wm5i+V26V?vInWp0R2RfUqGfWO1aTl_u-?5=0!Rd6;Qy@vMjZd2O*faPhe5$5V`pIDqE~lu`Vo?O z=ymnOmG=?0LYR6~sWw##g|Pe!Gw;4~i9MX%rnIHtak!-z|9q;Mgp#0{ z)@*bJ8e3|FAV-!AmhQC#3HiY&`MQ4nf1TWXV$oLnD``SUjp0nXSg||=<5u9*4v1j82Yg%Q@4yhQ8A9I8-4M@mI z@g^ldc%g%2HX2d-eG?83#_bMWi~Wgg2gy_vcm}VuasoHKNG;L@dlOJnDlHTZW}Oug zKb2!e*8PlO2m5;_(MpD3t{c=mS#mxK)nH^o6k2Y=Ag2kq)~}=qD`aiLV~V^ziBq`E zOZ?D)1K@zh-HFRI4txlD_}pm>B{uT+Z#82NM&SkMsM#)%6v8%QLRd2jeTt94=MU$K z^{NaT5Wjb`uO7u*nh+bH;f8=u$sf-xf+iRGkGX9A>!sapKz|KBoxb8(2I+X#lHb7= zlBvmXxgBqWLin}~f4hZ-CRh4inj0{Tmv|uxwbeq=Ttw1|@O5pFD;jnzg0e*XCG2bA z9tRJ|^=3HTgj`HQN{?~^OC4ngDfAdN?41vErRA2z>{96!l(CSFIje(Q>2LbpfgYsd&DMH>A~DcLwv@}rpkR^ zG~qcl%sC|xA2Xd(AUuVZFvT*{`ix~qt$vGna1jJRO zdjG6780M%5rHHH@<;m@d)`u{OKN3f8^`$3)ilfhzaO5ugGtAz7$X-XOTJ>()k|@cZh}!+MFn^ z*lKra{5Ztn)@7`OH33Oo&W9m-Df2adN}LT^;{3R-z(+oxn_s(EP!Pt;x&Rqw7p?UKTUBOLVu0}__$csQ%aj0O@%MNeVK0fnd4zp| z2b0=ycaC04p&ZVUEdNmz$@q}NqCc@WR19U~MoW$*fhdcW;W;o5RygZo@U*E6m$}G^ z>s4)pt#Hy$d)*SoWw(CeJRer~DHlMipm^8nE8q?ZV-;y126|Ov87!9hy0bgQZVC+^ z`KW2GY!S$C8+Zmtp1?B*bidUwl^GsVZR>x^v(lN2>6y^~uQ(pIwTES{1YKupP{nk;9e2B*;O9^tGd!~B}xC$spN@w6q?l4PA6-W zaL8!KB>UMJ)Kpo^t=gzq;K={#h@0XM-U|iM6PUP_J*}4Q1he@>%>@l?Y@=q_$V)Hk zV{s5neS^0g?D0VJOWO)}qz%Mkfe{_9^SQj~w~__tJC9~sOT19+<~7Y8k9lwPT7ASSK*(~-oAX7vwR+$E5CGM(Rt%bNuTDbArn`jPDw<*}fL;#hV#YGXMAEN! zPPh9&o99|0aSeI`w?Bb%$?GPk3BaT-0WNbIHa8L}HIvcm?NsRH6ldK7#xfXeH)&iT8uRRtI>Y{{gQxa#Bl6xmU6`513LG%={YgEtNS?-?Z^x?zHgr%&^9N|kxsv;?#-iM8dqE0 z++tTimN_A5r?S)&N;v*j+6V8HUD_GX1FOVHu^L;AH%g$M$^wsx_C0<}jAm+R~eL-QM!)VA^6%Ta%h^ADtpl)Y?oqvHiyt z3Kw0ndy(Y_-wNo9;VI?|CVNQ#!J(T2NF4fLwmOyc3k%$7SGXtosl#v9U#g#y z@#dM3Q|x5O`1}ytM}am1{(e0kTf8is|J`>soPKYo44o%gk?`#aU`N=J6(J>`%J=*S D{P$)5 literal 0 HcmV?d00001 diff --git a/public/offline.html b/public/offline.html new file mode 100644 index 0000000..9103f76 --- /dev/null +++ b/public/offline.html @@ -0,0 +1,21 @@ + + + + + + Bermite — hors ligne + + + +
Bermite
+
+

Vous êtes hors ligne et cette page n'a pas encore été consultée.

+

Réessayer

+
+ + diff --git a/public/pwa-192x192.png b/public/pwa-192x192.png new file mode 100644 index 0000000000000000000000000000000000000000..2805e34a0686ff1de9b1ac1b77c5750dc5ecdcad GIT binary patch literal 1503 zcmZXUdpOg30LH(+-|WIRXCc+7wiC-aAtfTRsb!;Khn3WEOHNaWC`yi>OD7dk%B2#e z5Yp;MH3y&F%*gQTuGS|u?Hp?P6 z%X&KH=|WkA$5?6hSba@f+avuWo=$Tk25~-KzUn}3=GByCK&5T+Eu2=jPfX?={i}bj z)s5!*#{z&E`eEo!qR(Ccu-5KuS3$x%d2eKH)vqKV0S2QxZp_Rwzx9lKly4QF?AFDr zrLBd%a^4a{fsxhO@H-2cR*+56HMc;WfFrX;t%Ix+)B%Np*N?laLK-7+b`_97WA zl9jJp;{yc_ADhS8IYm!5gkD%#Za2cBT4U2J8Y}kX@vWqihDV#SSA!X=byNsA=giiC ztJ0>m6xI=~lO51#_7Pdi$*%@rK&F%b<;*uXgC|5**a&s7BC91$yi%+}enLi?x|l5$ z!})6~g@=Gbwi{zWM&u#UItb3bwKh(3(|(@l8q;lpW>nh-?p$yYY_a<=ti#nssr6t> z{BCPkQ_yUi>;s*F>c@+rE#e)pBz(4SS{#FJhb8Z{O~}Yg|5O5NaRD<#mkSuRAl+O@ z0GG&WyfRoumxPxvHHM0eQy2jo+LlO2&{JX;P97#CxSns5CIeNFdPR&`9B*=BcuwE;`C}a1oEK z#MX1ZeExGWN&#hmJP7LCAV97cT`}4ZPKRzVrtN%drcXJX6Qu*EzErc}4f?Ndm3Lu#dFF&-!_t%r0*3UvpSge>jVn3PR8O=V#uF8$3+hP78rG9*o2oyt z(X{D)YxoI9t<8TsAHAN6SCREoryaq^y9E@{HF0I2 ziPuw7zhEbZzS^^rbWRzPT3;RLwQ=6MdkSigl)$K#x3mEwEFfOAoq3%6v@mrPd(zH2 z61~D)1}W{t!yEGg-q1EG{dGwGlX^5SO09aKYo~5j5CK?2%XE%S|ZF((y>R-G@&WkiXz%P z`JHmKptqttL}kRaVKw{z)_hQL+A3}dx}pWLAW~G$G2>v_FS8l3bpJGz4Q#Hjl08`M zM}*l8-K=X}uGJHGuO9r350~95fFf}h<6P3vNWimo=WyFG!9{J>ai87dGfENz?Ll20 zwd>wd198YA(Sh6K(&=R9Xl z5!&vthl4z?ludj3Go~6l79mgJGGm{xck`7|v=xSu;$*tA=;5=3iEQf=SA(d|gZq4O znVRL~gn^(T0cdZ9joqQV8$M=O(ZTzeB+kz_t?!<+T5m_`Tj&B_y*WJ#mlQf#P?7em z882f)sAp$bXnqtT%5{{#s~l1sXy1WYAc<8qVS5~pMH{i4;w?M913FD!+?xpnvD!Y9 z3y1c(<0qfa5=#o>?c>0AOmvZrna#BimWZdWq>{)0A_YBSB^6R3w#x%dk%2=wjk~^! z;riU})%aWS+qY#n>kG%^kyzNHtIF2&p+&yu(0ft!ox`h&z410tS}e-Y5slsJ?*ZwW z_cP(;d~}7T|6!VliwpK6=HOV~@B1E<2@7B}03^L8NgY5hR`e7M>IvWa7hCx*!cdF+ zx(~DjRfl_@{|6(@GA~m5UAXdidf@h=9Oyrq-HkF+R9oMa#ncAP-6?S2v=FB-WbI<%J3SVr_ zvSk4P%)bc_(bA}(rJJ_u-oNil3f1-XE)EU}SsZffMoVQz z())Msh6V@wla|cU?5Q%EO;eYLM}m>}hBLVa@0#_+*462*MwyusvT8d3=-YoftlznO zi_u#DP2g8ina>6~2ewrNbAs2c!_X^~X`!&IpnpXYw7ioltehu2e4!xf+7E*XUStnu zTQ=$UygZSTdmP-FqdJoZy9bo zYw$NC3k18_mv6p$(2e&Vp|Yl?5>~CXX6yeq&gBSce?-9dk@EZZhF&w`EY1|lkWI7n z*#UfIyS@Mkm+mHeY8mSt3|v^LaFTzyI$30>hp)wUMT&Vvzv;K2xkh8Rw~p0X z$cIXZ)Jmh_6*s4AL_7`WqO)}3V^SVkUQFCiTWHGpgZSyAVh-g>=Z@A+lt&}my7_+) zPShjhz!JPypT`qv6|0H0Oyw!*0ZYx8^f$1CY)M^gs&{X53()f?dZ1d zT9ZH{w~{UVA*qBG;UY;==^OXtWPV3rN^zKA)v8n@Vij3kg+WCRlslin%p zkmpa=5K;7pO(vbo4uQ10#D+!lKHFlvUs>;Lv!hLSpSBeJWfrsS^IuritB#?~ z&S4Xpd`7n)BSLGgUT27&GCb4lA$tI}89KfugY?Zb*DjSmw$acWo#zoQMSRAsOhqRR z=NoBjwBkw-FM;O@!6Sx%>e!j*(ZU~HLOcs5o1O76M5$Pb-Yl}0H|r}*MOtw+j3*KG zw}xM6t~%9t6{B5hTw14^iN7`RyPQn&lCYBu(J4SDPnhpt0Zz0DFBtg+b4D7|GtI0j z99T(`VSXri#e9D%)5l8g3-j5cW_T!@-p>$~fo$4^PU4=5Y&PeKZ$@8NBqk?q<0}J+ zThHgmga;Ex&7VAT%(sKj=1cO>bflFdsYm}jC0S<{Q$Y@XLTHxq0My!p7x%lOf7&Uy zyE6k-VO8fXxJaOvCYhFB2{CVZ?Z>TxHLb+ze9}>cI^q8GOoyl>G;6}1csxyoo%W?a zyhmpngDV8C_R<{Io_%3f#;X%Gj8v(@1O_XX%|@7Cd>m9hpaAY>fc4S z5;w3a0p)@`+=MT%5c~=|mlAhashBc}{M+WlW{&)J;F{44dwAIP-Dn!4C^APVPMC@Z zpf%S`p`}~Oc-T~A{aj6-jUzsXW*Bq8lxN6-@4q7aSRH!yUa*SWG;W@NXhj-okqk`Y zet!9Y$r0!9g=L_{{_{W{lk+U+g)pswFSv+i?A8VnrRo1V<(YaEKNXfZuJ6MZ^^%O_K)B@t)dZD z=;w;f3*#MN_%ym+te=FrRvs<=SRl+cM8=K|iLkNRN5F&g3vONhyN53(=)=-v3*Kwl z6~=*PtTf`TZZhp=9O8A7ishGTWn1*pD@eQ>JQoQZo-xLvMpcypzZ$dkZeZXT)i=je z=uX}1d2s+ef)ovpNMk%gMBrS;n^Er3nR^8%fNYau*{$go!+v4MeaTe&4_h9e|K0Gj z^|j5OLDRv5_9Edn>ycAV*Q!%u_f=P9IaAfI#yuW{9W@y(Q7n4nzjk!c{gyclEZUUP zZzWJ)7o;mI(e)#XzV5&y5=2(G>n`WPNDjnRZvB{MpPSrX&>ng>7L zQJiF^Tu7Rd(ydpmoZM@Rd~B0}v=X9ocp7fM)Fh5lbW79wtDi2sG~Apy72ixplro@e zG%H#tMO;)e@Yk@B`$-XPMO^oglVFDd+qg*e-Dnvs6Urj0tqCS)&spzXpQjR&>OSaI zWx8qjuubZXeULQcX>zllcmj@q%x$YX3rpeOVzql23&0a%_4HVlv0$8bDvU-lL}B{S zA+_7>Et&UVZ-I2HwY$?~hG^I;`ti)SJZQ<@-o7f?io91_KIYL@elcI|hCeFXzH-*v z(+y@hzPSI+x%<+NZ7;LVok-+=d}F>asb>ZY|1I{{TMn_lCeD(xvD`TH5i?b1!2V}6*Dp!5 zug}`R8@4;W2p{B$sw|dR@hNX3Sck<7@Av4YrnmX3bpzMFe%j|4n0Xy+P;pii_F_*y zoSe*1_YX)8j;10}^Dy?p+5ijrEV%Ci-@P!=gErx6BR?AcC~o)R$ZMv0_J2uv`R#aJ zjjdba-RLQE6h2_N8)fzLfV-wouf< z9lbd^5V0x-FgU#<3Mp1sAb8$G8C3UWat7z+h*0Y0Ipg`#B?P0A>SBwMTn>~_qr<8$ zv4E-8k7Qi00S%UwCk+&rxRhy%z!Q9`&3Fy=lDue2<}~9)p4O+q&u~gnLR{KqcLAOB zQZE*R8K~C_sy39=AvnS76W+)T0vW}vN=l!>jM?hUf`}QA(d3!u_9Jy8i@3<;G?x3GST>co)SHlM105fOHurSILZGY#-7Csk?h-i(#Bl!A zuNdkk&_^foWWhO!=CGO{5=b;u5(kGB7o|=mY_)+WYVbRJCnsqvUFSW&xDT8TDn~gu zd>6Oe3LmqSLv6Oxaebut>wNxyeyxp$*7p+@+_{pxzBq2?KlX2e!UJmpB)R_w6+<&r literal 0 HcmV?d00001 diff --git a/public/pwa-64x64.png b/public/pwa-64x64.png new file mode 100644 index 0000000000000000000000000000000000000000..bcdbaf414cb286c428194fc5f1c5aa0381f3847d GIT binary patch literal 620 zcmV-y0+aoTP)RV>ugK%?CS2BgYWL{>}*Q%@$u|!OYraS>}*T&@$v54 z*6eXm@4T}^Z!glLt8ACCY402*{sPE!CZeWDOmPWAEr^?=l&GU!vh z{i^!@A<}E~HMD>Y00009a7bBm000B%000B%0kwNlYXATNo=HSORCwC$mdlcZAP_|b zk%wqBB5MBsM<;X!A-W3p2tW;E{kQ~hkZS-Hu0+rS zqIG*1f=?Kd%S?{JV;LM*!lc@NriT86KLuzK`vVecYyv)E7{}K%O=^0nK0YaR { + event.waitUntil( + caches.open(CACHE) + // Un fichier manquant ne doit pas empêcher l'installation. + .then((cache) => Promise.allSettled(PRECACHE.map((url) => cache.add(url)))) + .then(() => self.skipWaiting()), + ); +}); + +self.addEventListener('activate', (event) => { + event.waitUntil( + caches.keys() + .then((keys) => Promise.all(keys.filter((key) => key !== CACHE).map((key) => caches.delete(key)))) + .then(() => self.clients.claim()), + ); +}); + +self.addEventListener('fetch', (event) => { + const request = event.request; + const url = new URL(request.url); + if (request.method !== 'GET' || url.origin !== self.location.origin || url.pathname.startsWith('/api/')) { + return; + } + + event.respondWith( + fetch(request) + .then((response) => { + if (response.ok && !response.redirected) { + const copy = response.clone(); + caches.open(CACHE).then((cache) => cache.put(request, copy)); + } + return response; + }) + .catch(async () => { + const cached = await caches.match(request); + if (cached) return cached; + if (request.mode === 'navigate') return caches.match('/offline.html'); + return Response.error(); + }), + ); +}); diff --git a/src/app.rs b/src/app.rs new file mode 100644 index 0000000..1b2979f --- /dev/null +++ b/src/app.rs @@ -0,0 +1,282 @@ +use crate::{ + auth::{self, Login, Logout, Register, ResetPassword, User}, + icons::{Icon, IconName}, + location::SaveLocation, + pages::{ + auth::{ForgotPasswordPage, LoginPage, RegisterPage, ResetPasswordPage}, + home::HomePage, + profile::ProfilePage, + rainfall::{RainfallGraphPage, RainfallIndexPage}, + weather::WeatherPage, + }, + profile::UpdateTheme, + ui::Loading, +}; +use leptos::prelude::*; +use leptos_meta::{Html, Meta, MetaTags, Stylesheet, Title, provide_meta_context}; +use leptos_router::{ + SsrMode, + components::{A, Redirect, Route, Router, Routes}, + path, +}; + +pub fn shell(options: LeptosOptions) -> impl IntoView { + view! { + + + + + + + + + + + + + + + + + // Service worker : mise en cache pour l'usage hors ligne (voir public/sw.js). + + + + + + + } +} + +/// Utilisateur courant, partagé par l'en-tête et les pages. Rechargé après chaque +/// connexion, déconnexion ou modification du profil. +#[derive(Clone, Copy)] +pub struct CurrentUser(pub Resource, ServerFnError>>); + +#[component] +pub fn App() -> impl IntoView { + provide_meta_context(); + + let login = ServerAction::::new(); + let logout = ServerAction::::new(); + let register = ServerAction::::new(); + let reset = ServerAction::::new(); + let save_location = ServerAction::::new(); + let update_theme = ServerAction::::new(); + + let user = Resource::new( + move || { + ( + login.version().get(), + logout.version().get(), + register.version().get(), + save_location.version().get(), + update_theme.version().get(), + ) + }, + |_| auth::get_user(), + ); + provide_context(CurrentUser(user)); + + // Apparence choisie dans le profil, posée sur `` (sans attribut : suit le système). + let theme = move || { + user.get() + .and_then(Result::ok) + .flatten() + .and_then(|user| user.theme.html_attr()) + }; + + view! { + + + <Meta name="color-scheme" content="light dark" /> + // Sous un `Transition` : le serveur attend l'utilisateur avant de rendre `<html>`, + // ce qui évite un éclair de mauvais thème. + <Transition> + <Html {..} data-theme=theme /> + </Transition> + + <Router> + <Header /> + // Marge basse sur mobile : la barre d'onglets est fixée en bas de l'écran. + <main class="pb-24 sm:pb-0"> + <Routes fallback=|| view! { <p class="m-5">"Page introuvable."</p> }> + <Route path=path!("/") view=HomePage ssr=SsrMode::Async /> + <Route + path=path!("/connexion") + view=move || view! { <LoginPage login /> } + ssr=SsrMode::Async + /> + <Route + path=path!("/sinscrire") + view=move || view! { <RegisterPage register /> } + ssr=SsrMode::Async + /> + <Route path=path!("/mot-de-passe-oubliee") view=ForgotPasswordPage ssr=SsrMode::Async /> + <Route + path=path!("/changer-le-mot-de-passe/:token") + view=move || view! { <ResetPasswordPage reset /> } + ssr=SsrMode::Async + /> + <Route + path=path!("/profile") + view=move || view! { <ProfilePage logout save_location update_theme /> } + ssr=SsrMode::Async + /> + <Route path=path!("/meteo") view=WeatherPage ssr=SsrMode::Async /> + <Route path=path!("/pluviometrie") view=RainfallGraphPage ssr=SsrMode::Async /> + <Route path=path!("/pluviometrie/mesures") view=RainfallIndexPage ssr=SsrMode::Async /> + </Routes> + </main> + <TabBar /> + </Router> + } +} + +/// Liens de navigation principaux : (adresse, libellé, icône, correspondance exacte). +const NAV: [(&str, &str, IconName, bool); 3] = [ + ("/", "Accueil", IconName::Home, true), + ("/pluviometrie", "Pluviométrie", IconName::CloudRain, false), + ("/meteo", "Météo", IconName::CloudSun, false), +]; + +#[component] +fn Header() -> impl IntoView { + let CurrentUser(user) = expect_context(); + + view! { + <header class="sticky top-0 z-20 border-b border-slate-200 bg-white/80 backdrop-blur dark:border-slate-800 dark:bg-slate-900/80"> + <div class="mx-auto flex h-16 max-w-5xl items-center justify-between gap-4 px-4 sm:px-6"> + <A href="/" attr:class="flex items-center gap-2.5 font-bold tracking-tight"> + <img src="/favicon.svg" alt="" width="32" height="32" class="size-8" /> + <span class="text-lg">"Bermite"</span> + </A> + <Transition> + {move || { + user.get() + .map(|user| match user { + Ok(Some(user)) => { + let initial = user + .name + .chars() + .next() + .map(|c| c.to_uppercase().to_string()) + .unwrap_or_default(); + view! { + // Le lien actif reçoit `aria-current="page"` du routeur. + <nav class="hidden items-center gap-1 sm:flex" aria-label="Navigation principale"> + {NAV + .into_iter() + .map(|(href, label, icon, exact)| { + view! { + <A + href=href + exact=exact + attr:class="flex items-center gap-2 rounded-full px-3.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 aria-[current=page]:bg-blue-50 aria-[current=page]:text-blue-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white dark:aria-[current=page]:bg-blue-500/15 dark:aria-[current=page]:text-blue-300" + > + <Icon icon class="size-4" /> + {label} + </A> + } + }) + .collect_view()} + </nav> + <A + href="/profile" + attr:class="flex items-center gap-2 rounded-full py-1 pr-1 pl-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 aria-[current=page]:bg-slate-100 dark:text-slate-200 dark:hover:bg-slate-800 dark:aria-[current=page]:bg-slate-800" + attr:title="Mon profil" + > + <span class="hidden max-w-32 truncate sm:inline">{user.name}</span> + <span class="flex size-8 items-center justify-center rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 font-semibold text-white"> + {initial} + </span> + </A> + } + .into_any() + } + _ => { + view! { + <A href="/connexion" attr:class="btn-ghost"> + "Connexion" + </A> + } + .into_any() + } + }) + }} + </Transition> + </div> + </header> + } +} + +/// Barre d'onglets en bas de l'écran, sur mobile, pour un utilisateur connecté. +#[component] +fn TabBar() -> impl IntoView { + let CurrentUser(user) = expect_context(); + let tabs = NAV + .into_iter() + .chain([("/profile", "Profil", IconName::User, false)]) + .collect::<Vec<_>>(); + view! { + <Transition> + {move || { + matches!(user.get(), Some(Ok(Some(_)))) + .then(|| { + view! { + <nav + class="fixed inset-x-0 bottom-0 z-20 border-t border-slate-200 bg-white/90 pb-[env(safe-area-inset-bottom)] backdrop-blur sm:hidden dark:border-slate-800 dark:bg-slate-900/90" + aria-label="Navigation principale" + > + <div class="grid grid-cols-4"> + {tabs + .clone() + .into_iter() + .map(|(href, label, icon, exact)| { + view! { + <A + href=href + exact=exact + attr:class="flex flex-col items-center gap-1 py-2.5 text-[11px] font-medium text-slate-500 transition aria-[current=page]:text-blue-600 dark:text-slate-400 dark:aria-[current=page]:text-blue-400" + > + <Icon icon class="size-6" /> + {label} + </A> + } + }) + .collect_view()} + </div> + </nav> + } + }) + }} + </Transition> + } +} + +/// N'affiche `render` que pour un utilisateur connecté ; redirige sinon vers /connexion. +/// +/// L'utilisateur est rechargé par la page elle-même : juste après une connexion, la +/// ressource globale de l'en-tête peut encore être périmée. +#[component] +pub fn Protected<F, V>(render: F) -> impl IntoView +where + F: Fn(User) -> V + Send + Sync + 'static, + V: IntoView + 'static, +{ + let user = Resource::new(|| (), |_| auth::get_user()); + view! { + <Suspense fallback=|| view! { <div class="mx-auto max-w-5xl px-4 py-8 sm:px-6"><Loading height="h-64" /></div> }> + {move || { + user.get() + .map(|user| match user { + Ok(Some(user)) => render(user).into_any(), + // Au rendu serveur, `Redirect` répond par un vrai 302 aux navigateurs. + _ => view! { <Redirect path="/connexion" /> }.into_any(), + }) + }} + </Suspense> + } +} diff --git a/src/auth.rs b/src/auth.rs new file mode 100644 index 0000000..8f2cdd6 --- /dev/null +++ b/src/auth.rs @@ -0,0 +1,390 @@ +//! Authentification : utilisateur courant, connexion, mot de passe oublié, inscription. +//! +//! Les corps des `#[server]` ne sont compilés que côté serveur ; le client +//! n'en garde que la signature (un appel HTTP généré par la macro). + +use leptos::prelude::*; +use serde::{Deserialize, Serialize}; + +use crate::{errors::field_error, location::Location, profile::Theme}; +#[cfg(feature = "ssr")] +use crate::{ + mail, + server::{self, USER_ID_KEY}, +}; + +/// Utilisateur connecté, tel qu'exposé au front (jamais de hash de mot de passe ici). +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct User { + pub id: i64, + pub name: String, + pub email: String, + pub theme: Theme, + pub locations: Vec<Location>, +} + +impl User { + pub fn has_location(&self) -> bool { + !self.locations.is_empty() + } +} + +pub const PASSWORD_MAX: usize = 128; +pub const EMAIL_MAX: usize = 254; +/// Durée de validité d'un lien de réinitialisation. +pub const RESET_TOKEN_HOURS: i64 = 24; + +/// Met l'adresse en forme canonique : sans espaces autour, en minuscules. +pub fn normalize_email(email: &str) -> String { + email.trim().to_lowercase() +} + +/// Validation pragmatique (pas la RFC complète) d'une adresse déjà normalisée. +pub fn validate_email(email: &str) -> Result<(), &'static str> { + const INVALID: &str = "Adresse e-mail invalide."; + if email.len() > EMAIL_MAX { + return Err(INVALID); + } + let Some((local, domain)) = email.split_once('@') else { + return Err(INVALID); + }; + let local_ok = !local.is_empty() + && local + .chars() + .all(|c| !c.is_whitespace() && !c.is_control() && !"@<>()[],;:\\\"".contains(c)); + let domain_ok = domain.contains('.') + && domain.split('.').all(|label| { + !label.is_empty() && label.chars().all(|c| c.is_ascii_alphanumeric() || c == '-') + }); + if local_ok && domain_ok { + Ok(()) + } else { + Err(INVALID) + } +} + +/// Même règle que lara-bermite : au moins 8 caractères dont une majuscule, +/// une minuscule et un chiffre. +pub fn validate_password(password: &str) -> Result<(), &'static str> { + const RULES: &str = "Le mot de passe doit contenir au moins 8 caractères, dont une majuscule, une minuscule et un chiffre."; + let len = password.chars().count(); + if len > PASSWORD_MAX { + return Err("Le mot de passe doit faire au plus 128 caractères."); + } + let ok = len >= 8 + && password.chars().any(|c| c.is_uppercase()) + && password.chars().any(|c| c.is_lowercase()) + && password.chars().any(|c| c.is_ascii_digit()); + if ok { Ok(()) } else { Err(RULES) } +} + +/// Valide un nouveau mot de passe et sa confirmation (réinitialisation, inscription). +pub fn validate_new_password(password: &str, confirmation: &str) -> Result<(), ServerFnError> { + validate_password(password).map_err(|e| field_error("password", e))?; + if password != confirmation { + return Err(field_error( + "password_confirmation", + "La confirmation ne correspond pas au mot de passe.", + )); + } + Ok(()) +} + +/// Renvoie l'utilisateur connecté, ou `None` s'il n'y a pas de session valide. +#[server] +pub async fn get_user() -> Result<Option<User>, ServerFnError> { + let session = server::session().await?; + let Some(user_id) = session + .get::<i64>(USER_ID_KEY) + .await + .map_err(server::internal_error)? + else { + return Ok(None); + }; + + let pool = server::pool()?; + let row = sqlx::query_as::<_, (i64, String, String, String)>( + "SELECT id, name, email, theme FROM users WHERE id = ?1", + ) + .bind(user_id) + .fetch_optional(&pool) + .await + .map_err(server::internal_error)?; + + let Some((id, name, email, theme)) = row else { + // L'utilisateur a été supprimé : on invalide la session orpheline. + session.flush().await.map_err(server::internal_error)?; + return Ok(None); + }; + + let locations = crate::location::user_locations(&pool, id).await?; + Ok(Some(User { + id, + name, + email, + theme: Theme::parse(&theme).unwrap_or_default(), + locations, + })) +} + +/// Connecte l'utilisateur si les identifiants sont corrects. +#[server] +pub async fn login(email: String, password: String) -> Result<(), ServerFnError> { + // Message identique pour « compte inconnu » et « mauvais mot de passe ». + const INVALID: &str = "Ces identifiants ne correspondent à aucun compte."; + + if password.chars().count() > PASSWORD_MAX { + return Err(ServerFnError::new(INVALID)); + } + + let pool = server::pool()?; + let row = + sqlx::query_as::<_, (i64, String)>("SELECT id, password_hash FROM users WHERE email = ?1") + .bind(normalize_email(&email)) + .fetch_optional(&pool) + .await + .map_err(server::internal_error)?; + + let user_id = row.as_ref().map(|(id, _)| *id); + let stored_hash = row.map(|(_, hash)| hash); + let legacy = stored_hash.as_deref().is_some_and(server::is_legacy_hash); + if !server::verify_password(password.clone(), stored_hash).await { + return Err(ServerFnError::new(INVALID)); + } + // `verify_password` ne renvoie `true` que si l'utilisateur existe. + let user_id = user_id.expect("utilisateur existant"); + + // Compte importé de Laravel : on remplace le hash bcrypt par un hash Argon2. + if legacy { + let hash = server::hash_password(password).await?; + sqlx::query( + "UPDATE users SET password_hash = ?1, updated_at = CURRENT_TIMESTAMP WHERE id = ?2", + ) + .bind(hash) + .bind(user_id) + .execute(&pool) + .await + .map_err(server::internal_error)?; + } + + start_session(user_id).await?; + leptos_axum::redirect("/"); + Ok(()) +} + +/// Déconnecte l'utilisateur et détruit sa session. +#[server] +pub async fn logout() -> Result<(), ServerFnError> { + server::session() + .await? + .flush() + .await + .map_err(server::internal_error)?; + leptos_axum::redirect("/connexion"); + Ok(()) +} + +/// Envoie un lien de réinitialisation si l'adresse correspond à un compte. +/// +/// La réponse est la même que l'adresse existe ou non, et l'e-mail part en tâche de fond : +/// ni le message ni le temps de réponse ne révèlent quels comptes existent. +#[server] +pub async fn forgot_password(email: String) -> Result<(), ServerFnError> { + let email = normalize_email(&email); + validate_email(&email).map_err(|e| field_error("email", e))?; + + let pool = server::pool()?; + let exists = sqlx::query_scalar::<_, i64>("SELECT id FROM users WHERE email = ?1") + .bind(&email) + .fetch_optional(&pool) + .await + .map_err(server::internal_error)? + .is_some(); + if !exists { + return Ok(()); + } + + let token = server::random_token(); + sqlx::query( + "INSERT INTO password_reset_tokens (email, token_hash, created_at) \ + VALUES (?1, ?2, CURRENT_TIMESTAMP) \ + ON CONFLICT (email) DO UPDATE SET token_hash = excluded.token_hash, created_at = excluded.created_at", + ) + .bind(&email) + .bind(server::token_hash(&token)) + .execute(&pool) + .await + .map_err(server::internal_error)?; + + let config = server::config()?; + let link = format!("{}/changer-le-mot-de-passe/{token}", config.app_url); + tokio::spawn(async move { + if let Err(e) = mail::send_reset_link(&config, &email, &link).await { + leptos::logging::error!("envoi du lien de réinitialisation impossible : {e}"); + } + }); + Ok(()) +} + +/// Change le mot de passe à partir d'un lien de réinitialisation valide. +#[server] +pub async fn reset_password( + token: String, + email: String, + password: String, + password_confirmation: String, +) -> Result<(), ServerFnError> { + const INVALID: &str = "Ce lien de réinitialisation est invalide ou a expiré."; + + let email = normalize_email(&email); + validate_email(&email).map_err(|e| field_error("email", e))?; + validate_new_password(&password, &password_confirmation)?; + + let pool = server::pool()?; + let valid = sqlx::query_scalar::<_, i64>( + "SELECT 1 FROM password_reset_tokens \ + WHERE email = ?1 AND token_hash = ?2 AND created_at > datetime('now', ?3)", + ) + .bind(&email) + .bind(server::token_hash(&token)) + .bind(format!("-{RESET_TOKEN_HOURS} hours")) + .fetch_optional(&pool) + .await + .map_err(server::internal_error)? + .is_some(); + if !valid { + return Err(ServerFnError::new(INVALID)); + } + + let hash = server::hash_password(password).await?; + let mut tx = pool.begin().await.map_err(server::internal_error)?; + sqlx::query( + "UPDATE users SET password_hash = ?1, updated_at = CURRENT_TIMESTAMP WHERE email = ?2", + ) + .bind(hash) + .bind(&email) + .execute(&mut *tx) + .await + .map_err(server::internal_error)?; + sqlx::query("DELETE FROM password_reset_tokens WHERE email = ?1") + .bind(&email) + .execute(&mut *tx) + .await + .map_err(server::internal_error)?; + tx.commit().await.map_err(server::internal_error)?; + + leptos_axum::redirect("/connexion"); + Ok(()) +} + +/// Les inscriptions sont-elles ouvertes (`REGISTRATION_ENABLED=true`) ? +#[server] +pub async fn registration_open() -> Result<bool, ServerFnError> { + Ok(server::config()?.registration_enabled) +} + +/// Crée un compte puis connecte l'utilisateur. Refusé si les inscriptions sont fermées. +#[server] +pub async fn register( + name: String, + email: String, + password: String, + password_confirmation: String, +) -> Result<(), ServerFnError> { + if !server::config()?.registration_enabled { + return Err(ServerFnError::new("Les inscriptions ne sont pas ouvertes.")); + } + let name = name.trim().to_string(); + if !(3..=100).contains(&name.chars().count()) { + return Err(field_error( + "name", + "Le nom doit faire entre 3 et 100 caractères.", + )); + } + let email = normalize_email(&email); + validate_email(&email).map_err(|e| field_error("email", e))?; + validate_new_password(&password, &password_confirmation)?; + + let hash = server::hash_password(password).await?; + let result = sqlx::query("INSERT INTO users (name, email, password_hash) VALUES (?1, ?2, ?3)") + .bind(&name) + .bind(&email) + .bind(&hash) + .execute(&server::pool()?) + .await; + let user_id = match result { + Ok(done) => done.last_insert_rowid(), + Err(sqlx::Error::Database(e)) if e.is_unique_violation() => { + return Err(field_error( + "email", + "Un compte existe déjà avec cette adresse.", + )); + } + Err(e) => return Err(server::internal_error(e)), + }; + + start_session(user_id).await?; + leptos_axum::redirect("/"); + Ok(()) +} + +/// Ouvre une session pour `user_id`, en renouvelant l'identifiant de session +/// (`cycle_id`) contre la fixation de session. +#[cfg(feature = "ssr")] +async fn start_session(user_id: i64) -> Result<(), ServerFnError> { + let session = server::session().await?; + session.cycle_id().await.map_err(server::internal_error)?; + session + .insert(USER_ID_KEY, user_id) + .await + .map_err(server::internal_error)?; + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn email_normalization() { + assert_eq!(normalize_email(" Alice@Example.COM "), "alice@example.com"); + } + + #[test] + fn email_validation() { + assert!(validate_email("alice@example.com").is_ok()); + for email in [ + "", + "alice", + "alice@", + "@example.com", + "alice@example", + "a b@example.com", + ] { + assert!( + validate_email(email).is_err(), + "{email} devrait être invalide" + ); + } + } + + #[test] + fn password_rules_match_laravel() { + assert!(validate_password("Abcdefg1").is_ok()); + assert!(validate_password("Abcdef1").is_err(), "trop court"); + assert!(validate_password("abcdefg1").is_err(), "sans majuscule"); + assert!(validate_password("ABCDEFG1").is_err(), "sans minuscule"); + assert!(validate_password("Abcdefgh").is_err(), "sans chiffre"); + assert!( + validate_password(&format!("Ab1{}", "a".repeat(130))).is_err(), + "trop long" + ); + } + + #[test] + fn confirmation_must_match() { + assert!(validate_new_password("Abcdefg1", "Abcdefg1").is_ok()); + let error = validate_new_password("Abcdefg1", "Abcdefg2").unwrap_err(); + assert!(crate::errors::error_for_field(&error, "password_confirmation").is_some()); + } +} diff --git a/src/bin/import_mysql.rs b/src/bin/import_mysql.rs new file mode 100644 index 0000000..98e3b9b --- /dev/null +++ b/src/bin/import_mysql.rs @@ -0,0 +1,127 @@ +//! Import unique des données de lara-bermite (MySQL) dans la base SQLite de bermite_rs. +//! +//! ```sh +//! cargo run --bin import_mysql --features ssr,import -- \ +//! mysql://utilisateur:motdepasse@127.0.0.1/lara_bermite sqlite:bermite.db +//! ``` +//! +//! Copie `users`, `locations` et `rainfalls` en conservant les identifiants. Les hash +//! bcrypt de Laravel sont repris tels quels : ils restent valides et sont convertis en +//! Argon2 à la connexion suivante. Les sessions et jetons ne sont pas repris. +//! Refuse de s'exécuter si la base cible contient déjà des utilisateurs. + +use bermite_rs::server::connect_db; +use sqlx::{MySqlPool, Row}; + +#[tokio::main] +async fn main() -> Result<(), Box<dyn std::error::Error>> { + let mut args = std::env::args().skip(1); + let (Some(mysql_url), Some(sqlite_url)) = (args.next(), args.next()) else { + eprintln!("usage : import_mysql <url mysql> <url sqlite>"); + std::process::exit(2); + }; + + let mysql = MySqlPool::connect(&mysql_url).await?; + let sqlite = connect_db(&sqlite_url).await?; + + let existing: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM users") + .fetch_one(&sqlite) + .await?; + if existing > 0 { + return Err(format!( + "la base cible contient déjà {existing} utilisateur(s) : import annulé" + ) + .into()); + } + + // Les conversions sont faites côté MySQL : entiers signés, dates en texte. + let users = sqlx::query( + "SELECT CAST(id AS SIGNED) AS id, name, email, password, \ + DATE_FORMAT(COALESCE(created_at, NOW()), '%Y-%m-%d %H:%i:%s') AS created_at, \ + DATE_FORMAT(COALESCE(updated_at, NOW()), '%Y-%m-%d %H:%i:%s') AS updated_at \ + FROM users ORDER BY id", + ) + .fetch_all(&mysql) + .await?; + let locations = sqlx::query( + "SELECT CAST(id AS SIGNED) AS id, CAST(user_id AS SIGNED) AS user_id, latitude, longitude, \ + DATE_FORMAT(COALESCE(created_at, NOW()), '%Y-%m-%d %H:%i:%s') AS created_at \ + FROM locations ORDER BY id", + ) + .fetch_all(&mysql) + .await?; + let rainfalls = sqlx::query( + "SELECT CAST(id AS SIGNED) AS id, CAST(user_id AS SIGNED) AS user_id, \ + DATE_FORMAT(date, '%Y-%m-%d') AS date, CAST(value AS SIGNED) AS value, \ + DATE_FORMAT(COALESCE(created_at, NOW()), '%Y-%m-%d %H:%i:%s') AS created_at, \ + DATE_FORMAT(COALESCE(updated_at, NOW()), '%Y-%m-%d %H:%i:%s') AS updated_at \ + FROM rainfalls ORDER BY id", + ) + .fetch_all(&mysql) + .await?; + + let mut tx = sqlite.begin().await?; + for row in &users { + sqlx::query( + "INSERT INTO users (id, name, email, password_hash, created_at, updated_at) \ + VALUES (?1, ?2, lower(trim(?3)), ?4, ?5, ?6)", + ) + .bind(row.try_get::<i64, _>("id")?) + .bind(row.try_get::<String, _>("name")?) + .bind(row.try_get::<String, _>("email")?) + .bind(row.try_get::<String, _>("password")?) + .bind(row.try_get::<String, _>("created_at")?) + .bind(row.try_get::<String, _>("updated_at")?) + .execute(&mut *tx) + .await?; + } + for row in &locations { + sqlx::query("INSERT INTO locations (id, user_id, latitude, longitude, created_at) VALUES (?1, ?2, ?3, ?4, ?5)") + .bind(row.try_get::<i64, _>("id")?) + .bind(row.try_get::<i64, _>("user_id")?) + .bind(row.try_get::<f64, _>("latitude")?) + .bind(row.try_get::<f64, _>("longitude")?) + .bind(row.try_get::<String, _>("created_at")?) + .execute(&mut *tx) + .await?; + } + let mut skipped = 0; + for row in &rainfalls { + let value: i64 = row.try_get("value")?; + // La contrainte SQLite impose 1 à 1000 mm, comme la validation de Laravel. + if !(1..=1000).contains(&value) { + eprintln!( + "mesure {} ignorée : valeur {value} hors limites", + row.try_get::<i64, _>("id")? + ); + skipped += 1; + continue; + } + sqlx::query( + "INSERT INTO rainfalls (id, user_id, date, value, created_at, updated_at) \ + VALUES (?1, ?2, ?3, ?4, ?5, ?6)", + ) + .bind(row.try_get::<i64, _>("id")?) + .bind(row.try_get::<i64, _>("user_id")?) + .bind(row.try_get::<String, _>("date")?) + .bind(value) + .bind(row.try_get::<String, _>("created_at")?) + .bind(row.try_get::<String, _>("updated_at")?) + .execute(&mut *tx) + .await?; + } + tx.commit().await?; + + println!( + "import terminé : {} utilisateur(s), {} emplacement(s), {} mesure(s){}", + users.len(), + locations.len(), + rainfalls.len() - skipped, + if skipped > 0 { + format!(" ({skipped} ignorée(s))") + } else { + String::new() + }, + ); + Ok(()) +} diff --git a/src/chart.rs b/src/chart.rs new file mode 100644 index 0000000..79aacb9 --- /dev/null +++ b/src/chart.rs @@ -0,0 +1,304 @@ +//! Graphique en colonnes (une ou plusieurs séries), en HTML et CSS. +//! +//! Les barres sont des `<div>` dont la hauteur est un pourcentage de la zone de tracé : +//! le graphique occupe toute la largeur disponible sans JavaScript ni mesure du +//! conteneur, et le texte n'est jamais déformé. Conventions : barres de 24 px au plus, +//! coins arrondis en haut et droits sur la ligne de base, 2 px d'écart entre barres +//! voisines, grille discrète, une seule valeur écrite (le maximum, pour une série +//! seule) ; le détail de chaque colonne est dans l'infobulle. + +use leptos::prelude::*; + +/// Hauteur de la zone de tracé, en pixels. +const PLOT_HEIGHT: u32 = 240; +/// Nombre maximal de libellés sur l'axe horizontal (écran large / petit écran). +const MAX_AXIS_LABELS: usize = 12; +const MAX_AXIS_LABELS_SMALL: usize = 5; +/// Au-delà, les barres se touchent (plus d'écart de 2 px). +const MAX_GAPPED_COLUMNS: usize = 60; + +/// Une série : son nom (légende, infobulle) et la classe de couleur de ses barres. +#[derive(Clone, Debug, PartialEq)] +pub struct Series { + pub name: String, + pub color: &'static str, +} + +/// Une colonne : son libellé et une valeur par série (`None` : pas de barre). +#[derive(Clone, Debug, PartialEq)] +pub struct Column { + /// Libellé de l'axe horizontal. + pub label: String, + /// Titre de l'infobulle (par défaut, le libellé). + pub title: Option<String>, + pub values: Vec<Option<i64>>, +} + +/// Graduation « ronde » de l'axe vertical (1, 2, 5 × 10ⁿ) pour environ 4 intervalles. +pub fn nice_step(max: i64) -> i64 { + let raw = (max.max(1) as f64 / 4.0).max(1.0); + let magnitude = 10f64.powf(raw.log10().floor()); + let step = [1.0, 2.0, 5.0, 10.0] + .into_iter() + .map(|m| m * magnitude) + .find(|step| *step >= raw) + .unwrap_or(10.0 * magnitude); + step as i64 +} + +/// Haut de l'axe : premier multiple de `step` supérieur ou égal au maximum. +fn axis_top(max: i64, step: i64) -> i64 { + (max.max(1) + step - 1) / step * step +} + +#[component] +pub fn ColumnChart( + series: Vec<Series>, + columns: Vec<Column>, + /// Unité des valeurs (infobulle). + #[prop(default = "mm")] + unit: &'static str, + #[prop(optional, into)] loading: Signal<bool>, +) -> impl IntoView { + let hovered = RwSignal::new(None::<usize>); + + let max = columns + .iter() + .flat_map(|c| c.values.iter().flatten()) + .copied() + .max() + .unwrap_or(0); + let step = nice_step(max); + let top = axis_top(max, step); + let percent = move |value: i64| value as f64 / top as f64 * 100.0; + let ticks: Vec<i64> = (0..=top / step).map(|i| i * step).collect(); + + let n = columns.len().max(1); + let label_every = n.div_ceil(MAX_AXIS_LABELS); + let label_every_small = n.div_ceil(MAX_AXIS_LABELS_SMALL); + let gap = if columns.len() <= MAX_GAPPED_COLUMNS { + "gap-[2px]" + } else { + "" + }; + // Une série seule : on écrit la valeur de la plus haute colonne, et rien d'autre. + let max_index = (series.len() == 1 && max > 0) + .then(|| { + columns + .iter() + .position(|c| c.values.first().copied().flatten() == Some(max)) + }) + .flatten(); + let multi = series.len() > 1; + + let tooltip_columns = columns.clone(); + let tooltip_series = series.clone(); + + view! { + <div class="flex flex-col gap-3 transition-opacity" class=("opacity-50", move || loading.try_get().unwrap_or(false))> + {multi + .then(|| { + view! { + <ul class="flex flex-wrap gap-x-4 gap-y-1 text-sm" aria-label="Légende"> + {series + .iter() + .map(|s| { + view! { + <li class="flex items-center gap-1.5"> + <span class=format!("size-2.5 rounded-sm {}", s.color)></span> + <span class="muted">{s.name.clone()}</span> + </li> + } + }) + .collect_view()} + </ul> + } + })} + <div class="flex pt-5"> + // Graduations de l'axe vertical. + <div class="relative w-9 shrink-0" style=format!("height: {PLOT_HEIGHT}px") aria-hidden="true"> + {ticks + .iter() + .map(|&tick| { + view! { + <span + class="muted absolute right-2 translate-y-1/2 text-[11px] tabular-nums" + style=format!("bottom: {}%", percent(tick)) + > + {tick} + </span> + } + }) + .collect_view()} + </div> + <div + class="relative min-w-0 flex-1" + style=format!("height: {PLOT_HEIGHT}px") + on:pointerleave=move |_| hovered.set(None) + > + // Lignes de la grille (la ligne de base un ton plus marqué). + {ticks + .iter() + .map(|&tick| { + let class = if tick == 0 { + "absolute inset-x-0 border-t border-slate-300 dark:border-slate-600" + } else { + "absolute inset-x-0 border-t border-slate-100 dark:border-slate-800" + }; + view! { <div class=class style=format!("bottom: {}%", percent(tick))></div> } + }) + .collect_view()} + <div class=format!("absolute inset-0 flex items-end {gap}") role="img" aria-label="Graphique en colonnes"> + {columns + .iter() + .enumerate() + .map(|(i, column)| { + let bars = column + .values + .iter() + .zip(&series) + .map(|(value, s)| { + let value = value.unwrap_or(0); + let label = (max_index == Some(i)) + .then(|| { + view! { + <span class="mb-1 text-[11px] font-semibold tabular-nums">{value}</span> + } + }); + view! { + <div class="flex h-full w-full max-w-6 min-w-0 flex-col items-center justify-end"> + {label} + <div + class=format!("w-full rounded-t-[4px] transition-[height] {}", s.color) + style=format!("height: {}%", percent(value)) + ></div> + </div> + } + }) + .collect_view(); + view! { + <div + class=format!( + "flex h-full min-w-0 flex-1 cursor-default items-end justify-center rounded-t-md transition-colors {gap}", + ) + class=("bg-slate-500/10", move || hovered.try_get().flatten() == Some(i)) + on:pointerenter=move |_| hovered.set(Some(i)) + on:click=move |_| hovered.set(Some(i)) + > + {bars} + </div> + } + }) + .collect_view()} + </div> + // Infobulle de la colonne survolée. + {move || { + hovered + .try_get() + .flatten() + .and_then(|i| tooltip_columns.get(i).map(|c| (i, c.clone()))) + .map(|(i, column)| { + let center = (i as f64 + 0.5) / n as f64 * 100.0; + // Recentrée vers l'intérieur près des bords. + let shift = if center < 20.0 { + "0%" + } else if center > 80.0 { + "-100%" + } else { + "-50%" + }; + view! { + <div + class="pointer-events-none absolute -top-2 z-10 min-w-36 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm shadow-lg dark:border-slate-700 dark:bg-slate-800" + style=format!("left: {center}%; transform: translate({shift}, -100%)") + > + <div class="mb-1 font-semibold whitespace-nowrap"> + {column.title.clone().unwrap_or(column.label.clone())} + </div> + {column + .values + .iter() + .zip(&tooltip_series) + .map(|(value, s)| { + view! { + <div class="flex items-center justify-between gap-4 whitespace-nowrap"> + <span class="flex items-center gap-1.5"> + <span class=format!("size-2 rounded-sm {}", s.color)></span> + <span class="muted">{s.name.clone()}</span> + </span> + <span class="font-semibold tabular-nums"> + {match value { + Some(v) => format!("{v} {unit}"), + None => "—".to_string(), + }} + </span> + </div> + } + }) + .collect_view()} + </div> + } + }) + }} + </div> + </div> + // Libellés de l'axe horizontal : un sur `label_every` (un sur `label_every_small` sur mobile). + <div class="ml-9 flex h-4" aria-hidden="true"> + {columns + .iter() + .enumerate() + .map(|(i, column)| { + let wide = i % label_every == 0; + let small = i % label_every_small == 0; + // Le premier et le dernier libellé sont alignés sur les bords, pour ne pas déborder. + let anchor = if i == 0 { + "left-0" + } else if i + 1 == columns.len() { + "right-0" + } else { + "left-1/2 -translate-x-1/2" + }; + let visibility = match (wide, small) { + (true, true) => "", + (true, false) => "max-sm:invisible", + (false, true) => "sm:invisible", + (false, false) => "invisible", + }; + view! { + <div class="relative min-w-0 flex-1"> + <span class=format!( + "muted absolute {anchor} text-[11px] whitespace-nowrap {visibility}", + )>{column.label.clone()}</span> + </div> + } + }) + .collect_view()} + </div> + </div> + } + // Effacement du type : la vue est très imbriquée. + .into_any() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn nice_steps() { + assert_eq!(nice_step(0), 1); + assert_eq!(nice_step(4), 1); + assert_eq!(nice_step(10), 5); + assert_eq!(nice_step(23), 10); + assert_eq!(nice_step(80), 20); + assert_eq!(nice_step(260), 100); + assert_eq!(nice_step(1000), 500); + } + + #[test] + fn axis_top_rounds_up_to_a_step() { + assert_eq!(axis_top(0, 1), 1); + assert_eq!(axis_top(20, 5), 20); + assert_eq!(axis_top(42, 10), 50); + } +} diff --git a/src/components.rs b/src/components.rs new file mode 100644 index 0000000..95a85bb --- /dev/null +++ b/src/components.rs @@ -0,0 +1,325 @@ +//! Blocs de la pluviométrie partagés entre l'accueil et la page Pluviométrie. + +use chrono::Datelike; +use leptos::{html, prelude::*}; +use leptos_router::components::A; + +use crate::{ + chart::{Column, ColumnChart, Series}, + errors::error_message, + icons::{Icon, IconName}, + rainfall::{ + self, AddRainfall, MonthlySummary, + graph::{month_name, month_short}, + }, + ui::{ + Card, ErrorBanner, Field, Loading, StatTile, SubmitButton, SuccessBanner, field_error_of, + general_error_of, succeeded, + }, + weather::weekday_fr, +}; + +/// Nombre avec séparateur de milliers à la française (espace fine insécable). +pub fn format_number(value: i64) -> String { + let digits = value.unsigned_abs().to_string(); + let mut out = String::new(); + for (i, c) in digits.chars().enumerate() { + if i > 0 && (digits.len() - i).is_multiple_of(3) { + out.push('\u{202f}'); + } + out.push(c); + } + if value < 0 { format!("-{out}") } else { out } +} + +/// « mardi 14 octobre » à partir d'une date AAAA-MM-JJ. +pub fn format_long_date(date: &str) -> String { + chrono::NaiveDate::parse_from_str(date, "%Y-%m-%d") + .map(|d| { + format!( + "{} {} {}", + weekday_fr(d.weekday()), + d.day(), + month_name(d.month()).to_lowercase() + ) + }) + .unwrap_or_else(|_| date.to_string()) +} + +/// Formulaire « Nouvelle mesure ». +#[component] +pub fn AddRainfallForm(add: ServerAction<AddRainfall>) -> impl IntoView { + let value = add.value(); + let form = NodeRef::<html::Form>::new(); + let today = rainfall::today().format("%Y-%m-%d").to_string(); + + // Vide le formulaire après un ajout réussi (`ActionForm` ne le fait pas) ; la date + // revient à sa valeur par défaut, aujourd'hui. + Effect::new(move |_| { + if succeeded(value).get() + && let Some(form) = form.get() + { + form.reset(); + } + }); + + view! { + <Card title="Nouvelle mesure" icon=IconName::Plus> + <ActionForm action=add node_ref=form attr:class="flex flex-col gap-4"> + <Show when=move || succeeded(value).get()> + <SuccessBanner>"Mesure enregistrée."</SuccessBanner> + </Show> + <ErrorBanner message=general_error_of(value) /> + <div class="grid grid-cols-2 gap-3"> + <Field label="Date" name="date" kind="date" value=today error=field_error_of(value, "date") /> + <Field + label="Pluie (mm)" + name="value" + kind="number" + min="1" + max="1000" + step="1" + inputmode="numeric" + placeholder="0" + error=field_error_of(value, "value") + /> + </div> + <SubmitButton pending=add.pending() class="w-full"> + <Icon icon=IconName::Check class="size-4" /> + "Enregistrer" + </SubmitButton> + </ActionForm> + </Card> + } +} + +/// Les 5 dernières mesures. `reload` : signal qui change après chaque ajout. +#[component] +pub fn LastRainfalls(#[prop(into)] reload: Signal<usize>) -> impl IntoView { + let last = Resource::new(move || reload.get(), |_| rainfall::list_rainfalls(5)); + view! { + <Card title="Dernières mesures" icon=IconName::List> + <Transition fallback=|| view! { <Loading height="h-40" /> }> + {move || { + last.get() + .map(|result| match result { + Ok(page) if page.items.is_empty() => { + view! { <p class="muted py-4 text-center text-sm">"Aucune mesure pour l'instant."</p> } + .into_any() + } + Ok(page) => { + view! { + <ul class="-my-2 divide-y divide-slate-100 dark:divide-slate-800"> + {page + .items + .into_iter() + .map(|r| { + view! { + <li class="flex items-center justify-between gap-3 py-2.5"> + <span class="first-letter:uppercase">{format_long_date(&r.date)}</span> + <span class="rounded-full bg-blue-50 px-2.5 py-0.5 text-sm font-semibold text-blue-700 tabular-nums dark:bg-blue-500/10 dark:text-blue-300"> + {r.value} " mm" + </span> + </li> + } + }) + .collect_view()} + </ul> + } + .into_any() + } + Err(e) => view! { <ErrorBanner message=Some(error_message(&e)) /> }.into_any(), + }) + }} + </Transition> + <A + href="/pluviometrie/mesures" + attr:class="mt-4 flex items-center justify-center gap-1.5 rounded-lg border border-slate-200 py-2 text-sm font-medium text-slate-600 transition hover:bg-slate-50 hover:text-slate-900 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white" + > + "Toutes les mesures" + <Icon icon=IconName::ArrowRight class="size-4" /> + </A> + </Card> + } +} + +/// Chiffres clés et comparaison mois par mois avec l'an dernier (page d'accueil). +#[component] +pub fn YearOverview(#[prop(into)] reload: Signal<usize>) -> impl IntoView { + let summary = Resource::new(move || reload.get(), |_| rainfall::last_months()); + let last = Resource::new(move || reload.get(), |_| rainfall::list_rainfalls(1)); + view! { + <Transition fallback=|| { + view! { + <div class="grid gap-4 sm:grid-cols-3"> + <Loading height="h-28" /> + <Loading height="h-28" /> + <Loading height="h-28" /> + </div> + <Loading height="h-80" /> + } + }> + {move || { + let last = last.get().and_then(Result::ok).and_then(|page| page.items.into_iter().next()); + summary + .get() + .map(|result| match result { + Ok(summary) => view! { <Overview summary last /> }.into_any(), + Err(e) => view! { <ErrorBanner message=Some(error_message(&e)) /> }.into_any(), + }) + }} + </Transition> + } +} + +#[component] +fn Overview(summary: MonthlySummary, last: Option<rainfall::Rainfall>) -> impl IntoView { + let year = summary.current_year; + let month = rainfall::today().month(); + let this_month = summary.rows.iter().find(|r| r.month == month).cloned(); + + let difference = summary.total_current - summary.total_previous_to_date; + let year_detail = format!( + "{} mm à la même date en {} ({}{})", + format_number(summary.total_previous_to_date), + year - 1, + if difference >= 0 { "+" } else { "" }, + format_number(difference), + ); + + let series = vec![ + Series { + name: year.to_string(), + color: "bg-chart-1", + }, + Series { + name: (year - 1).to_string(), + color: "bg-chart-2", + }, + ]; + let columns = summary + .rows + .iter() + .map(|row| Column { + label: month_short(row.month).to_string(), + title: Some(row.label.clone()), + values: vec![row.current, Some(row.previous)], + }) + .collect::<Vec<_>>(); + + view! { + <div class="grid grid-cols-2 gap-3 sm:grid-cols-3 sm:gap-4"> + <div class="col-span-2 sm:col-span-1"> + <StatTile + label=format!("Cumul {year}") + value=format_number(summary.total_current) + unit="mm" + detail=year_detail + icon=IconName::Droplet + /> + </div> + <StatTile + label=format!("{} {year}", month_name(month)) + value=format_number(this_month.as_ref().and_then(|r| r.current).unwrap_or(0)) + unit="mm" + detail=format!( + "{} mm en {} {}", + format_number(this_month.map(|r| r.previous).unwrap_or(0)), + month_name(month).to_lowercase(), + year - 1, + ) + icon=IconName::Calendar + /> + {match last { + Some(last) => { + view! { + <StatTile + label="Dernière mesure" + value=last.value.to_string() + unit="mm" + detail=format_long_date(&last.date) + icon=IconName::CloudRain + /> + } + .into_any() + } + None => { + view! { + <StatTile label="Dernière mesure" value="—" detail="Aucune mesure" icon=IconName::CloudRain /> + } + .into_any() + } + }} + </div> + + <Card title="Mois par mois" icon=IconName::CloudRain> + <ColumnChart series columns /> + <details class="group mt-4 border-t border-slate-100 pt-3 dark:border-slate-800"> + <summary class="muted flex cursor-pointer list-none items-center gap-1 text-sm font-medium hover:text-slate-900 dark:hover:text-white"> + <Icon icon=IconName::ChevronDown class="size-4 transition-transform group-open:rotate-180" /> + "Voir le tableau" + </summary> + <MonthTable summary /> + </details> + </Card> + } +} + +#[component] +fn MonthTable(summary: MonthlySummary) -> impl IntoView { + let year = summary.current_year; + view! { + <table class="mt-3 w-full text-sm tabular-nums"> + <thead> + <tr class="muted border-b border-slate-200 text-left dark:border-slate-700"> + <th class="py-2 font-medium">"Mois"</th> + <th class="py-2 text-right font-medium">{year}</th> + <th class="py-2 text-right font-medium">{year - 1}</th> + </tr> + </thead> + <tbody class="divide-y divide-slate-100 dark:divide-slate-800"> + {summary + .rows + .into_iter() + .map(|row| { + view! { + <tr> + <td class="py-1.5">{row.label}</td> + <td class="py-1.5 text-right">{row.current.map(|v| format!("{v} mm"))}</td> + <td class="py-1.5 text-right">{row.previous} " mm"</td> + </tr> + } + }) + .collect_view()} + </tbody> + <tfoot> + <tr class="border-t border-slate-200 font-semibold dark:border-slate-700"> + <td class="py-2">"Total"</td> + <td class="py-2 text-right">{format_number(summary.total_current)} " mm"</td> + <td class="py-2 text-right">{format_number(summary.total_previous)} " mm"</td> + </tr> + </tfoot> + </table> + {summary + .first_year + .map(|first| view! { <p class="muted mt-2 text-right text-xs">"Mesures depuis " {first}</p> })} + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn numbers_are_grouped_by_thousands() { + assert_eq!(format_number(0), "0"); + assert_eq!(format_number(999), "999"); + assert_eq!(format_number(1281), "1\u{202f}281"); + assert_eq!(format_number(-1234567), "-1\u{202f}234\u{202f}567"); + } + + #[test] + fn long_dates_are_french() { + assert_eq!(format_long_date("2026-10-14"), "mercredi 14 octobre"); + } +} diff --git a/src/errors.rs b/src/errors.rs new file mode 100644 index 0000000..e6313c7 --- /dev/null +++ b/src/errors.rs @@ -0,0 +1,72 @@ +//! Erreurs des server functions, rattachées ou non à un champ de formulaire. +//! +//! Une erreur de champ est transportée dans le message de `ServerFnError` sous la +//! forme `champ` + séparateur + `message`, pour être affichée sous le bon `<input>` +//! (l'équivalent des erreurs 422 de Laravel). + +use leptos::prelude::*; + +const SEPARATOR: char = '\u{1f}'; + +/// Erreur de validation attachée au champ `field`. +pub fn field_error(field: &str, message: impl Into<String>) -> ServerFnError { + ServerFnError::new(format!("{field}{SEPARATOR}{}", message.into())) +} + +fn split(error: &ServerFnError) -> (Option<&str>, String) { + match error { + ServerFnError::ServerError(message) => match message.split_once(SEPARATOR) { + Some((field, message)) => (Some(field), message.to_string()), + None => (None, message.clone()), + }, + _ => ( + None, + "Impossible de joindre le serveur. Réessayez.".to_string(), + ), + } +} + +/// Message lisible de l'erreur, qu'elle soit liée à un champ ou non. +pub fn error_message(error: &ServerFnError) -> String { + split(error).1 +} + +/// Message de l'erreur si elle concerne le champ `field`. +pub fn error_for_field(error: &ServerFnError, field: &str) -> Option<String> { + match split(error) { + (Some(f), message) if f == field => Some(message), + _ => None, + } +} + +/// Message de l'erreur si elle ne concerne aucun champ en particulier. +pub fn general_error(error: &ServerFnError) -> Option<String> { + match split(error) { + (None, message) => Some(message), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn field_errors_round_trip() { + let error = field_error("email", "Adresse invalide."); + assert_eq!( + error_for_field(&error, "email").as_deref(), + Some("Adresse invalide.") + ); + assert_eq!(error_for_field(&error, "password"), None); + assert_eq!(general_error(&error), None); + assert_eq!(error_message(&error), "Adresse invalide."); + } + + #[test] + fn general_errors_are_not_attached_to_fields() { + let error = ServerFnError::new("Boom"); + assert_eq!(error_for_field(&error, "email"), None); + assert_eq!(general_error(&error).as_deref(), Some("Boom")); + } +} diff --git a/src/icons.rs b/src/icons.rs new file mode 100644 index 0000000..c6ae246 --- /dev/null +++ b/src/icons.rs @@ -0,0 +1,101 @@ +//! Icônes SVG au trait (dessins de Lucide, licence ISC), en ligne pour éviter toute requête. + +use leptos::prelude::*; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum IconName { + Home, + CloudRain, + CloudSun, + User, + Plus, + Trash, + Pencil, + Check, + X, + LogOut, + MapPin, + Droplet, + List, + Sun, + Moon, + Monitor, + ArrowRight, + ChevronDown, + Calendar, +} + +impl IconName { + fn paths(self) -> &'static str { + match self { + IconName::Home => { + r#"<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>"# + } + IconName::CloudRain => { + r#"<path d="M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242"/><path d="M16 14v6"/><path d="M8 14v6"/><path d="M12 16v6"/>"# + } + IconName::CloudSun => { + r#"<path d="M12 2v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="M20 12h2"/><path d="m19.07 4.93-1.41 1.41"/><path d="M15.947 12.65a4 4 0 0 0-5.925-4.128"/><path d="M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z"/>"# + } + IconName::User => { + r#"<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>"# + } + IconName::Plus => r#"<path d="M5 12h14"/><path d="M12 5v14"/>"#, + IconName::Trash => { + r#"<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>"# + } + IconName::Pencil => { + r#"<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/>"# + } + IconName::Check => r#"<path d="M20 6 9 17l-5-5"/>"#, + IconName::X => r#"<path d="M18 6 6 18"/><path d="m6 6 12 12"/>"#, + IconName::LogOut => { + r#"<path d="m16 17 5-5-5-5"/><path d="M21 12H9"/><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/>"# + } + IconName::MapPin => { + r#"<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"/><circle cx="12" cy="10" r="3"/>"# + } + IconName::Droplet => { + r#"<path d="M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z"/>"# + } + IconName::List => { + r#"<path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/><path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/>"# + } + IconName::Sun => { + r#"<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>"# + } + IconName::Moon => r#"<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>"#, + IconName::Monitor => { + r#"<rect width="20" height="14" x="2" y="3" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/>"# + } + IconName::ArrowRight => r#"<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>"#, + IconName::ChevronDown => r#"<path d="m6 9 6 6 6-6"/>"#, + IconName::Calendar => { + r#"<path d="M8 2v4"/><path d="M16 2v4"/><rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/>"# + } + } + } +} + +/// Icône décorative (masquée aux lecteurs d'écran : le texte voisin porte le sens). +#[component] +pub fn Icon(icon: IconName, #[prop(optional, into)] class: String) -> impl IntoView { + let class = if class.is_empty() { + "size-5 shrink-0".to_string() + } else { + format!("shrink-0 {class}") + }; + view! { + <svg + class=class + viewBox="0 0 24 24" + fill="none" + stroke="currentColor" + stroke-width="2" + stroke-linecap="round" + stroke-linejoin="round" + aria-hidden="true" + inner_html=icon.paths() + ></svg> + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..0be7414 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,27 @@ +// Les vues Leptos produisent des types très imbriqués (build WASM en release). +#![recursion_limit = "256"] + +pub mod app; +pub mod auth; +pub mod chart; +pub mod components; +pub mod errors; +pub mod icons; +pub mod location; +#[cfg(feature = "ssr")] +pub mod mail; +pub mod pages; +pub mod profile; +pub mod rainfall; +#[cfg(feature = "ssr")] +pub mod server; +pub mod ui; +pub mod weather; + +#[cfg(feature = "hydrate")] +#[wasm_bindgen::prelude::wasm_bindgen] +pub fn hydrate() { + use crate::app::*; + console_error_panic_hook::set_once(); + leptos::mount::hydrate_body(App); +} diff --git a/src/location.rs b/src/location.rs new file mode 100644 index 0000000..6e5a47b --- /dev/null +++ b/src/location.rs @@ -0,0 +1,101 @@ +//! Emplacement de l'utilisateur, utilisé pour les prévisions météo. + +use leptos::prelude::*; +use serde::{Deserialize, Serialize}; + +use crate::errors::field_error; +#[cfg(feature = "ssr")] +use crate::server; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Location { + pub id: i64, + pub latitude: f64, + pub longitude: f64, +} + +/// Lit une coordonnée saisie (virgule acceptée) et vérifie ses bornes. +/// Arrondie à 5 décimales (≈ 1 m), comme la règle `decimal:3,5` de Laravel. +pub fn parse_coordinate(field: &str, value: &str, bound: f64) -> Result<f64, ServerFnError> { + let number: f64 = value + .trim() + .replace(',', ".") + .parse() + .map_err(|_| field_error(field, "Veuillez saisir un nombre."))?; + if !number.is_finite() || number.abs() > bound { + return Err(field_error( + field, + format!("La valeur doit être comprise entre -{bound} et {bound}."), + )); + } + Ok((number * 100_000.0).round() / 100_000.0) +} + +#[cfg(feature = "ssr")] +pub async fn user_locations( + pool: &sqlx::SqlitePool, + user_id: i64, +) -> Result<Vec<Location>, ServerFnError> { + let rows = sqlx::query_as::<_, (i64, f64, f64)>( + "SELECT id, latitude, longitude FROM locations WHERE user_id = ?1 ORDER BY id", + ) + .bind(user_id) + .fetch_all(pool) + .await + .map_err(server::internal_error)?; + Ok(rows + .into_iter() + .map(|(id, latitude, longitude)| Location { + id, + latitude, + longitude, + }) + .collect()) +} + +/// Enregistre l'emplacement de l'utilisateur (remplace le précédent s'il y en avait un). +#[server] +pub async fn save_location(latitude: String, longitude: String) -> Result<(), ServerFnError> { + let user_id = server::require_user_id().await?; + let latitude = parse_coordinate("latitude", &latitude, 90.0)?; + let longitude = parse_coordinate("longitude", &longitude, 180.0)?; + + let pool = server::pool()?; + let mut tx = pool.begin().await.map_err(server::internal_error)?; + sqlx::query("DELETE FROM locations WHERE user_id = ?1") + .bind(user_id) + .execute(&mut *tx) + .await + .map_err(server::internal_error)?; + sqlx::query("INSERT INTO locations (user_id, latitude, longitude) VALUES (?1, ?2, ?3)") + .bind(user_id) + .bind(latitude) + .bind(longitude) + .execute(&mut *tx) + .await + .map_err(server::internal_error)?; + tx.commit().await.map_err(server::internal_error)?; + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn coordinates_are_parsed_and_rounded() { + assert_eq!( + parse_coordinate("latitude", "45.123456", 90.0).unwrap(), + 45.12346 + ); + assert_eq!(parse_coordinate("latitude", " -1,5 ", 90.0).unwrap(), -1.5); + } + + #[test] + fn out_of_range_coordinates_are_rejected() { + assert!(parse_coordinate("latitude", "91", 90.0).is_err()); + assert!(parse_coordinate("longitude", "-180.1", 180.0).is_err()); + assert!(parse_coordinate("longitude", "abc", 180.0).is_err()); + assert!(parse_coordinate("longitude", "NaN", 180.0).is_err()); + } +} diff --git a/src/mail.rs b/src/mail.rs new file mode 100644 index 0000000..04c2efe --- /dev/null +++ b/src/mail.rs @@ -0,0 +1,65 @@ +//! Envoi des e-mails (serveur uniquement). + +use lettre::{ + AsyncSmtpTransport, AsyncTransport, Message, Tokio1Executor, message::MultiPart, + transport::smtp::authentication::Credentials, +}; + +use crate::server::Config; + +/// Envoie le lien de réinitialisation du mot de passe (texte du mail de lara-bermite). +/// +/// Sans SMTP configuré (développement), le lien est seulement écrit dans les logs. +pub async fn send_reset_link(config: &Config, to: &str, link: &str) -> Result<(), String> { + let Some(smtp) = &config.smtp else { + leptos::logging::log!("SMTP non configuré — lien de réinitialisation pour {to} : {link}"); + return Ok(()); + }; + + let text = format!( + "Créer un nouveau mot de passe\n\n\ + Veuillez suivre ce lien pour réinitialiser votre mot de passe (valable 24 heures) :\n\ + {link}\n\n\ + Si vous n'êtes pas à l'origine de cette demande, ignorez ce message.\n\n\ + Merci,\nBermite\n" + ); + let html = format!( + r#"<h1>Créer un nouveau mot de passe</h1> +<p>Veuillez cliquer sur le bouton ci-dessous pour réinitialiser votre mot de passe (valable 24 heures).</p> +<p><a href="{link}" style="display:inline-block;padding:8px 16px;background:#1d4ed8;color:#fff;border-radius:4px;text-decoration:none">Réinitialisation de mot de passe</a></p> +<p>Si le bouton ne fonctionne pas, essayez le lien suivant :<br>{link}</p> +<p>Merci,<br>Bermite</p>"# + ); + + let message = Message::builder() + .from( + config + .mail_from + .parse() + .map_err(|e| format!("MAIL_FROM invalide : {e}"))?, + ) + .to(to + .parse() + .map_err(|e| format!("destinataire invalide : {e}"))?) + .subject("Bermite réinitialisation du mot de passe") + .multipart(MultiPart::alternative_plain_html(text, html)) + .map_err(|e| e.to_string())?; + + // Port 465 : TLS implicite (OVH) ; sinon STARTTLS. + let builder = if smtp.port == 465 { + AsyncSmtpTransport::<Tokio1Executor>::relay(&smtp.host) + } else { + AsyncSmtpTransport::<Tokio1Executor>::starttls_relay(&smtp.host) + } + .map_err(|e| e.to_string())?; + let transport = builder + .port(smtp.port) + .credentials(Credentials::new( + smtp.username.clone(), + smtp.password.clone(), + )) + .build(); + + transport.send(message).await.map_err(|e| e.to_string())?; + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index e7a11a9..027921d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,94 @@ -fn main() { - println!("Hello, world!"); +#[cfg(feature = "ssr")] +#[tokio::main] +async fn main() { + use axum::Router; + use bermite_rs::{ + app::{App, shell}, + server::{self, AppContext, Config}, + }; + use leptos::{logging::log, prelude::*}; + use leptos_axum::{LeptosRoutes, generate_route_list}; + use std::sync::Arc; + use tower_sessions::{ + Expiry, SessionManagerLayer, + cookie::{SameSite, time::Duration}, + session_store::ExpiredDeletion, + }; + use tower_sessions_sqlx_store::SqliteStore; + + // Le fichier .env est facultatif (en production, les variables peuvent venir de systemd). + let _ = dotenvy::dotenv(); + + let database_url = std::env::var("DATABASE_URL").unwrap_or_else(|_| "sqlite:bermite.db".into()); + let pool = server::connect_db(&database_url) + .await + .expect("impossible d'ouvrir la base de données"); + + // Les sessions sont stockées en base : elles survivent à un redémarrage du serveur. + let session_store = SqliteStore::new(pool.clone()); + session_store + .migrate() + .await + .expect("impossible de créer la table des sessions"); + tokio::spawn( + session_store + .clone() + .continuously_delete_expired(tokio::time::Duration::from_secs(60 * 60)), + ); + + let conf = get_configuration(None).unwrap(); + let addr = conf.leptos_options.site_addr; + let leptos_options = conf.leptos_options; + let is_prod = matches!(leptos_options.env, Env::PROD); + + let config = Config::from_env(); + if config.open_weather_map_api_key.is_none() { + log!("⚠ OPEN_WEATHER_MAP_API_KEY absente : la page Météo renverra une erreur"); + } + let context = AppContext { + pool, + config: Arc::new(config), + http: reqwest::Client::builder() + .timeout(std::time::Duration::from_secs(10)) + .build() + .expect("client HTTP"), + weather_cache: Default::default(), + }; + + let session_layer = SessionManagerLayer::new(session_store) + // Cookie `Secure` (HTTPS uniquement) en production. `HttpOnly` est activé par défaut. + .with_secure(is_prod) + // `Lax` : le cookie n'est pas envoyé sur les requêtes POST venant d'un autre site (CSRF). + .with_same_site(SameSite::Lax) + // Comme la SESSION_LIFETIME de lara-bermite : une semaine d'inactivité. + .with_expiry(Expiry::OnInactivity(Duration::days(7))); + + let routes = generate_route_list(App); + let app = Router::new() + .leptos_routes_with_context( + &leptos_options, + routes, + { + let context = context.clone(); + move || provide_context(context.clone()) + }, + { + let leptos_options = leptos_options.clone(); + move || shell(leptos_options.clone()) + }, + ) + .fallback(leptos_axum::file_and_error_handler(shell)) + .layer(session_layer) + .with_state(leptos_options); + + log!("listening on http://{}", &addr); + let listener = tokio::net::TcpListener::bind(&addr).await.unwrap(); + axum::serve(listener, app.into_make_service()) + .await + .unwrap(); +} + +#[cfg(not(feature = "ssr"))] +pub fn main() { + // Pas de `main` côté client : voir `hydrate()` dans lib.rs. } diff --git a/src/pages/auth.rs b/src/pages/auth.rs new file mode 100644 index 0000000..0a056d0 --- /dev/null +++ b/src/pages/auth.rs @@ -0,0 +1,210 @@ +//! Connexion, inscription, mot de passe oublié et réinitialisation. + +use leptos::prelude::*; +use leptos_router::{components::A, hooks::use_params_map}; + +use crate::{ + auth::{self, ForgotPassword, Login, Register, ResetPassword}, + ui::{ + ErrorBanner, Field, Loading, SubmitButton, SuccessBanner, field_error_of, general_error_of, + succeeded, + }, +}; + +/// Écran centré des formulaires d'authentification : logo, titre, sous-titre, carte. +#[component] +fn AuthCard(title: &'static str, subtitle: &'static str, children: Children) -> impl IntoView { + view! { + <div class="flex min-h-[calc(100vh-4rem)] items-start justify-center px-4 py-10 sm:items-center"> + <div class="w-full max-w-sm"> + <div class="mb-6 flex flex-col items-center gap-3 text-center"> + <img src="/favicon.svg" alt="" width="48" height="48" class="size-12" /> + <div> + <h1 class="text-2xl font-bold tracking-tight">{title}</h1> + <p class="muted mt-1 text-sm">{subtitle}</p> + </div> + </div> + <div class="surface p-6">{children()}</div> + </div> + </div> + } +} + +#[component] +pub fn LoginPage(login: ServerAction<Login>) -> impl IntoView { + let value = login.value(); + view! { + <AuthCard title="Connexion" subtitle="Suivez votre pluviométrie et la météo"> + <ActionForm action=login attr:class="flex flex-col gap-4"> + <ErrorBanner message=general_error_of(value) /> + <Field + label="E-mail" + name="email" + kind="email" + placeholder="vous@exemple.fr" + autocomplete="username" + autofocus=true + error=field_error_of(value, "email") + /> + <Field + label="Mot de passe" + name="password" + kind="password" + placeholder="******" + autocomplete="current-password" + error=field_error_of(value, "password") + /> + <SubmitButton pending=login.pending() class="mt-1 w-full"> + "Valider" + </SubmitButton> + <A + href="/mot-de-passe-oubliee" + attr:class="text-center text-sm font-medium text-blue-600 hover:underline dark:text-blue-400" + > + "Mot de passe oublié ?" + </A> + </ActionForm> + </AuthCard> + } +} + +#[component] +pub fn RegisterPage(register: ServerAction<Register>) -> impl IntoView { + let open = Resource::new(|| (), |_| auth::registration_open()); + let value = register.value(); + view! { + <Suspense fallback=|| view! { <div class="mx-auto max-w-sm px-4 py-10"><Loading height="h-80" /></div> }> + {move || { + open.get() + .map(|open| { + if !matches!(open, Ok(true)) { + return view! { + <AuthCard title="Inscriptions fermées" subtitle="Un compte est nécessaire, mais les inscriptions ne sont pas ouvertes."> + <A href="/connexion" attr:class="btn-primary w-full">"Se connecter"</A> + </AuthCard> + } + .into_any(); + } + view! { + <AuthCard title="Créer un compte" subtitle="Quelques secondes suffisent"> + <ActionForm action=register attr:class="flex flex-col gap-4"> + <ErrorBanner message=general_error_of(value) /> + <Field + label="Nom" + name="name" + autocomplete="name" + autofocus=true + error=field_error_of(value, "name") + /> + <Field + label="E-mail" + name="email" + kind="email" + autocomplete="email" + error=field_error_of(value, "email") + /> + <Field + label="Mot de passe" + name="password" + kind="password" + autocomplete="new-password" + error=field_error_of(value, "password") + /> + <Field + label="Confirmation du mot de passe" + name="password_confirmation" + kind="password" + autocomplete="new-password" + error=field_error_of(value, "password_confirmation") + /> + <SubmitButton pending=register.pending() class="mt-1 w-full"> + "Valider" + </SubmitButton> + </ActionForm> + </AuthCard> + } + .into_any() + }) + }} + </Suspense> + } +} + +#[component] +pub fn ForgotPasswordPage() -> impl IntoView { + let forgot = ServerAction::<ForgotPassword>::new(); + let value = forgot.value(); + view! { + <AuthCard title="Mot de passe oublié" subtitle="Recevez un lien de réinitialisation par e-mail"> + <ActionForm action=forgot attr:class="flex flex-col gap-4"> + <Show when=move || succeeded(value).get()> + <SuccessBanner> + "Si un compte correspond à cette adresse, un e-mail vous a été envoyé pour modifier le mot de passe." + </SuccessBanner> + </Show> + <ErrorBanner message=general_error_of(value) /> + <Field + label="E-mail" + name="email" + kind="email" + placeholder="vous@exemple.fr" + autocomplete="email" + autofocus=true + error=field_error_of(value, "email") + /> + <SubmitButton pending=forgot.pending() class="mt-1 w-full"> + "Valider" + </SubmitButton> + <A + href="/connexion" + attr:class="text-center text-sm font-medium text-blue-600 hover:underline dark:text-blue-400" + > + "Retour à la connexion" + </A> + </ActionForm> + </AuthCard> + } +} + +#[component] +pub fn ResetPasswordPage(reset: ServerAction<ResetPassword>) -> impl IntoView { + let params = use_params_map(); + let token = move || params.with(|p| p.get("token").unwrap_or_default()); + let value = reset.value(); + view! { + <AuthCard title="Nouveau mot de passe" subtitle="Au moins 8 caractères, dont une majuscule, une minuscule et un chiffre"> + <ActionForm action=reset attr:class="flex flex-col gap-4"> + <ErrorBanner message=general_error_of(value) /> + <input type="hidden" name="token" value=token /> + <Field + label="E-mail" + name="email" + kind="email" + placeholder="vous@exemple.fr" + autocomplete="username" + autofocus=true + error=field_error_of(value, "email") + /> + <Field + label="Mot de passe" + name="password" + kind="password" + placeholder="******" + autocomplete="new-password" + error=field_error_of(value, "password") + /> + <Field + label="Confirmation du mot de passe" + name="password_confirmation" + kind="password" + placeholder="******" + autocomplete="new-password" + error=field_error_of(value, "password_confirmation") + /> + <SubmitButton pending=reset.pending() class="mt-1 w-full"> + "Valider" + </SubmitButton> + </ActionForm> + </AuthCard> + } +} diff --git a/src/pages/home.rs b/src/pages/home.rs new file mode 100644 index 0000000..3aaf254 --- /dev/null +++ b/src/pages/home.rs @@ -0,0 +1,29 @@ +//! Accueil : chiffres clés, comparaison avec l'an dernier et saisie rapide d'une mesure. + +use leptos::prelude::*; + +use crate::{ + app::Protected, + components::{AddRainfallForm, LastRainfalls, YearOverview}, + rainfall::AddRainfall, + ui::Page, +}; + +#[component] +pub fn HomePage() -> impl IntoView { + view! { + <Protected render=|user| { + let add = ServerAction::<AddRainfall>::new(); + let reload = Signal::derive(move || add.version().get()); + view! { + <Page title=format!("Bonjour {}", user.name) subtitle="Vos précipitations en un coup d'œil"> + <YearOverview reload /> + <div class="grid gap-5 md:grid-cols-2 md:items-start"> + <AddRainfallForm add /> + <LastRainfalls reload /> + </div> + </Page> + } + } /> + } +} diff --git a/src/pages/mod.rs b/src/pages/mod.rs new file mode 100644 index 0000000..9e19e62 --- /dev/null +++ b/src/pages/mod.rs @@ -0,0 +1,5 @@ +pub mod auth; +pub mod home; +pub mod profile; +pub mod rainfall; +pub mod weather; diff --git a/src/pages/profile.rs b/src/pages/profile.rs new file mode 100644 index 0000000..d6d33a2 --- /dev/null +++ b/src/pages/profile.rs @@ -0,0 +1,217 @@ +//! Profil : identité, déconnexion, emplacement météo et apparence. + +use leptos::{html, prelude::*}; + +use crate::{ + app::{CurrentUser, Protected}, + auth::Logout, + icons::{Icon, IconName}, + location::SaveLocation, + profile::{Theme, UpdateTheme}, + ui::{ + Card, ErrorBanner, Field, Page, SubmitButton, field_error_of, general_error_of, succeeded, + }, +}; + +#[component] +pub fn ProfilePage( + logout: ServerAction<Logout>, + save_location: ServerAction<SaveLocation>, + update_theme: ServerAction<UpdateTheme>, +) -> impl IntoView { + view! { + <Protected render=move |_| { + view! { <Profile logout save_location update_theme /> } + } /> + } +} + +#[component] +fn Profile( + logout: ServerAction<Logout>, + save_location: ServerAction<SaveLocation>, + update_theme: ServerAction<UpdateTheme>, +) -> impl IntoView { + // Ressource globale : rechargée après l'enregistrement d'un emplacement ou d'un thème. + let CurrentUser(user) = expect_context(); + let user = move || user.get().and_then(Result::ok).flatten(); + let editing_location = RwSignal::new(false); + + Effect::new(move |_| { + if succeeded(save_location.value()).get() { + editing_location.set(false); + } + }); + + view! { + <Page title="Profil"> + <Transition> + {move || { + user() + .map(|user| { + let initial = user.name.chars().next().map(|c| c.to_uppercase().to_string()).unwrap_or_default(); + let location = user.locations.first().cloned(); + let has_location = location.is_some(); + let latitude = location.as_ref().map(|l| l.latitude.to_string()).unwrap_or_default(); + let longitude = location.as_ref().map(|l| l.longitude.to_string()).unwrap_or_default(); + view! { + <Card> + <div class="flex flex-wrap items-center gap-4"> + <span class="flex size-14 items-center justify-center rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 text-xl font-semibold text-white"> + {initial} + </span> + <div class="min-w-0 flex-1"> + <div class="truncate text-lg font-semibold">{user.name.clone()}</div> + <div class="muted truncate">{user.email.clone()}</div> + </div> + <ActionForm action=logout> + <button + type="submit" + class="btn-ghost border border-slate-200 hover:!border-red-200 hover:!bg-red-50 hover:!text-red-600 dark:border-slate-700 dark:hover:!border-red-500/30 dark:hover:!bg-red-500/10 dark:hover:!text-red-400" + > + <Icon icon=IconName::LogOut class="size-4" /> + "Se déconnecter" + </button> + </ActionForm> + </div> + </Card> + + <Card title="Emplacement météo" icon=IconName::MapPin> + {location + .map(|location| { + view! { + <div class="flex flex-wrap items-center justify-between gap-3"> + <dl class="flex gap-6 tabular-nums"> + <div> + <dt class="muted text-xs font-medium">"Latitude"</dt> + <dd class="font-semibold">{location.latitude}</dd> + </div> + <div> + <dt class="muted text-xs font-medium">"Longitude"</dt> + <dd class="font-semibold">{location.longitude}</dd> + </div> + </dl> + <button + type="button" + class="btn-ghost" + on:click=move |_| editing_location.update(|e| *e = !*e) + > + <Icon icon=IconName::Pencil class="size-4" /> + "Modifier" + </button> + </div> + } + })} + <Show when=move || !has_location || editing_location.get()> + <LocationForm + save_location + latitude=latitude.clone() + longitude=longitude.clone() + /> + </Show> + </Card> + + <Card title="Apparence" icon=IconName::Sun> + <ThemePicker update_theme current=user.theme /> + </Card> + } + }) + }} + </Transition> + </Page> + } +} + +#[component] +fn LocationForm( + save_location: ServerAction<SaveLocation>, + latitude: String, + longitude: String, +) -> impl IntoView { + let value = save_location.value(); + view! { + <ActionForm action=save_location attr:class="mt-4 flex flex-col gap-3 border-t border-slate-100 pt-4 first:mt-0 first:border-0 first:pt-0 dark:border-slate-800"> + <p class="muted text-sm"> + "Coordonnées en degrés décimaux, par exemple celles affichées par un clic droit dans une carte en ligne." + </p> + <ErrorBanner message=general_error_of(value) /> + <div class="grid gap-3 sm:grid-cols-[1fr_1fr_auto] sm:items-start"> + <Field + label="Latitude" + name="latitude" + kind="number" + step="0.00001" + min="-90" + max="90" + inputmode="decimal" + placeholder="45.76404" + value=latitude + error=field_error_of(value, "latitude") + /> + <Field + label="Longitude" + name="longitude" + kind="number" + step="0.00001" + min="-180" + max="180" + inputmode="decimal" + placeholder="4.83566" + value=longitude + error=field_error_of(value, "longitude") + /> + <SubmitButton pending=save_location.pending() class="sm:mt-[26px]"> + "Enregistrer" + </SubmitButton> + </div> + </ActionForm> + } +} + +/// Choix du thème : trois tuiles ; le choix est enregistré dès le clic. +#[component] +fn ThemePicker(update_theme: ServerAction<UpdateTheme>, current: Theme) -> impl IntoView { + let form = NodeRef::<html::Form>::new(); + view! { + <ActionForm action=update_theme node_ref=form> + <fieldset class="grid grid-cols-3 gap-3"> + <legend class="sr-only">"Thème"</legend> + {Theme::ALL + .into_iter() + .map(|theme| { + let icon = match theme { + Theme::System => IconName::Monitor, + Theme::Light => IconName::Sun, + Theme::Dark => IconName::Moon, + }; + view! { + <label class="flex cursor-pointer flex-col items-center gap-2 rounded-xl border-2 border-slate-200 p-3 text-sm font-medium transition hover:border-slate-300 has-[:checked]:border-blue-600 has-[:checked]:bg-blue-50 has-[:checked]:text-blue-700 has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-blue-600 dark:border-slate-700 dark:hover:border-slate-600 dark:has-[:checked]:border-blue-500 dark:has-[:checked]:bg-blue-500/10 dark:has-[:checked]:text-blue-300"> + <input + class="sr-only" + type="radio" + name="theme" + value=theme.as_str() + checked=theme == current + on:change=move |_| { + if let Some(form) = form.get() { + let _ = form.request_submit(); + } + } + /> + <Icon icon class="size-6" /> + {theme.label()} + </label> + } + }) + .collect_view()} + </fieldset> + // Sans JavaScript, le choix s'enregistre avec ce bouton. + <noscript> + <button type="submit" class="btn-primary mt-3">"Enregistrer"</button> + </noscript> + </ActionForm> + <div class="mt-3 empty:hidden"> + <ErrorBanner message=general_error_of(update_theme.value()) /> + </div> + } +} diff --git a/src/pages/rainfall.rs b/src/pages/rainfall.rs new file mode 100644 index 0000000..8e7841e --- /dev/null +++ b/src/pages/rainfall.rs @@ -0,0 +1,474 @@ +//! Pages Pluviométrie (graphique) et liste des mesures. + +use chrono::{Datelike, Months, NaiveDate}; +use leptos::prelude::*; +use leptos_router::components::A; + +use crate::{ + app::Protected, + chart::{Column, ColumnChart, Series}, + components::{AddRainfallForm, LastRainfalls, format_long_date, format_number}, + errors::{error_for_field, error_message, general_error}, + icons::{Icon, IconName}, + rainfall::{ + self, AddRainfall, DeleteRainfall, GraphPoint, PAGE_SIZE, Period, Rainfall, UpdateRainfall, + graph::{month_name, month_short}, + }, + ui::{Card, ErrorBanner, FieldError, Loading, Page, field_error_of, general_error_of}, +}; + +fn iso(date: NaiveDate) -> String { + date.format("%Y-%m-%d").to_string() +} + +#[component] +pub fn RainfallGraphPage() -> impl IntoView { + view! { <Protected render=|_| view! { <RainfallGraph /> } /> } +} + +/// Raccourcis de période : libellé et (début, regroupement) à partir d'aujourd'hui. +fn presets(today: NaiveDate) -> [(&'static str, NaiveDate, Period); 4] { + [ + ( + "30 jours", + today.checked_sub_months(Months::new(1)).unwrap_or(today), + Period::Day, + ), + ( + "12 semaines", + today - chrono::Duration::weeks(12), + Period::Week, + ), + ( + "12 mois", + today + .checked_sub_months(Months::new(11)) + .unwrap_or(today) + .with_day(1) + .unwrap_or(today), + Period::Month, + ), + ( + "Années", + NaiveDate::from_ymd_opt(today.year() - 9, 1, 1).unwrap_or(today), + Period::Year, + ), + ] +} + +#[component] +fn RainfallGraph() -> impl IntoView { + let add = ServerAction::<AddRainfall>::new(); + let reload = Signal::derive(move || add.version().get()); + + // Par défaut : le dernier mois, jour par jour. + let today = rainfall::today(); + let start = RwSignal::new(iso(presets(today)[0].1)); + let end = RwSignal::new(iso(today)); + let period = RwSignal::new(Period::Day); + + let graph = Resource::new( + move || (start.get(), end.get(), period.get(), reload.get()), + |(start, end, period, _)| rainfall::graph_data(start, end, period.as_str().to_string()), + ); + let pending = RwSignal::new(false); + let error = move || graph.get().and_then(Result::err); + let field_error = move |field: &'static str| { + Signal::derive(move || error().and_then(|e| error_for_field(&e, field))) + }; + + let segment = "rounded-md px-3 py-1.5 text-sm font-medium transition cursor-pointer"; + let segment_on = "bg-white text-slate-900 shadow-sm dark:bg-slate-700 dark:text-white"; + let segment_off = + "text-slate-600 hover:text-slate-900 dark:text-slate-400 dark:hover:text-white"; + + view! { + <Page title="Pluviométrie" subtitle="Cumuls de pluie sur la période choisie"> + <Card> + <div class="flex flex-col gap-4"> + // Raccourcis. + <div class="flex flex-wrap gap-2"> + {presets(today) + .into_iter() + .map(|(label, from, p)| { + let from = iso(from); + let to = iso(today); + let active = { + let (from, to) = (from.clone(), to.clone()); + Memo::new(move |_| start.get() == from && end.get() == to && period.get() == p) + }; + view! { + <button + type="button" + aria-pressed=move || active.get().to_string() + class=move || { + if active.get() { + "cursor-pointer rounded-full border border-blue-600 bg-blue-600 px-3 py-1 text-sm font-medium text-white transition" + } else { + "cursor-pointer rounded-full border border-slate-300 px-3 py-1 text-sm font-medium transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800" + } + } + on:click=move |_| { + start.set(from.clone()); + end.set(to.clone()); + period.set(p); + } + > + {label} + </button> + } + }) + .collect_view()} + </div> + <div class="flex flex-col gap-3 md:flex-row md:items-end"> + <div class="grid flex-1 grid-cols-2 gap-3 md:max-w-sm"> + <label class="flex flex-col gap-1.5 text-sm font-medium text-slate-700 dark:text-slate-300"> + "Du" + <input + class="input" + type="date" + prop:value=move || start.get() + on:change=move |ev| start.set(event_target_value(&ev)) + /> + </label> + <label class="flex flex-col gap-1.5 text-sm font-medium text-slate-700 dark:text-slate-300"> + "Au" + <input + class="input" + type="date" + prop:value=move || end.get() + on:change=move |ev| end.set(event_target_value(&ev)) + /> + </label> + </div> + // Regroupement : contrôle segmenté. + <div + class="inline-flex self-start rounded-lg bg-slate-100 p-1 md:self-auto dark:bg-slate-800" + role="radiogroup" + aria-label="Regroupement" + > + {Period::ALL + .into_iter() + .map(|p| { + view! { + <button + type="button" + role="radio" + aria-checked=move || (period.get() == p).to_string() + class=move || { + format!( + "{segment} {}", + if period.get() == p { segment_on } else { segment_off }, + ) + } + on:click=move |_| period.set(p) + > + {p.label()} + </button> + } + }) + .collect_view()} + </div> + </div> + <Transition> + <FieldError message=field_error("start") /> + <FieldError message=field_error("end") /> + <ErrorBanner message=Signal::derive(move || error().and_then(|e| general_error(&e))) /> + </Transition> + </div> + </Card> + + <Card> + <Transition fallback=|| view! { <Loading height="h-72" /> } set_pending=pending> + {move || { + graph + .get() + .map(|result| { + let points = result.unwrap_or_default(); + let period = period.get_untracked(); + view! { <GraphView points period pending /> } + }) + }} + </Transition> + </Card> + + <div class="grid gap-5 md:grid-cols-2 md:items-start"> + <AddRainfallForm add /> + <LastRainfalls reload /> + </div> + </Page> + } +} + +/// Libellé court de l'axe ; le libellé complet reste dans l'infobulle. +fn axis_label(point: &GraphPoint, period: Period) -> String { + let Ok(start) = NaiveDate::parse_from_str(&point.start, "%Y-%m-%d") else { + return point.label.clone(); + }; + match period { + Period::Day => start.format("%d/%m").to_string(), + Period::Week => format!("S{}", start.iso_week().week()), + Period::Month => format!("{} {}", month_short(start.month()), start.format("%y")), + Period::Year => start.year().to_string(), + } +} + +#[component] +fn GraphView(points: Vec<GraphPoint>, period: Period, pending: RwSignal<bool>) -> impl IntoView { + let total: i64 = points.iter().map(|p| p.value).sum(); + let days: u32 = points.iter().map(|p| p.days).sum(); + let rainy = points.iter().filter(|p| p.value > 0).count(); + let columns = points + .iter() + .map(|p| Column { + label: axis_label(p, period), + title: Some(if p.days > 1 { + format!("{} ({} jours)", p.label, p.days) + } else { + p.label.clone() + }), + values: vec![Some(p.value)], + }) + .collect::<Vec<_>>(); + let series = vec![Series { + name: "Pluie".into(), + color: "bg-chart-1", + }]; + + view! { + <div class="mb-2 flex flex-wrap items-baseline justify-between gap-2"> + <div> + <span class="text-3xl font-semibold tracking-tight">{format_number(total)}</span> + <span class="muted ml-1 font-medium">"mm"</span> + </div> + <p class="muted text-sm"> + {format!("sur {days} jour{}", if days > 1 { "s" } else { "" })} + {(points.len() > 1).then(|| format!(" · {rainy} période{} avec pluie", if rainy > 1 { "s" } else { "" }))} + </p> + </div> + <ColumnChart series columns loading=pending /> + } +} + +/// Regroupe des mesures (déjà triées par date décroissante) par mois : (« Octobre 2026 », mesures). +fn group_by_month(items: Vec<Rainfall>) -> Vec<(String, Vec<Rainfall>)> { + let mut groups: Vec<(String, Vec<Rainfall>)> = Vec::new(); + for item in items { + let title = NaiveDate::parse_from_str(&item.date, "%Y-%m-%d") + .map(|d| format!("{} {}", month_name(d.month()), d.year())) + .unwrap_or_default(); + match groups.last_mut() { + Some((last, group)) if *last == title => group.push(item), + _ => groups.push((title, vec![item])), + } + } + groups +} + +#[component] +pub fn RainfallIndexPage() -> impl IntoView { + view! { <Protected render=|_| view! { <RainfallIndex /> } /> } +} + +#[component] +fn RainfallIndex() -> impl IntoView { + let delete = ServerAction::<DeleteRainfall>::new(); + let update = ServerAction::<UpdateRainfall>::new(); + // Nombre de mesures affichées ; « Afficher plus » en ajoute une page. + let limit = RwSignal::new(PAGE_SIZE); + let editing = RwSignal::new(None::<i64>); + + let list = Resource::new( + move || (limit.get(), delete.version().get(), update.version().get()), + |(limit, ..)| rainfall::list_rainfalls(limit), + ); + + // Referme l'édition une fois la modification enregistrée. + Effect::new(move |_| { + if matches!(update.value().get(), Some(Ok(()))) { + editing.set(None); + } + }); + + view! { + <Page title="Toutes les mesures"> + <A href="/pluviometrie" attr:class="btn-ghost -mt-3 self-start"> + <Icon icon=IconName::ArrowRight class="size-4 rotate-180" /> + "Retour au graphique" + </A> + <ErrorBanner message=general_error_of(delete.value()) /> + <Transition fallback=|| view! { <Loading height="h-96" /> }> + {move || { + list.get() + .map(|result| match result { + Ok(page) if page.items.is_empty() => { + view! { + <Card> + <p class="muted py-8 text-center">"Aucune mesure enregistrée."</p> + </Card> + } + .into_any() + } + Ok(page) => { + let has_more = (page.items.len() as i64) < page.total; + let shown = page.items.len(); + view! { + <div class="surface overflow-hidden"> + <ul class="divide-y divide-slate-100 dark:divide-slate-800"> + {group_by_month(page.items) + .into_iter() + .map(|(title, items)| { + view! { + <li class="muted bg-slate-50 px-4 py-1.5 text-xs font-semibold tracking-wide uppercase dark:bg-slate-800/50"> + {title} + </li> + {items + .into_iter() + .map(|rainfall| view! { <RainfallRow rainfall editing update delete /> }) + .collect_view()} + } + }) + .collect_view()} + </ul> + <div class="flex items-center justify-between gap-3 border-t border-slate-100 px-4 py-3 text-sm dark:border-slate-800"> + <span class="muted">{format!("{shown} sur {} mesures", page.total)}</span> + {has_more + .then(|| { + view! { + <button + type="button" + class="btn-ghost" + on:click=move |_| limit.update(|l| *l += PAGE_SIZE) + > + "Afficher plus" + <Icon icon=IconName::ChevronDown class="size-4" /> + </button> + } + })} + </div> + </div> + } + .into_any() + } + Err(e) => view! { <ErrorBanner message=Some(error_message(&e)) /> }.into_any(), + }) + }} + </Transition> + </Page> + } +} + +/// Ligne de la liste : affichage, ou formulaire d'édition en place. +#[component] +fn RainfallRow( + rainfall: Rainfall, + editing: RwSignal<Option<i64>>, + update: ServerAction<UpdateRainfall>, + delete: ServerAction<DeleteRainfall>, +) -> impl IntoView { + let id = rainfall.id; + let is_editing = move || editing.get() == Some(id); + let icon_button = "flex size-9 cursor-pointer items-center justify-center rounded-lg text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-800 dark:hover:text-white"; + + view! { + <li class="px-4 py-3"> + <Show + when=is_editing + fallback={ + let rainfall = rainfall.clone(); + move || { + view! { + <div class="flex items-center gap-3"> + <div class="min-w-0 flex-1"> + <div class="font-medium first-letter:uppercase">{format_long_date(&rainfall.date)}</div> + </div> + <span class="rounded-full bg-blue-50 px-2.5 py-0.5 text-sm font-semibold text-blue-700 tabular-nums dark:bg-blue-500/10 dark:text-blue-300"> + {rainfall.value} " mm" + </span> + <div class="flex"> + <button + type="button" + class=icon_button + title="Modifier" + aria-label="Modifier" + on:click=move |_| { + update.value().set(None); + editing.set(Some(id)); + } + > + <Icon icon=IconName::Pencil class="size-4" /> + </button> + <ActionForm action=delete> + <input type="hidden" name="id" value=id /> + <button + type="submit" + class=format!("{icon_button} hover:!bg-red-50 hover:!text-red-600 dark:hover:!bg-red-500/10 dark:hover:!text-red-400") + title="Supprimer" + aria-label="Supprimer" + > + <Icon icon=IconName::Trash class="size-4" /> + </button> + </ActionForm> + </div> + </div> + } + } + } + > + <EditRainfallForm id date=rainfall.date.clone() amount=rainfall.value update editing /> + </Show> + </li> + } +} + +#[component] +fn EditRainfallForm( + id: i64, + date: String, + amount: i64, + update: ServerAction<UpdateRainfall>, + editing: RwSignal<Option<i64>>, +) -> impl IntoView { + let value = update.value(); + view! { + <ActionForm action=update attr:class="flex flex-wrap items-start gap-2"> + <input type="hidden" name="id" value=id /> + <div class="flex min-w-36 flex-1 flex-col gap-1"> + <input class="input" type="date" name="date" value=date required aria-label="Date" /> + <FieldError message=field_error_of(value, "date") /> + </div> + <div class="flex w-24 flex-col gap-1"> + <input + class="input" + type="number" + name="value" + min="1" + max="1000" + inputmode="numeric" + value=amount + required + aria-label="Pluie en mm" + /> + <FieldError message=field_error_of(value, "value") /> + </div> + <div class="flex gap-1"> + <button type="submit" class="btn-primary h-[42px]" disabled=move || update.pending().get()> + <Icon icon=IconName::Check class="size-4" /> + <span class="sr-only sm:not-sr-only">"Enregistrer"</span> + </button> + <button + type="button" + class="btn-ghost h-[42px]" + title="Annuler" + on:click=move |_| editing.set(None) + > + <Icon icon=IconName::X class="size-4" /> + <span class="sr-only">"Annuler"</span> + </button> + </div> + <div class="w-full empty:hidden"> + <ErrorBanner message=general_error_of(value) /> + </div> + </ActionForm> + } +} diff --git a/src/pages/weather.rs b/src/pages/weather.rs new file mode 100644 index 0000000..b0919be --- /dev/null +++ b/src/pages/weather.rs @@ -0,0 +1,210 @@ +//! Page Météo : conditions actuelles et prévisions des jours suivants. + +use leptos::prelude::*; +use leptos_router::components::A; + +use crate::{ + app::Protected, + errors::error_message, + icons::{Icon, IconName}, + ui::{Card, ErrorBanner, Loading, Page}, + weather::{self, CurrentWeather, DayForecast, Slot}, +}; + +/// Les prévisions sont rechargées toutes les 5 minutes tant que la page est ouverte. +const REFRESH_SECONDS: u64 = 5 * 60; + +fn icon_src(icon: &str) -> String { + format!("/images/icons/{icon}.svg") +} + +fn degrees(value: f64) -> String { + format!("{:.0}°", value) +} + +#[component] +pub fn WeatherPage() -> impl IntoView { + view! { + <Protected render=|user| { + if user.has_location() { + view! { <Weather /> }.into_any() + } else { + view! { + <Page title="Météo"> + <Card> + <div class="flex flex-col items-center gap-3 py-8 text-center"> + <span class="flex size-12 items-center justify-center rounded-full bg-blue-50 text-blue-600 dark:bg-blue-500/10 dark:text-blue-400"> + <Icon icon=IconName::MapPin class="size-6" /> + </span> + <p class="font-medium">"Aucun emplacement défini"</p> + <p class="muted max-w-sm text-sm"> + "Indiquez les coordonnées de votre pluviomètre pour afficher les prévisions." + </p> + <A href="/profile" attr:class="btn-primary mt-2"> + "Définir l'emplacement" + </A> + </div> + </Card> + </Page> + } + .into_any() + } + } /> + } +} + +#[component] +fn Weather() -> impl IntoView { + let tick = RwSignal::new(0u32); + let forecast = Resource::new(move || tick.get(), |_| weather::get_weather()); + let pending = RwSignal::new(false); + + // Côté client uniquement (les effets ne s'exécutent pas pendant le rendu serveur). + Effect::new(move |_| { + if let Ok(handle) = set_interval_with_handle( + move || tick.update(|t| *t += 1), + std::time::Duration::from_secs(REFRESH_SECONDS), + ) { + on_cleanup(move || handle.clear()); + } + }); + + view! { + <Page title="Météo" subtitle="Prévisions à 5 jours pour votre emplacement"> + <Transition + fallback=|| { + view! { + <Loading height="h-48" /> + <Loading height="h-80" /> + } + } + set_pending=pending + > + {move || { + forecast + .get() + .map(|result| match result { + Ok(view) => { + // Bornes de la semaine, pour situer la plage de chaque jour. + let low = view.days.iter().map(|d| d.min).fold(f64::INFINITY, f64::min); + let high = view.days.iter().map(|d| d.max).fold(f64::NEG_INFINITY, f64::max); + view! { + {view.current.map(|current| view! { <CurrentCard current pending /> })} + <section class="surface overflow-hidden"> + <h2 class="flex items-center gap-2.5 px-4 pt-4 pb-2 font-semibold sm:px-5"> + <span class="flex size-8 items-center justify-center rounded-lg bg-blue-50 text-blue-600 dark:bg-blue-500/10 dark:text-blue-400"> + <Icon icon=IconName::Calendar class="size-4" /> + </span> + "Prochains jours" + </h2> + <ul class="divide-y divide-slate-100 dark:divide-slate-800"> + {view + .days + .into_iter() + .map(|day| view! { <DayRow day low high /> }) + .collect_view()} + </ul> + </section> + } + .into_any() + } + Err(e) => view! { <ErrorBanner message=Some(error_message(&e)) /> }.into_any(), + }) + }} + </Transition> + </Page> + } +} + +#[component] +fn CurrentCard(current: CurrentWeather, pending: RwSignal<bool>) -> impl IntoView { + view! { + <section + class="relative overflow-hidden rounded-2xl bg-gradient-to-br from-sky-500 via-blue-600 to-indigo-700 p-6 text-white shadow-lg sm:p-8" + class=("animate-pulse", move || pending.get()) + > + // Halo décoratif. + <div class="pointer-events-none absolute -top-16 -right-16 size-64 rounded-full bg-white/10 blur-2xl"></div> + <div class="relative flex items-center justify-between gap-4"> + <div class="flex flex-col gap-1"> + <span class="text-sm font-medium text-white/80">"Maintenant"</span> + <span class="text-7xl font-semibold tracking-tighter sm:text-8xl">{degrees(current.temp)}</span> + <span class="text-lg font-medium first-letter:uppercase">{current.description.clone()}</span> + <span class="mt-1 text-sm text-white/80"> + "Max. " {degrees(current.temp_max)} " · Min. " {degrees(current.temp_min)} + </span> + </div> + <img + class="size-28 drop-shadow-xl sm:size-40" + src=icon_src(¤t.icon) + alt="" + width="160" + height="160" + /> + </div> + </section> + } +} + +#[component] +fn DayRow(day: DayForecast, low: f64, high: f64) -> impl IntoView { + let open = RwSignal::new(false); + let slots_id = format!("slots-{}", day.date); + // Position de la plage du jour dans celle de la semaine, en pourcentages. + let span = (high - low).max(1.0); + let left = (day.min - low) / span * 100.0; + let width = ((day.max - day.min) / span * 100.0).max(4.0); + + view! { + <li> + <button + type="button" + class="flex w-full cursor-pointer items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 sm:gap-4 sm:px-5 dark:hover:bg-slate-800/50" + aria-expanded=move || open.get().to_string() + aria-controls=slots_id.clone() + on:click=move |_| open.update(|o| *o = !*o) + > + <div class="w-24 shrink-0 sm:w-32"> + <div class="font-medium first-letter:uppercase">{day.weekday.clone()}</div> + <div class="muted text-xs">{day.date_fr.clone()}</div> + </div> + <img class="size-10 shrink-0" src=icon_src(&day.icon) alt="" width="40" height="40" /> + <span class="muted hidden min-w-0 flex-1 truncate text-sm first-letter:uppercase sm:block"> + {day.description.clone()} + </span> + <div class="flex flex-1 items-center gap-2 tabular-nums sm:w-56 sm:flex-none"> + <span class="muted w-8 text-right text-sm">{degrees(day.min)}</span> + <div class="relative h-1.5 flex-1 rounded-full bg-slate-100 dark:bg-slate-800"> + <div + class="absolute inset-y-0 rounded-full bg-gradient-to-r from-sky-400 to-amber-400" + style=format!("left: {left:.1}%; width: {width:.1}%") + ></div> + </div> + <span class="w-8 text-sm font-semibold">{degrees(day.max)}</span> + </div> + <span class="text-slate-400 transition-transform" class=("rotate-180", move || open.get())> + <Icon icon=IconName::ChevronDown class="size-4" /> + </span> + </button> + <ul + id=slots_id + class="flex gap-2 overflow-x-auto px-4 pb-4 sm:px-5" + class=("hidden", move || !open.get()) + > + {day.slots.into_iter().map(|slot| view! { <SlotItem item=slot /> }).collect_view()} + </ul> + </li> + } +} + +#[component] +fn SlotItem(item: Slot) -> impl IntoView { + view! { + <li class="flex w-24 shrink-0 flex-col items-center gap-1 rounded-xl bg-slate-50 px-2 py-3 text-center dark:bg-slate-800/60"> + <span class="muted text-xs font-medium">{format!("{} h", item.hour)}</span> + <img class="size-10" src=icon_src(&item.icon) alt="" width="40" height="40" /> + <span class="font-semibold tabular-nums">{format!("{:.1}°", item.temp)}</span> + <span class="muted line-clamp-2 text-[11px] leading-tight">{item.description}</span> + </li> + } +} diff --git a/src/profile.rs b/src/profile.rs new file mode 100644 index 0000000..9350934 --- /dev/null +++ b/src/profile.rs @@ -0,0 +1,77 @@ +//! Apparence choisie par l'utilisateur (thème clair / sombre). + +use leptos::prelude::*; +use serde::{Deserialize, Serialize}; + +#[cfg(feature = "ssr")] +use crate::server; + +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +pub enum Theme { + /// Suit le réglage clair / sombre du système. + #[default] + System, + Light, + Dark, +} + +impl Theme { + pub const ALL: [Theme; 3] = [Theme::System, Theme::Light, Theme::Dark]; + + /// Valeur stockée en base et envoyée par le formulaire. + pub fn as_str(self) -> &'static str { + match self { + Theme::System => "system", + Theme::Light => "light", + Theme::Dark => "dark", + } + } + + pub fn parse(value: &str) -> Option<Theme> { + Theme::ALL.into_iter().find(|theme| theme.as_str() == value) + } + + pub fn label(self) -> &'static str { + match self { + Theme::System => "Automatique", + Theme::Light => "Clair", + Theme::Dark => "Sombre", + } + } + + /// Valeur de l'attribut `data-theme` de `<html>` ; `None` pour « automatique ». + pub fn html_attr(self) -> Option<&'static str> { + match self { + Theme::System => None, + other => Some(other.as_str()), + } + } +} + +#[server] +pub async fn update_theme(theme: String) -> Result<(), ServerFnError> { + let user_id = server::require_user_id().await?; + let theme = Theme::parse(&theme).ok_or_else(|| ServerFnError::new("Apparence invalide."))?; + sqlx::query("UPDATE users SET theme = ?1, updated_at = CURRENT_TIMESTAMP WHERE id = ?2") + .bind(theme.as_str()) + .bind(user_id) + .execute(&server::pool()?) + .await + .map_err(server::internal_error)?; + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn theme_round_trips() { + for theme in Theme::ALL { + assert_eq!(Theme::parse(theme.as_str()), Some(theme)); + } + assert_eq!(Theme::parse("auto"), None); + assert_eq!(Theme::System.html_attr(), None); + assert_eq!(Theme::Dark.html_attr(), Some("dark")); + } +} diff --git a/src/rainfall.rs b/src/rainfall.rs new file mode 100644 index 0000000..b804a05 --- /dev/null +++ b/src/rainfall.rs @@ -0,0 +1,258 @@ +//! Mesures de pluviométrie : saisie, liste, graphique et cumuls mensuels. + +pub mod graph; + +use chrono::NaiveDate; +use leptos::prelude::*; +use serde::{Deserialize, Serialize}; + +pub use graph::{GraphPoint, MonthlySummary, Period}; + +use crate::errors::field_error; +#[cfg(feature = "ssr")] +use crate::server; + +/// Taille d'une page de la liste des mesures (comme le `paginate(15)` de Laravel). +pub const PAGE_SIZE: i64 = 15; +pub const VALUE_MIN: i64 = 1; +pub const VALUE_MAX: i64 = 1000; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Rainfall { + pub id: i64, + /// AAAA-MM-JJ + pub date: String, + /// Hauteur d'eau en mm. + pub value: i64, +} + +impl Rainfall { + /// Date au format français (JJ/MM/AAAA). + pub fn date_fr(&self) -> String { + format_date_fr(&self.date) + } +} + +pub fn format_date_fr(date: &str) -> String { + NaiveDate::parse_from_str(date, "%Y-%m-%d") + .map(|d| d.format("%d/%m/%Y").to_string()) + .unwrap_or_else(|_| date.to_string()) +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct RainfallPage { + pub items: Vec<Rainfall>, + pub total: i64, +} + +/// Date du jour (fuseau du serveur côté SSR, du navigateur côté client). +pub fn today() -> NaiveDate { + chrono::Local::now().date_naive() +} + +/// Lit une date `AAAA-MM-JJ` (format des `<input type="date">`). +pub fn parse_date(field: &str, value: &str) -> Result<NaiveDate, ServerFnError> { + NaiveDate::parse_from_str(value.trim(), "%Y-%m-%d") + .ok() + .filter(|d| (1900..=2200).contains(&chrono::Datelike::year(d))) + .ok_or_else(|| field_error(field, "Veuillez saisir une date valide.")) +} + +/// Lit une hauteur d'eau entière entre 1 et 1000 mm. +pub fn parse_value(value: &str) -> Result<i64, ServerFnError> { + let message = format!("La mesure doit être un nombre entier entre {VALUE_MIN} et {VALUE_MAX}."); + let number: i64 = value + .trim() + .parse() + .map_err(|_| field_error("value", message.clone()))?; + if !(VALUE_MIN..=VALUE_MAX).contains(&number) { + return Err(field_error("value", message)); + } + Ok(number) +} + +#[server] +pub async fn add_rainfall(date: String, value: String) -> Result<(), ServerFnError> { + let user_id = server::require_user_id().await?; + let date = parse_date("date", &date)?; + let value = parse_value(&value)?; + sqlx::query("INSERT INTO rainfalls (user_id, date, value) VALUES (?1, ?2, ?3)") + .bind(user_id) + .bind(date.format("%Y-%m-%d").to_string()) + .bind(value) + .execute(&server::pool()?) + .await + .map_err(server::internal_error)?; + Ok(()) +} + +#[server] +pub async fn update_rainfall(id: i64, date: String, value: String) -> Result<(), ServerFnError> { + let user_id = server::require_user_id().await?; + let date = parse_date("date", &date)?; + let value = parse_value(&value)?; + let done = sqlx::query( + "UPDATE rainfalls SET date = ?1, value = ?2, updated_at = CURRENT_TIMESTAMP \ + WHERE id = ?3 AND user_id = ?4", + ) + .bind(date.format("%Y-%m-%d").to_string()) + .bind(value) + .bind(id) + .bind(user_id) + .execute(&server::pool()?) + .await + .map_err(server::internal_error)?; + if done.rows_affected() == 0 { + return Err(ServerFnError::new("Mesure introuvable.")); + } + Ok(()) +} + +#[server] +pub async fn delete_rainfall(id: i64) -> Result<(), ServerFnError> { + let user_id = server::require_user_id().await?; + sqlx::query("DELETE FROM rainfalls WHERE id = ?1 AND user_id = ?2") + .bind(id) + .bind(user_id) + .execute(&server::pool()?) + .await + .map_err(server::internal_error)?; + Ok(()) +} + +/// Les `limit` mesures les plus récentes, et le nombre total de mesures. +#[server] +pub async fn list_rainfalls(limit: i64) -> Result<RainfallPage, ServerFnError> { + let user_id = server::require_user_id().await?; + let pool = server::pool()?; + let items = sqlx::query_as::<_, (i64, String, i64)>( + "SELECT id, date, value FROM rainfalls WHERE user_id = ?1 ORDER BY date DESC, id DESC LIMIT ?2", + ) + .bind(user_id) + .bind(limit.clamp(1, 10_000)) + .fetch_all(&pool) + .await + .map_err(server::internal_error)? + .into_iter() + .map(|(id, date, value)| Rainfall { id, date, value }) + .collect(); + let total = sqlx::query_scalar::<_, i64>("SELECT COUNT(*) FROM rainfalls WHERE user_id = ?1") + .bind(user_id) + .fetch_one(&pool) + .await + .map_err(server::internal_error)?; + Ok(RainfallPage { items, total }) +} + +/// Cumuls à afficher dans le graphique de la page Pluviométrie. +#[server] +pub async fn graph_data( + start: String, + end: String, + period: String, +) -> Result<Vec<GraphPoint>, ServerFnError> { + use std::collections::HashMap; + + let user_id = server::require_user_id().await?; + let start = parse_date("start", &start)?; + let end = parse_date("end", &end)?; + let period = + Period::parse(&period).ok_or_else(|| field_error("period", "Période invalide."))?; + if end < start { + return Err(field_error( + "end", + "La date de fin doit être postérieure à la date de début.", + )); + } + if (end - start).num_days() > period.max_days() { + return Err(field_error( + "start", + "Intervalle trop long pour ce regroupement : choisissez une période plus courte ou un regroupement plus large.", + )); + } + + let rows = sqlx::query_as::<_, (String, i64)>( + "SELECT date, SUM(value) FROM rainfalls \ + WHERE user_id = ?1 AND date BETWEEN ?2 AND ?3 GROUP BY date", + ) + .bind(user_id) + .bind(start.format("%Y-%m-%d").to_string()) + .bind(end.format("%Y-%m-%d").to_string()) + .fetch_all(&server::pool()?) + .await + .map_err(server::internal_error)?; + let daily: HashMap<NaiveDate, i64> = rows + .into_iter() + .filter_map(|(date, sum)| Some((NaiveDate::parse_from_str(&date, "%Y-%m-%d").ok()?, sum))) + .collect(); + + Ok(graph::group(start, end, period, &daily)) +} + +/// Cumuls mensuels de l'année en cours et de la précédente (page d'accueil). +#[server] +pub async fn last_months() -> Result<MonthlySummary, ServerFnError> { + use chrono::Datelike; + use std::collections::HashMap; + + let user_id = server::require_user_id().await?; + let pool = server::pool()?; + let today = today(); + let rows = sqlx::query_as::<_, (String, i64)>( + "SELECT substr(date, 1, 7) AS month, SUM(value) FROM rainfalls \ + WHERE user_id = ?1 AND date >= ?2 GROUP BY month", + ) + .bind(user_id) + .bind(format!("{}-01-01", today.year() - 1)) + .fetch_all(&pool) + .await + .map_err(server::internal_error)?; + let sums: HashMap<(i32, u32), i64> = rows + .into_iter() + .filter_map(|(month, sum)| { + let (year, month) = month.split_once('-')?; + Some(((year.parse().ok()?, month.parse().ok()?), sum)) + }) + .collect(); + + let first_year = sqlx::query_scalar::<_, Option<String>>( + "SELECT MIN(date) FROM rainfalls WHERE user_id = ?1", + ) + .bind(user_id) + .fetch_one(&pool) + .await + .map_err(server::internal_error)? + .and_then(|date| date.get(..4)?.parse().ok()); + + Ok(graph::monthly_summary(today, &sums, first_year)) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn values_must_be_between_1_and_1000() { + assert_eq!(parse_value("1").unwrap(), 1); + assert_eq!(parse_value(" 1000 ").unwrap(), 1000); + for value in ["0", "1001", "-3", "2.5", "", "abc"] { + assert!(parse_value(value).is_err(), "{value:?}"); + } + } + + #[test] + fn dates_are_parsed() { + assert_eq!( + parse_date("date", "2023-02-28").unwrap(), + NaiveDate::from_ymd_opt(2023, 2, 28).unwrap() + ); + for value in ["2023-02-30", "28/02/2023", "", "0001-01-01"] { + assert!(parse_date("date", value).is_err(), "{value:?}"); + } + } + + #[test] + fn french_dates() { + assert_eq!(format_date_fr("2023-02-08"), "08/02/2023"); + } +} diff --git a/src/rainfall/graph.rs b/src/rainfall/graph.rs new file mode 100644 index 0000000..aefa696 --- /dev/null +++ b/src/rainfall/graph.rs @@ -0,0 +1,353 @@ +//! Regroupement des mesures par jour / semaine / mois / année (fonctions pures, testées). +//! +//! Port de `RainfallController::graphValue`, `Rainfall::getDateKey` et +//! `Rainfall::getDateKeyData` de lara-bermite. + +use chrono::{Datelike, NaiveDate}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +pub const MONTHS: [&str; 12] = [ + "Janvier", + "Février", + "Mars", + "Avril", + "Mai", + "Juin", + "Juillet", + "Août", + "Septembre", + "Octobre", + "Novembre", + "Décembre", +]; + +/// Abréviations usuelles (juin et juillet restent distincts). +pub const MONTHS_SHORT: [&str; 12] = [ + "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", + "déc.", +]; + +pub fn month_short(month: u32) -> &'static str { + MONTHS_SHORT[(month as usize).saturating_sub(1).min(11)] +} + +pub fn month_name(month: u32) -> &'static str { + MONTHS[(month as usize).saturating_sub(1).min(11)] +} + +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +pub enum Period { + #[default] + Day, + Week, + Month, + Year, +} + +impl Period { + pub const ALL: [Period; 4] = [Period::Day, Period::Week, Period::Month, Period::Year]; + + pub fn as_str(self) -> &'static str { + match self { + Period::Day => "day", + Period::Week => "week", + Period::Month => "month", + Period::Year => "year", + } + } + + pub fn parse(value: &str) -> Option<Period> { + Period::ALL.into_iter().find(|p| p.as_str() == value) + } + + pub fn label(self) -> &'static str { + match self { + Period::Day => "Jour", + Period::Week => "Semaine", + Period::Month => "Mois", + Period::Year => "Année", + } + } + + /// Nombre maximal de jours affichables pour ce regroupement (lisibilité du graphique). + pub fn max_days(self) -> i64 { + match self { + Period::Day => 366 * 2, + Period::Week => 366 * 10, + Period::Month | Period::Year => 366 * 100, + } + } + + /// Clé identifiant le groupe auquel appartient `date`. + fn key(self, date: NaiveDate) -> (i32, u32) { + match self { + Period::Day => (date.year(), date.ordinal()), + Period::Week => { + let week = date.iso_week(); + (week.year(), week.week()) + } + Period::Month => (date.year(), date.month()), + Period::Year => (date.year(), 0), + } + } + + fn label_for(self, date: NaiveDate) -> String { + match self { + Period::Day => date.format("%d/%m/%Y").to_string(), + Period::Week => format!("semaine {}", date.iso_week().week()), + Period::Month => format!("{} {}", month_name(date.month()), date.year()), + Period::Year => date.year().to_string(), + } + } +} + +/// Une barre du graphique. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct GraphPoint { + /// Premier jour du groupe compris dans l'intervalle demandé (AAAA-MM-JJ). + pub start: String, + /// Nombre de jours du groupe compris dans l'intervalle demandé. + pub days: u32, + pub label: String, + /// Cumul des mesures du groupe, en mm. + pub value: i64, +} + +/// Regroupe les cumuls journaliers `daily` sur l'intervalle `[start, end]` (bornes incluses). +/// Chaque groupe de l'intervalle apparaît, même sans mesure (valeur 0). +pub fn group( + start: NaiveDate, + end: NaiveDate, + period: Period, + daily: &HashMap<NaiveDate, i64>, +) -> Vec<GraphPoint> { + let mut points: Vec<GraphPoint> = Vec::new(); + let mut current_key = None; + for date in start.iter_days().take_while(|d| *d <= end) { + let key = period.key(date); + if current_key != Some(key) { + current_key = Some(key); + points.push(GraphPoint { + start: date.format("%Y-%m-%d").to_string(), + days: 0, + label: period.label_for(date), + value: 0, + }); + } + let point = points.last_mut().expect("un groupe vient d'être créé"); + point.days += 1; + point.value += daily.get(&date).copied().unwrap_or(0); + } + points +} + +/// Une ligne du tableau « Précipitations des derniers mois ». +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct MonthRow { + pub month: u32, + pub label: String, + /// Cumul de l'année en cours ; `None` pour les mois pas encore commencés. + pub current: Option<i64>, + pub previous: i64, +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct MonthlySummary { + pub current_year: i32, + pub rows: Vec<MonthRow>, + pub total_current: i64, + pub total_previous: i64, + /// Cumul de l'an dernier sur les mêmes mois (janvier au mois en cours inclus). + pub total_previous_to_date: i64, + /// Année de la plus ancienne mesure. + pub first_year: Option<i32>, +} + +/// Port de `RainfallController::lastMonths` : de janvier de l'an dernier au mois en cours. +/// `sums` associe (année, mois) au cumul du mois. +pub fn monthly_summary( + today: NaiveDate, + sums: &HashMap<(i32, u32), i64>, + first_year: Option<i32>, +) -> MonthlySummary { + let year = today.year(); + let rows: Vec<MonthRow> = (1..=12) + .map(|month| MonthRow { + month, + label: month_name(month).to_string(), + current: (month <= today.month()) + .then(|| sums.get(&(year, month)).copied().unwrap_or(0)), + previous: sums.get(&(year - 1, month)).copied().unwrap_or(0), + }) + .collect(); + MonthlySummary { + current_year: year, + total_current: rows.iter().filter_map(|r| r.current).sum(), + total_previous: rows.iter().map(|r| r.previous).sum(), + total_previous_to_date: rows + .iter() + .filter(|r| r.current.is_some()) + .map(|r| r.previous) + .sum(), + rows, + first_year, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn d(s: &str) -> NaiveDate { + NaiveDate::parse_from_str(s, "%Y-%m-%d").unwrap() + } + + fn sample() -> HashMap<NaiveDate, i64> { + HashMap::from([ + (d("2022-11-20"), 4), + (d("2023-01-01"), 3), + (d("2023-01-02"), 5), + (d("2023-01-20"), 7), + (d("2023-02-01"), 2), + (d("2023-02-06"), 1), + (d("2023-03-31"), 10), + ]) + } + + #[test] + fn by_day() { + let points = group(d("2023-01-01"), d("2023-01-31"), Period::Day, &sample()); + assert_eq!(points.len(), 31); + assert_eq!( + points[0], + GraphPoint { + start: "2023-01-01".into(), + days: 1, + label: "01/01/2023".into(), + value: 3 + } + ); + assert_eq!( + points[1], + GraphPoint { + start: "2023-01-02".into(), + days: 1, + label: "02/01/2023".into(), + value: 5 + } + ); + assert_eq!(points[2].value, 0); + } + + #[test] + fn by_week_uses_iso_weeks() { + // Le 1er février 2023 est un mercredi : la première semaine ne compte que 5 jours. + let points = group(d("2023-02-01"), d("2023-02-28"), Period::Week, &sample()); + assert_eq!( + points[0], + GraphPoint { + start: "2023-02-01".into(), + days: 5, + label: "semaine 5".into(), + value: 2 + } + ); + assert_eq!( + points[1], + GraphPoint { + start: "2023-02-06".into(), + days: 7, + label: "semaine 6".into(), + value: 1 + } + ); + assert_eq!(points.iter().map(|p| p.days).sum::<u32>(), 28); + } + + #[test] + fn by_month() { + let points = group(d("2023-01-15"), d("2023-04-10"), Period::Month, &sample()); + assert_eq!( + points[0], + GraphPoint { + start: "2023-01-15".into(), + days: 17, + label: "Janvier 2023".into(), + value: 7 + } + ); + assert_eq!( + points[1], + GraphPoint { + start: "2023-02-01".into(), + days: 28, + label: "Février 2023".into(), + value: 3 + } + ); + assert_eq!( + points[2], + GraphPoint { + start: "2023-03-01".into(), + days: 31, + label: "Mars 2023".into(), + value: 10 + } + ); + assert_eq!(points[3].days, 10); + } + + #[test] + fn by_year() { + let points = group(d("2022-11-15"), d("2024-12-31"), Period::Year, &sample()); + assert_eq!( + points[0], + GraphPoint { + start: "2022-11-15".into(), + days: 47, + label: "2022".into(), + value: 4 + } + ); + assert_eq!(points[1].start, "2023-01-01"); + assert_eq!(points[1].days, 365); + assert_eq!(points[1].value, 28); + // 2024 est bissextile. + assert_eq!(points[2].days, 366); + } + + #[test] + fn empty_when_end_before_start() { + assert!(group(d("2023-02-01"), d("2023-01-01"), Period::Day, &sample()).is_empty()); + } + + #[test] + fn monthly_summary_covers_last_and_current_year() { + let sums = HashMap::from([ + ((2023, 1), 15), + ((2023, 3), 10), + ((2022, 1), 6), + ((2022, 12), 8), + ]); + let summary = monthly_summary(d("2023-03-14"), &sums, Some(2021)); + assert_eq!(summary.current_year, 2023); + assert_eq!(summary.rows.len(), 12); + assert_eq!( + summary.rows[0], + MonthRow { + month: 1, + label: "Janvier".into(), + current: Some(15), + previous: 6 + } + ); + assert_eq!(summary.rows[1].current, Some(0)); + assert_eq!(summary.rows[3].current, None, "avril n'a pas commencé"); + assert_eq!(summary.rows[11].previous, 8); + assert_eq!(summary.total_current, 25); + assert_eq!(summary.total_previous, 14); + assert_eq!(summary.total_previous_to_date, 6); + assert_eq!(summary.first_year, Some(2021)); + } +} diff --git a/src/server.rs b/src/server.rs new file mode 100644 index 0000000..838bbb2 --- /dev/null +++ b/src/server.rs @@ -0,0 +1,246 @@ +//! Code exécuté uniquement côté serveur : configuration, base de données, mots de passe, session. + +use argon2::{ + Argon2, + password_hash::{ + PasswordHash, PasswordHasher, PasswordVerifier, SaltString, + rand_core::{OsRng, RngCore}, + }, +}; +use leptos::prelude::*; +use sha2::{Digest, Sha256}; +use sqlx::{ + SqlitePool, + sqlite::{SqliteConnectOptions, SqlitePoolOptions}, +}; +use std::{error::Error, fmt::Display, str::FromStr, sync::Arc, sync::LazyLock}; +use tower_sessions::Session; + +use crate::weather::WeatherCache; + +/// Clé sous laquelle l'identifiant de l'utilisateur est stocké dans la session. +pub const USER_ID_KEY: &str = "user_id"; + +/// Réglages lus dans l'environnement (fichier `.env` au besoin). +#[derive(Clone, Debug)] +pub struct Config { + /// URL publique du site, sans `/` final : sert au lien de réinitialisation. + pub app_url: String, + pub open_weather_map_api_key: Option<String>, + pub smtp: Option<SmtpConfig>, + pub mail_from: String, + pub registration_enabled: bool, +} + +#[derive(Clone, Debug)] +pub struct SmtpConfig { + pub host: String, + pub port: u16, + pub username: String, + pub password: String, +} + +impl Config { + pub fn from_env() -> Config { + let var = |name: &str| std::env::var(name).ok().filter(|v| !v.trim().is_empty()); + let smtp = var("SMTP_HOST").map(|host| SmtpConfig { + host, + port: var("SMTP_PORT").and_then(|p| p.parse().ok()).unwrap_or(465), + username: var("SMTP_USERNAME").unwrap_or_default(), + password: var("SMTP_PASSWORD").unwrap_or_default(), + }); + Config { + app_url: var("APP_URL") + .unwrap_or_else(|| "http://127.0.0.1:3004".into()) + .trim_end_matches('/') + .to_string(), + open_weather_map_api_key: var("OPEN_WEATHER_MAP_API_KEY"), + smtp, + mail_from: var("MAIL_FROM").unwrap_or_else(|| "Bermite <bermite@localhost>".into()), + registration_enabled: var("REGISTRATION_ENABLED").is_some_and(|v| v == "true"), + } + } +} + +/// Tout ce que les server functions trouvent dans leur contexte. +#[derive(Clone)] +pub struct AppContext { + pub pool: SqlitePool, + pub config: Arc<Config>, + pub http: reqwest::Client, + pub weather_cache: WeatherCache, +} + +/// Ouvre le pool SQLite (en créant le fichier au besoin) et applique les migrations. +pub async fn connect_db(url: &str) -> Result<SqlitePool, Box<dyn Error>> { + let options = SqliteConnectOptions::from_str(url)? + .create_if_missing(true) + .foreign_keys(true); + let pool = SqlitePoolOptions::new() + .max_connections(5) + .connect_with(options) + .await?; + sqlx::migrate!().run(&pool).await?; + Ok(pool) +} + +fn context() -> Result<AppContext, ServerFnError> { + use_context::<AppContext>().ok_or_else(|| internal_error("AppContext absent du contexte")) +} + +/// Pool SQLite fourni en contexte par `main`. +pub fn pool() -> Result<SqlitePool, ServerFnError> { + Ok(context()?.pool) +} + +pub fn config() -> Result<Arc<Config>, ServerFnError> { + Ok(context()?.config) +} + +pub fn http() -> Result<reqwest::Client, ServerFnError> { + Ok(context()?.http) +} + +pub fn weather_cache() -> Result<WeatherCache, ServerFnError> { + Ok(context()?.weather_cache) +} + +/// Session de la requête en cours. +pub async fn session() -> Result<Session, ServerFnError> { + leptos_axum::extract::<Session>() + .await + .map_err(internal_error) +} + +/// Identifiant de l'utilisateur connecté, ou une erreur s'il n'y a pas de session. +/// +/// À appeler en tête de toute server function qui touche à des données personnelles, +/// puis à utiliser dans un `WHERE user_id = ?` : c'est ce qui empêche un utilisateur +/// de lire ou modifier les données d'un autre. +pub async fn require_user_id() -> Result<i64, ServerFnError> { + session() + .await? + .get::<i64>(USER_ID_KEY) + .await + .map_err(internal_error)? + .ok_or_else(|| ServerFnError::new("Vous devez être connecté.")) +} + +/// Journalise l'erreur réelle et renvoie au client un message générique, +/// pour ne jamais exposer de détails internes (SQL, chemins, etc.). +pub fn internal_error(error: impl Display) -> ServerFnError { + leptos::logging::error!("erreur interne : {error}"); + ServerFnError::new("Une erreur interne est survenue.") +} + +/// Hache un mot de passe avec Argon2id (sel aléatoire, paramètres par défaut). +/// +/// Le calcul est volontairement coûteux : il est déporté sur un thread bloquant +/// pour ne pas geler le runtime async. +pub async fn hash_password(password: String) -> Result<String, ServerFnError> { + tokio::task::spawn_blocking(move || hash_password_sync(&password)) + .await + .map_err(internal_error)? + .map_err(internal_error) +} + +fn hash_password_sync(password: &str) -> Result<String, String> { + let salt = SaltString::generate(&mut OsRng); + Argon2::default() + .hash_password(password.as_bytes(), &salt) + .map(|hash| hash.to_string()) + .map_err(|e| e.to_string()) +} + +/// Hash factice, vérifié quand l'utilisateur n'existe pas : le temps de réponse +/// est ainsi le même que pour un mauvais mot de passe, ce qui empêche de deviner +/// quelles adresses ont un compte en mesurant la latence. +static DUMMY_HASH: LazyLock<String> = LazyLock::new(|| { + hash_password_sync("mot-de-passe-factice") + .expect("le hachage du hash factice ne peut pas échouer") +}); + +/// Les comptes importés de Laravel ont un hash bcrypt (`$2y$…`). +pub fn is_legacy_hash(hash: &str) -> bool { + hash.starts_with("$2y$") || hash.starts_with("$2b$") || hash.starts_with("$2a$") +} + +/// Vérifie un mot de passe contre un hash Argon2 ou bcrypt. `stored_hash` vaut `None` +/// si l'utilisateur n'existe pas : le calcul est alors fait contre un hash factice et +/// le résultat est toujours `false`. +pub async fn verify_password(password: String, stored_hash: Option<String>) -> bool { + tokio::task::spawn_blocking(move || { + let user_exists = stored_hash.is_some(); + let hash = stored_hash.as_deref().unwrap_or(DUMMY_HASH.as_str()); + let valid = if is_legacy_hash(hash) { + bcrypt::verify(&password, hash).unwrap_or(false) + } else { + PasswordHash::new(hash).is_ok_and(|parsed| { + Argon2::default() + .verify_password(password.as_bytes(), &parsed) + .is_ok() + }) + }; + valid && user_exists + }) + .await + .unwrap_or(false) +} + +/// Jeton aléatoire (256 bits, en hexadécimal) pour les liens de réinitialisation. +pub fn random_token() -> String { + let mut bytes = [0u8; 32]; + OsRng.fill_bytes(&mut bytes); + hex::encode(bytes) +} + +/// Empreinte stockée en base à la place du jeton : une fuite de la base ne permet +/// pas de réinitialiser les mots de passe. +pub fn token_hash(token: &str) -> String { + hex::encode(Sha256::digest(token.as_bytes())) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn correct_password_is_accepted() { + let hash = hash_password("Correct-horse-1".into()).await.unwrap(); + assert!(hash.starts_with("$argon2id$")); + assert!(verify_password("Correct-horse-1".into(), Some(hash)).await); + } + + #[tokio::test] + async fn wrong_password_is_rejected() { + let hash = hash_password("Correct-horse-1".into()).await.unwrap(); + assert!(!verify_password("wrong".into(), Some(hash)).await); + } + + #[tokio::test] + async fn unknown_user_is_always_rejected() { + assert!(!verify_password("mot-de-passe-factice".into(), None).await); + } + + #[tokio::test] + async fn laravel_bcrypt_hashes_are_accepted() { + // Laravel produit des hash `$2y$` ; on en fabrique un équivalent. + let hash = bcrypt::hash_with_result("Secret123", 4) + .unwrap() + .format_for_version(bcrypt::Version::TwoY); + assert!(hash.starts_with("$2y$")); + assert!(is_legacy_hash(&hash)); + assert!(verify_password("Secret123".into(), Some(hash.clone())).await); + assert!(!verify_password("secret123".into(), Some(hash)).await); + } + + #[test] + fn tokens_are_random_and_hashed() { + let a = random_token(); + let b = random_token(); + assert_eq!(a.len(), 64); + assert_ne!(a, b); + assert_eq!(token_hash(&a), token_hash(&a)); + assert_ne!(token_hash(&a), a); + } +} diff --git a/src/ui.rs b/src/ui.rs new file mode 100644 index 0000000..6faa348 --- /dev/null +++ b/src/ui.rs @@ -0,0 +1,251 @@ +//! Petits composants d'interface réutilisables (Tailwind CSS). + +// Faux positif provoqué par `#[component]` sur les props `optional, into`. +#![allow(clippy::extra_unused_lifetimes)] + +use leptos::prelude::*; + +use crate::{ + errors::{error_for_field, general_error}, + icons::{Icon, IconName}, +}; + +/// Valeur d'une `ServerAction` (`action.value()`) : `None` tant qu'elle n'a pas été lancée. +pub trait ActionValue<T>: + Get<Value = Option<Result<T, ServerFnError>>> + Send + Sync + 'static +{ +} +impl<T, S> ActionValue<T> for S where + S: Get<Value = Option<Result<T, ServerFnError>>> + Send + Sync + 'static +{ +} + +/// Erreur d'une action concernant le champ `field`. +pub fn field_error_of<T>(value: impl ActionValue<T>, field: &'static str) -> Signal<Option<String>> +where + T: Clone + Send + Sync + 'static, +{ + Signal::derive(move || match value.get() { + Some(Err(e)) => error_for_field(&e, field), + _ => None, + }) +} + +/// Erreur d'une action qui ne concerne aucun champ en particulier. +pub fn general_error_of<T>(value: impl ActionValue<T>) -> Signal<Option<String>> +where + T: Clone + Send + Sync + 'static, +{ + Signal::derive(move || match value.get() { + Some(Err(e)) => general_error(&e), + _ => None, + }) +} + +/// L'action a-t-elle réussi (dernier résultat) ? +pub fn succeeded<T>(value: impl ActionValue<T>) -> Signal<bool> +where + T: Clone + Send + Sync + 'static, +{ + Signal::derive(move || matches!(value.get(), Some(Ok(_)))) +} + +/// Mise en page d'une page : largeur maximale, marges, titre et sous-titre facultatifs. +#[component] +pub fn Page( + #[prop(optional, into)] title: Option<String>, + #[prop(optional, into)] subtitle: Option<String>, + children: Children, +) -> impl IntoView { + view! { + <div class="mx-auto flex w-full max-w-5xl flex-col gap-5 px-4 py-6 sm:px-6 sm:py-8"> + {title + .map(|title| { + view! { + <div> + <h1 class="text-2xl font-bold tracking-tight sm:text-3xl">{title}</h1> + {subtitle.map(|subtitle| view! { <p class="muted mt-1">{subtitle}</p> })} + </div> + } + })} + {children()} + </div> + } +} + +/// Carte : surface blanche arrondie, avec un titre et une icône facultatifs. +#[component] +pub fn Card( + #[prop(optional)] title: Option<&'static str>, + #[prop(optional)] icon: Option<IconName>, + #[prop(optional, into)] class: String, + children: Children, +) -> impl IntoView { + view! { + <section class=format!("surface p-4 sm:p-5 {class}")> + {title + .map(|title| { + view! { + <h2 class="mb-4 flex items-center gap-2.5 font-semibold"> + {icon + .map(|icon| { + view! { + <span class="flex size-8 items-center justify-center rounded-lg bg-blue-50 text-blue-600 dark:bg-blue-500/10 dark:text-blue-400"> + <Icon icon class="size-4" /> + </span> + } + })} + {title} + </h2> + } + })} + {children()} + </section> + } +} + +/// Chiffre clé : libellé, valeur, unité et détail facultatif. +#[component] +pub fn StatTile( + #[prop(into)] label: String, + #[prop(into)] value: String, + #[prop(optional)] unit: Option<&'static str>, + #[prop(optional, into)] detail: Option<String>, + #[prop(optional)] icon: Option<IconName>, +) -> impl IntoView { + view! { + <div class="surface flex flex-col gap-1 p-4"> + <div class="muted flex items-center gap-1.5 text-sm font-medium"> + {icon.map(|icon| view! { <Icon icon class="size-4" /> })} + {label} + </div> + <div class="text-2xl font-semibold tracking-tight sm:text-3xl"> + {value} + {unit.map(|unit| view! { <span class="muted ml-1 text-base font-medium">{unit}</span> })} + </div> + {detail.map(|detail| view! { <div class="muted text-sm">{detail}</div> })} + </div> + } +} + +/// Champ de formulaire : libellé, `<input>` et message d'erreur éventuel. +#[component] +pub fn Field( + #[prop(optional)] label: Option<&'static str>, + name: &'static str, + #[prop(default = "text")] kind: &'static str, + #[prop(optional, into)] value: Option<String>, + #[prop(optional)] placeholder: Option<&'static str>, + #[prop(optional)] autocomplete: Option<&'static str>, + #[prop(optional)] step: Option<&'static str>, + #[prop(optional)] min: Option<&'static str>, + #[prop(optional)] max: Option<&'static str>, + #[prop(optional)] inputmode: Option<&'static str>, + #[prop(default = true)] required: bool, + #[prop(optional)] autofocus: bool, + #[prop(optional, into)] error: Signal<Option<String>>, +) -> impl IntoView { + let id = format!("field-{name}"); + let error_id = format!("{id}-error"); + view! { + <div class="flex flex-col gap-1.5"> + {label + .map(|label| { + view! { + <label for=id.clone() class="text-sm font-medium text-slate-700 dark:text-slate-300"> + {label} + </label> + } + })} + <input + id=id + class="input" + class=("!border-red-500", move || error.with(Option::is_some)) + type=kind + name=name + value=value + placeholder=placeholder + autocomplete=autocomplete + step=step + min=min + max=max + inputmode=inputmode + required=required + autofocus=autofocus + aria-invalid=move || error.with(Option::is_some).to_string() + aria-describedby=error_id.clone() + /> + <FieldError id=error_id message=error /> + </div> + } +} + +/// Message d'erreur sous un champ. +#[component] +pub fn FieldError( + #[prop(optional, into)] id: String, + #[prop(into)] message: Signal<Option<String>>, +) -> impl IntoView { + view! { + <p id=id class="text-sm text-red-600 empty:hidden dark:text-red-400" role="alert"> + {move || message.get()} + </p> + } +} + +/// Bandeau d'erreur générale. +#[component] +pub fn ErrorBanner(#[prop(into)] message: Signal<Option<String>>) -> impl IntoView { + move || { + message.get().map(|message| { + view! { + <div + class="rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300" + role="alert" + > + {message} + </div> + } + }) + } +} + +/// Bandeau de confirmation. +#[component] +pub fn SuccessBanner(children: Children) -> impl IntoView { + view! { + <div + class="flex items-start gap-2 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-800 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-300" + role="status" + > + <Icon icon=IconName::Check class="mt-0.5 size-4" /> + <span>{children()}</span> + </div> + } +} + +/// Bouton de validation, désactivé pendant l'envoi. +#[component] +pub fn SubmitButton( + #[prop(into)] pending: Signal<bool>, + #[prop(optional, into)] class: String, + children: Children, +) -> impl IntoView { + view! { + <button type="submit" class=format!("btn-primary {class}") disabled=move || pending.get()> + {children()} + </button> + } +} + +/// Bloc grisé animé affiché pendant un chargement. +#[component] +pub fn Loading(#[prop(default = "h-32")] height: &'static str) -> impl IntoView { + view! { + <div + class=format!("w-full animate-pulse rounded-2xl bg-slate-200/70 dark:bg-slate-800/70 {height}") + role="status" + aria-label="Chargement" + ></div> + } +} diff --git a/src/weather.rs b/src/weather.rs new file mode 100644 index 0000000..c3a5ca6 --- /dev/null +++ b/src/weather.rs @@ -0,0 +1,382 @@ +//! Prévisions météo OpenWeatherMap (5 jours, pas de 3 heures). +//! +//! Le serveur interroge l'API (avec un cache de 5 minutes par emplacement, comme le +//! `Cache::remember` de lara-bermite) puis prépare directement ce que la page affiche : +//! la météo du moment et un résumé par jour (port de la logique de `Weather.tsx`). + +use chrono::{DateTime, Datelike, NaiveDate, Timelike, Weekday}; +use leptos::prelude::*; +use serde::{Deserialize, Serialize}; + +#[cfg(feature = "ssr")] +use crate::server; + +/// Icônes disponibles dans `public/images/icons`. +const ICONS: [&str; 7] = ["01d", "02d", "03d", "03n", "04d", "09d", "10d"]; + +/// Nom de l'icône à afficher : celle d'OpenWeatherMap si on l'a, sa version « jour » +/// sinon, et une icône générique en dernier recours. +pub fn icon_name(icon: &str) -> String { + if ICONS.contains(&icon) { + return icon.to_string(); + } + let day = icon.replace('n', "d"); + if ICONS.contains(&day.as_str()) { + day + } else { + "weather".to_string() + } +} + +pub fn weekday_fr(weekday: Weekday) -> &'static str { + match weekday { + Weekday::Mon => "lundi", + Weekday::Tue => "mardi", + Weekday::Wed => "mercredi", + Weekday::Thu => "jeudi", + Weekday::Fri => "vendredi", + Weekday::Sat => "samedi", + Weekday::Sun => "dimanche", + } +} + +// ---- Réponse de l'API (https://openweathermap.org/forecast5) ---- + +#[derive(Clone, Debug, Deserialize)] +pub struct Forecast { + pub list: Vec<ForecastItem>, + #[serde(default)] + pub city: Option<City>, +} + +#[derive(Clone, Debug, Deserialize)] +pub struct City { + /// Décalage horaire en secondes par rapport à UTC. + #[serde(default)] + pub timezone: i64, +} + +#[derive(Clone, Debug, Deserialize)] +pub struct ForecastItem { + pub dt: i64, + pub main: ForecastMain, + pub weather: Vec<WeatherTag>, +} + +#[derive(Clone, Debug, Deserialize)] +pub struct ForecastMain { + pub temp: f64, + pub temp_min: f64, + pub temp_max: f64, +} + +#[derive(Clone, Debug, Deserialize)] +pub struct WeatherTag { + pub main: String, + pub description: String, + pub icon: String, +} + +// ---- Ce que la page affiche ---- + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct WeatherView { + pub current: Option<CurrentWeather>, + pub days: Vec<DayForecast>, +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct CurrentWeather { + pub temp: f64, + /// Minimum et maximum prévus pour la journée. + pub temp_min: f64, + pub temp_max: f64, + pub main: String, + pub description: String, + pub icon: String, +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct DayForecast { + /// AAAA-MM-JJ + pub date: String, + pub weekday: String, + /// JJ/MM/AAAA + pub date_fr: String, + pub main: String, + pub description: String, + pub icon: String, + pub min: f64, + pub max: f64, + pub slots: Vec<Slot>, +} + +/// Prévision d'une tranche de 3 heures. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Slot { + pub hour: u32, + pub temp: f64, + pub description: String, + pub icon: String, +} + +/// Prépare l'affichage à partir de la réponse de l'API. `now` est un timestamp UNIX. +pub fn summarize(forecast: &Forecast, now: i64) -> WeatherView { + let offset = forecast.city.as_ref().map_or(0, |c| c.timezone); + let local = |ts: i64| { + DateTime::from_timestamp(ts + offset, 0) + .unwrap_or_default() + .naive_utc() + }; + let today = local(now).date(); + + let items: Vec<_> = forecast + .list + .iter() + .filter_map(|item| Some((local(item.dt), item, item.weather.first()?))) + .collect(); + + let current = items.first().map(|(_, first, tag)| { + let today_items = items.iter().filter(|(time, ..)| time.date() == today); + CurrentWeather { + temp: first.main.temp, + temp_min: today_items + .clone() + .map(|(_, i, _)| i.main.temp_min) + .fold(first.main.temp_min, f64::min), + temp_max: today_items + .map(|(_, i, _)| i.main.temp_max) + .fold(first.main.temp_max, f64::max), + main: tag.main.clone(), + description: tag.description.clone(), + icon: icon_name(&tag.icon), + } + }); + + // Regroupement par jour, dans l'ordre chronologique, sans le jour même. + let mut groups: Vec<(NaiveDate, Vec<_>)> = Vec::new(); + for entry in items.iter().filter(|(time, ..)| time.date() != today) { + match groups.last_mut() { + Some((date, entries)) if *date == entry.0.date() => entries.push(entry), + _ => groups.push((entry.0.date(), vec![entry])), + } + } + + let days = groups + .into_iter() + .map(|(date, entries)| { + // Temps dominant : le plus fréquent de la journée (le premier rencontré en cas d'égalité). + let mut counts: Vec<(&str, usize)> = Vec::new(); + for (_, _, tag) in &entries { + match counts.iter_mut().find(|(main, _)| *main == tag.main) { + Some((_, count)) => *count += 1, + None => counts.push((&tag.main, 1)), + } + } + let dominant = counts + .iter() + .fold(None::<(&str, usize)>, |best, &(main, count)| match best { + Some((_, best_count)) if best_count >= count => best, + _ => Some((main, count)), + }) + .map(|(main, _)| main) + .unwrap_or_default(); + let tag = entries + .iter() + .map(|(_, _, tag)| tag) + .find(|tag| tag.main == dominant) + .expect("le temps dominant vient de la liste"); + + DayForecast { + date: date.format("%Y-%m-%d").to_string(), + weekday: weekday_fr(date.weekday()).to_string(), + date_fr: date.format("%d/%m/%Y").to_string(), + main: tag.main.clone(), + description: tag.description.clone(), + icon: icon_name(&tag.icon.replace('n', "d")), + min: entries + .iter() + .map(|(_, i, _)| i.main.temp_min) + .fold(f64::INFINITY, f64::min), + max: entries + .iter() + .map(|(_, i, _)| i.main.temp_max) + .fold(f64::NEG_INFINITY, f64::max), + slots: entries + .iter() + .map(|(time, item, tag)| Slot { + hour: time.hour(), + temp: item.main.temp, + description: tag.description.clone(), + icon: icon_name(&tag.icon.replace('n', "d")), + }) + .collect(), + } + }) + .collect(); + + WeatherView { current, days } +} + +/// Réponses de l'API mises en cache, par emplacement. +#[cfg(feature = "ssr")] +pub type WeatherCache = std::sync::Arc< + tokio::sync::Mutex< + std::collections::HashMap<i64, (std::time::Instant, std::sync::Arc<Forecast>)>, + >, +>; + +#[cfg(feature = "ssr")] +const CACHE_TTL: std::time::Duration = std::time::Duration::from_secs(5 * 60); + +#[server] +pub async fn get_weather() -> Result<WeatherView, ServerFnError> { + use std::{sync::Arc, time::Instant}; + + let user_id = server::require_user_id().await?; + let locations = crate::location::user_locations(&server::pool()?, user_id).await?; + let Some(location) = locations.first() else { + return Err(ServerFnError::new( + "Coordonnées non renseignées dans le profil.", + )); + }; + + let cache = server::weather_cache()?; + let cached = cache + .lock() + .await + .get(&location.id) + .filter(|(at, _)| at.elapsed() < CACHE_TTL) + .map(|(_, forecast)| forecast.clone()); + + let forecast = match cached { + Some(forecast) => forecast, + None => { + let config = server::config()?; + let Some(api_key) = &config.open_weather_map_api_key else { + return Err(server::internal_error( + "OPEN_WEATHER_MAP_API_KEY non configurée", + )); + }; + let response = server::http()? + .get("https://api.openweathermap.org/data/2.5/forecast") + .query(&[ + ("lat", location.latitude.to_string()), + ("lon", location.longitude.to_string()), + ("appid", api_key.clone()), + ("units", "metric".into()), + ("lang", "fr".into()), + ]) + .send() + .await + .and_then(|r| r.error_for_status()); + let forecast: Forecast = match response { + Ok(response) => response.json().await.map_err(server::internal_error)?, + Err(e) => { + // Sans `e.url()` : l'URL contient la clé d'API. + leptos::logging::error!("OpenWeatherMap injoignable : {}", e.without_url()); + return Err(ServerFnError::new("Impossible de récupérer la météo.")); + } + }; + let forecast = Arc::new(forecast); + cache + .lock() + .await + .insert(location.id, (Instant::now(), forecast.clone())); + forecast + } + }; + + Ok(summarize(&forecast, chrono::Utc::now().timestamp())) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn item(dt: i64, temp: f64, main: &str, icon: &str) -> ForecastItem { + ForecastItem { + dt, + main: ForecastMain { + temp, + temp_min: temp - 1.0, + temp_max: temp + 1.0, + }, + weather: vec![WeatherTag { + main: main.into(), + description: main.to_lowercase(), + icon: icon.into(), + }], + } + } + + // 2023-06-01T00:00:00Z + const DAY1: i64 = 1_685_577_600; + const H: i64 = 3600; + + #[test] + fn icons_fall_back_to_day_then_generic() { + assert_eq!(icon_name("03n"), "03n"); + assert_eq!(icon_name("01n"), "01d"); + assert_eq!(icon_name("13d"), "weather"); + } + + #[test] + fn summary_splits_today_and_next_days() { + let forecast = Forecast { + city: Some(City { timezone: 2 * H }), + list: vec![ + item(DAY1 + 12 * H, 20.0, "Clear", "01d"), + item(DAY1 + 15 * H, 24.0, "Clouds", "03d"), + item(DAY1 + 23 * H, 15.0, "Rain", "10n"), // 1er juin 23 h UTC = 2 juin 1 h locale + item(DAY1 + 26 * H, 14.0, "Rain", "10d"), + item(DAY1 + 29 * H, 18.0, "Clear", "01d"), + ], + }; + let view = summarize(&forecast, DAY1 + 11 * H); + + let current = view.current.unwrap(); + assert_eq!(current.temp, 20.0); + assert_eq!(current.temp_min, 19.0); + assert_eq!(current.temp_max, 25.0); + assert_eq!(current.icon, "01d"); + + assert_eq!(view.days.len(), 1); + let day = &view.days[0]; + assert_eq!(day.date, "2023-06-02"); + assert_eq!(day.weekday, "vendredi"); + assert_eq!(day.main, "Rain"); + assert_eq!(day.icon, "10d"); + assert_eq!(day.min, 13.0); + assert_eq!(day.max, 19.0); + assert_eq!( + day.slots.iter().map(|s| s.hour).collect::<Vec<_>>(), + [1, 4, 7] + ); + } + + #[test] + fn ties_keep_the_first_weather() { + let forecast = Forecast { + city: None, + list: vec![ + item(DAY1, 10.0, "Clear", "01d"), + item(DAY1 + 30 * H, 10.0, "Clouds", "04d"), + item(DAY1 + 33 * H, 10.0, "Rain", "09d"), + ], + }; + let view = summarize(&forecast, DAY1); + assert_eq!(view.days[0].main, "Clouds"); + } + + #[cfg(feature = "ssr")] + #[test] + fn parses_api_response() { + let json = r#"{"cod":"200","list":[{"dt":1685620800,"main":{"temp":21.5,"feels_like":21,"temp_min":20.1,"temp_max":22.3,"pressure":1015,"humidity":50}, + "weather":[{"id":800,"main":"Clear","description":"ciel dégagé","icon":"01d"}],"dt_txt":"2023-06-01 12:00:00"}], + "city":{"id":1,"name":"X","timezone":7200}}"#; + let forecast: Forecast = serde_json::from_str(json).unwrap(); + assert_eq!(forecast.list.len(), 1); + assert_eq!(forecast.city.unwrap().timezone, 7200); + } +} diff --git a/style/tailwind.css b/style/tailwind.css new file mode 100644 index 0000000..af9508d --- /dev/null +++ b/style/tailwind.css @@ -0,0 +1,83 @@ +@import "tailwindcss"; + +/* Les vues Leptos vivent dans `src`. */ +@source "../src"; + +/* Variante `dark:` à trois états, pilotée par l'attribut `data-theme` de <html> : + - data-theme="dark" : sombre forcé ; + - data-theme="light" : clair forcé ; + - sans attribut : suit le réglage du système (prefers-color-scheme). */ +@custom-variant dark { + &:where([data-theme="dark"], [data-theme="dark"] *) { + @slot; + } + @media (prefers-color-scheme: dark) { + &:where(:not([data-theme="light"], [data-theme="light"] *)) { + @slot; + } + } +} + +@theme { + --font-sans: "Figtree", ui-sans-serif, system-ui, sans-serif; + + /* Séries des graphiques (palette validée en clair et en sombre, daltonisme compris). */ + --color-chart-1: #2a78d6; + --color-chart-2: #eb6834; +} + +@layer base { + :root { + color-scheme: light dark; + } + :root[data-theme="light"] { + color-scheme: light; + } + :root[data-theme="dark"] { + color-scheme: dark; + } + + /* Teintes des séries recalées pour le fond sombre. */ + :root[data-theme="dark"] { + --color-chart-1: #3987e5; + --color-chart-2: #d95926; + } + @media (prefers-color-scheme: dark) { + :root:where(:not([data-theme="light"])) { + --color-chart-1: #3987e5; + --color-chart-2: #d95926; + } + } + + input[type="date"]::-webkit-calendar-picker-indicator { + cursor: pointer; + opacity: 0.6; + } + input[type="date"]::-webkit-calendar-picker-indicator:hover { + opacity: 1; + } +} + +/* Bouton principal. */ +@utility btn-primary { + @apply inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-2 font-semibold text-white shadow-sm transition hover:bg-blue-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600 active:scale-[0.98] disabled:cursor-wait disabled:opacity-60; +} + +/* Bouton discret (actions secondaires). */ +@utility btn-ghost { + @apply inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-lg px-3 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-2 focus-visible:outline-blue-600 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white; +} + +@utility input { + @apply w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 shadow-xs transition placeholder:text-slate-400 focus:border-blue-500 focus:ring-3 focus:ring-blue-500/20 focus:outline-none dark:border-slate-700 dark:bg-slate-800 dark:text-white; +} + +/* Surface des cartes. */ +@utility surface { + @apply rounded-2xl border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-900; +} + +/* Texte secondaire. */ +@utility muted { + @apply text-slate-500 dark:text-slate-400; +}