Skip to content

Commit

Permalink
Merge pull request #57 from lgou2w/next
Browse files Browse the repository at this point in the history
v0.4.4
  • Loading branch information
lgou2w authored Dec 5, 2024
2 parents 62c56b8 + 5fffa59 commit 17c31ca
Show file tree
Hide file tree
Showing 62 changed files with 2,385 additions and 2,043 deletions.
1,419 changes: 874 additions & 545 deletions Cargo.lock

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hoyo.gacha",
"version": "0.4.3",
"version": "0.4.4",
"description": "An unofficial tool for managing and analyzing your miHoYo gacha records",
"author": "lgou2w <[email protected]>",
"homepage": "https://github.com/lgou2w/HoYo.Gacha#readme",
Expand All @@ -22,43 +22,43 @@
"lint:fix": "eslint --fix --ext .ts,.tsx --ignore-path .gitignore ."
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/icons-material": "^5.16.0",
"@mui/material": "^5.16.0",
"@mui/system": "^5.16.0",
"@nivo/calendar": "^0.87.0",
"@nivo/core": "^0.87.0",
"@nivo/pie": "^0.87.0",
"@nivo/tooltip": "^0.87.0",
"@tanstack/react-query": "^5.50.1",
"@tanstack/react-query-devtools": "^5.50.1",
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"@mui/icons-material": "^5.16.9",
"@mui/material": "^5.16.9",
"@mui/system": "^5.16.8",
"@nivo/calendar": "^0.88.0",
"@nivo/core": "^0.88.0",
"@nivo/pie": "^0.88.0",
"@nivo/tooltip": "^0.88.0",
"@tanstack/react-query": "^5.62.2",
"@tanstack/react-query-devtools": "^5.62.2",
"@tauri-apps/api": "^1.6.0",
"dayjs": "^1.11.11",
"dayjs": "^1.11.13",
"immer": "^10.1.1",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.52.1",
"react-router-dom": "^6.24.1",
"react-hook-form": "^7.53.2",
"react-router-dom": "^6.28.0",
"use-immer": "^0.10.0"
},
"devDependencies": {
"@tauri-apps/cli": "^1.6.0",
"@types/node": "^18.19.39",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"@vitejs/plugin-react": "^4.3.1",
"@tauri-apps/cli": "^1.6.3",
"@types/node": "^18.19.67",
"@types/react": "^18.3.13",
"@types/react-dom": "^18.3.1",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"@typescript-eslint/parser": "^8.17.0",
"@vitejs/plugin-react": "^4.3.4",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint": "^8.57.1",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-promise": "^6.4.0",
"eslint-plugin-react": "^7.34.3",
"typescript": "^5.5.3",
"vite": "^5.3.3"
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.14.0",
"eslint-plugin-promise": "^7.2.1",
"eslint-plugin-react": "^7.37.2",
"typescript": "^5.7.2",
"vite": "^6.0.2"
}
}
2,466 changes: 1,164 additions & 1,302 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hoyo_gacha"
version = "0.4.3"
version = "0.4.4"
edition = "2021"
authors = ["lgou2w"]
description = "An unofficial tool for managing and analyzing your miHoYo gacha records"
Expand All @@ -13,34 +13,34 @@ build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
shadow-rs = "0.29.0"
tauri-build = { version = "1.5.2", features = [] }
shadow-rs = "0.36.0"
tauri-build = { version = "1.5.5", features = [] }

[dependencies]
anyhow = "1.0.86"
async-trait = "0.1.80"
anyhow = "1.0.94"
async-trait = "0.1.83"
byteorder = "1.5.0"
exponential-backoff = "1.2.0"
exponential-backoff = "2.0.0"
form_urlencoded = "1.2.1"
futures = { version = "0.3.30", default-features = false, features = ["std", "async-await"] }
once_cell = "1.19.0"
futures = { version = "0.3.31", default-features = false, features = ["std", "async-await"] }
once_cell = "1.20.2"
paste = "1.0.15"
reqwest = { version = "0.12.5", features = ["json", "stream"] }
reqwest = { version = "0.12.9", features = ["json", "stream"] }
sea-orm = { version = "0.12.15", features = ["sqlx-sqlite", "runtime-tokio", "macros", "runtime-tokio-native-tls"], default-features = false }
serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.120"
shadow-rs = "0.29.0"
serde = { version = "1.0.215", features = ["derive"] }
serde_json = "1.0.133"
shadow-rs = "0.36.0"
sqlx-core = "0.7.4"
tauri = { version = "1.7.1", features = ["clipboard-all", "dialog-all", "path-all", "process-all", "shell-all", "devtools"] }
thiserror = "1.0.61"
time = { version = "0.3.36", features = ["formatting", "serde", "macros", "serde-human-readable", "local-offset"] }
tokio = { version = "1.38.0", features = ["full"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
url = "2.5.2"
tauri = { version = "1.8.1", features = ["clipboard-all", "dialog-all", "path-all", "process-all", "shell-all", "devtools"] }
thiserror = "2.0.4"
time = { version = "0.3.37", features = ["formatting", "serde", "macros", "serde-human-readable", "local-offset"] }
tokio = { version = "1.42.0", features = ["full"] }
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
url = "2.5.4"

[target."cfg(windows)".dependencies.windows]
version = "0.39.0"
version = "0.58.0"
features = [
"Win32_UI_WindowsAndMessaging"
]
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main() {
shadow_rs::new().ok();
shadow_rs::new().unwrap();
tauri_build::build();
}
6 changes: 1 addition & 5 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ fn get_version() -> Version {
Version {
version: constants::VERSION.to_owned(),
commit_hash: constants::COMMIT_HASH[0..7].to_owned(),
commit_tag: if commit_tag.is_empty() {
None
} else {
Some(commit_tag.to_owned())
},
commit_tag: Some(commit_tag.to_owned()),
date: constants::COMMIT_DATE.to_owned(),
}
}
Expand Down
1 change: 0 additions & 1 deletion src-tauri/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub const AUTHOR: &str = env!("CARGO_PKG_AUTHORS");
pub const REPOSITORY: &str = env!("CARGO_PKG_REPOSITORY");

/// See: https://github.com/baoyachi/shadow-rs
shadow_rs::shadow!(build);

pub const RUST_VERSION: &str = build::RUST_VERSION;
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/disk_cache/block_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const BLOCK_VERSION3_0: u32 = 0x30000;
const BLOCK_HEADER_SIZE: u32 = 8192;
const BLOCK_MAX_BLOCKS: u32 = (BLOCK_HEADER_SIZE - 80) * 8;

#[allow(dead_code)]
pub struct BlockFileHeader {
pub magic: u32,
pub version: u32,
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/disk_cache/entry_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::io::{Error, ErrorKind, Read, Result};

const BLOCK_KEY_SIZE: u32 = 256 - 24 * 4;

#[allow(dead_code)]
pub struct EntryStore {
pub hash: u32,
pub next: CacheAddr,
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/disk_cache/index_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const INDEX_VERSION3_0: u32 = 0x30000;
#[allow(unused)]
const INDEX_TABLE_SIZE: u32 = 0x10000;

#[allow(dead_code)]
pub struct LruData {
pub pad1: [i32; 2],
pub filled: i32,
Expand All @@ -27,6 +28,7 @@ pub struct LruData {
pub pad2: [i32; 7],
}

#[allow(dead_code)]
pub struct IndexFileHeader {
pub magic: u32,
pub version: u32,
Expand All @@ -43,6 +45,7 @@ pub struct IndexFileHeader {
pub lru: LruData,
}

#[allow(dead_code)]
pub struct IndexFile {
pub header: IndexFileHeader,
pub table: Vec<CacheAddr>,
Expand Down
1 change: 0 additions & 1 deletion src-tauri/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ pub enum Error {
pub type Result<T> = std::result::Result<T, Error>;

/// Native error to JavaScript error
macro_rules! impl_error_identifiers {
($( $variant: ident => $ident: ident ),*) => {
impl Error {
Expand Down
27 changes: 12 additions & 15 deletions src-tauri/src/gacha/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ use reqwest::Client as Reqwest;
use serde::{Deserialize, Serialize};
use std::any::Any;
use std::collections::BTreeMap;
use std::future::Future;
use std::path::{Path, PathBuf};
use time::OffsetDateTime;

/// Game Directory
// TODO:
// International

pub trait GameDataDirectoryFinder {
fn find_game_data_directories(&self) -> Result<Vec<PathBuf>>;
}

/// Gacha Url
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GachaUrl {
pub addr: u32,
Expand All @@ -35,13 +31,11 @@ impl std::ops::Deref for GachaUrl {
}

/// Gacha Url Finder
pub trait GachaUrlFinder {
fn find_gacha_urls<P: AsRef<Path>>(&self, game_data_dir: P) -> Result<Vec<GachaUrl>>;
}

/// Gacha Record
pub trait GachaRecord: Any {
fn id(&self) -> &str;
fn as_any(&self) -> &dyn Any;
Expand All @@ -55,7 +49,6 @@ impl dyn GachaRecord {
}

/// Gacha Record Fetcher
#[async_trait]
pub trait GachaRecordFetcher {
type Target: GachaRecord;
Expand All @@ -76,7 +69,6 @@ pub trait GachaRecordFetcher {
}

/// Gacha Record Fetcher Channel
#[allow(unused)]
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -199,19 +191,18 @@ pub trait GachaRecordFetcherChannel<T: GachaRecord + Sized + Serialize + Send +
}
}

pub async fn create_fetcher_channel<Record, FetcherChannel, F, Fut>(
pub async fn create_fetcher_channel<Record, FetcherChannel>(
fetcher_channel: FetcherChannel,
reqwest: Reqwest,
fetcher: FetcherChannel::Fetcher,
gacha_url: String,
gacha_type_and_last_end_id_mappings: BTreeMap<String, Option<String>>,
receiver_fn: F,
) -> Result<()>
window: tauri::Window,
event_channel: String,
) -> Result<Vec<Record>>
where
Record: GachaRecord + Sized + Serialize + Send + Sync,
FetcherChannel: GachaRecordFetcherChannel<Record> + Send + Sync + 'static,
F: Fn(GachaRecordFetcherChannelFragment<Record>) -> Fut,
Fut: Future<Output = Result<()>>,
{
use tokio::spawn;
use tokio::sync::mpsc::channel;
Expand All @@ -229,11 +220,17 @@ where
.await
});

let mut records = Vec::new();
while let Some(fragment) = receiver.recv().await {
receiver_fn(fragment).await?;
window.emit(&event_channel, &fragment)?;
if let GachaRecordFetcherChannelFragment::Data(data) = fragment {
records.extend(data);
}
}

task
.await
.map_err(|_| Error::GachaRecordFetcherChannelJoin)?
.map_err(|_| Error::GachaRecordFetcherChannelJoin)??;

Ok(records)
}
4 changes: 0 additions & 4 deletions src-tauri/src/gacha/impl_genshin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use std::path::{Path, PathBuf};
pub struct GenshinGacha;

/// Game Directory
impl GameDataDirectoryFinder for GenshinGacha {
fn find_game_data_directories(&self) -> Result<Vec<PathBuf>> {
let mihoyo_dir = lookup_mihoyo_dir();
Expand Down Expand Up @@ -48,7 +47,6 @@ impl GameDataDirectoryFinder for GenshinGacha {
}

/// Gacha Url
const ENDPOINT: &str = "/api/getGachaLog?";

impl GachaUrlFinder for GenshinGacha {
Expand All @@ -60,7 +58,6 @@ impl GachaUrlFinder for GenshinGacha {
}

/// Gacha Record
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
pub struct GenshinGachaRecord {
pub id: String,
Expand Down Expand Up @@ -92,7 +89,6 @@ impl PartialOrd for GenshinGachaRecord {
}

/// Gacha Record Fetcher
#[allow(unused)]
#[derive(Deserialize)]
pub(crate) struct GenshinGachaRecordPagination {
Expand Down
3 changes: 0 additions & 3 deletions src-tauri/src/gacha/impl_starrail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use std::path::{Path, PathBuf};
pub struct StarRailGacha;

/// Game Directory
impl GameDataDirectoryFinder for StarRailGacha {
fn find_game_data_directories(&self) -> Result<Vec<PathBuf>> {
let cognosphere_dir = lookup_cognosphere_dir();
Expand Down Expand Up @@ -48,7 +47,6 @@ impl GameDataDirectoryFinder for StarRailGacha {
}

/// Gacha Url
const ENDPOINT: &str = "/api/getGachaLog?";

impl GachaUrlFinder for StarRailGacha {
Expand Down Expand Up @@ -93,7 +91,6 @@ impl PartialOrd for StarRailGachaRecord {
}

/// Gacha Record Fetcher
#[allow(unused)]
#[derive(Deserialize)]
pub(crate) struct StarRailGachaRecordPagination {
Expand Down
3 changes: 0 additions & 3 deletions src-tauri/src/gacha/impl_zzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use std::path::{Path, PathBuf};
pub struct ZenlessZoneZeroGacha;

/// Game Directory
impl GameDataDirectoryFinder for ZenlessZoneZeroGacha {
fn find_game_data_directories(&self) -> Result<Vec<PathBuf>> {
let cognosphere_dir = lookup_cognosphere_dir();
Expand Down Expand Up @@ -48,7 +47,6 @@ impl GameDataDirectoryFinder for ZenlessZoneZeroGacha {
}

/// Gacha Url
const ENDPOINT: &str = "/api/getGachaLog?";

impl GachaUrlFinder for ZenlessZoneZeroGacha {
Expand Down Expand Up @@ -93,7 +91,6 @@ impl PartialOrd for ZenlessZoneZeroGachaRecord {
}

/// Gacha Record Fetcher
#[allow(unused)]
#[derive(Deserialize)]
pub(crate) struct ZenlessZoneZeroGachaRecordPagination {
Expand Down
Loading

0 comments on commit 17c31ca

Please sign in to comment.