chore: Begin work on backend refactor

This commit is contained in:
LynithDev 2025-03-23 19:04:58 +01:00
parent 59183e9124
commit 5f4d4013b3
26 changed files with 863 additions and 189 deletions

View file

@ -41,9 +41,9 @@
".rustup",
".crates"
],
"rust-analyzer.procMacro.enable": false,
"rust-analyzer.procMacro.attributes.enable": false,
"rust-analyzer.check.command": "check",
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.procMacro.attributes.enable": true,
"rust-analyzer.check.command": "clippy",
"rust-analyzer.diagnostics.experimental.enable": false,
"rust-analyzer.linkedProjects": [],
"rust-analyzer.cargo.extraEnv": {},
@ -53,6 +53,7 @@
// Disable the default formatter
"prettier.enable": false,
"editor.formatOnSave": false,
// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",

318
Cargo.lock generated
View file

@ -174,7 +174,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -335,7 +335,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -370,7 +370,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -401,7 +401,7 @@ dependencies = [
"crc32fast",
"futures-lite",
"pin-project",
"thiserror",
"thiserror 1.0.64",
"tokio",
"tokio-util",
]
@ -664,9 +664,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "bytes"
version = "1.7.2"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3"
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
dependencies = [
"serde",
]
@ -703,7 +703,7 @@ dependencies = [
"glib",
"libc",
"once_cell",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -746,7 +746,7 @@ dependencies = [
"semver",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -1182,7 +1182,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
dependencies = [
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1192,7 +1192,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f"
dependencies = [
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1228,7 +1228,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1252,7 +1252,7 @@ dependencies = [
"proc-macro2",
"quote",
"strsim",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1263,7 +1263,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
dependencies = [
"darling_core",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1324,7 +1324,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1337,7 +1337,43 @@ dependencies = [
"proc-macro2",
"quote",
"rustc_version",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
name = "diesel"
version = "2.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "470eb10efc8646313634c99bb1593f402a6434cbd86e266770c6e39219adb86a"
dependencies = [
"chrono",
"diesel_derives",
"libsqlite3-sys",
"serde_json",
"time",
"uuid 0.8.2",
]
[[package]]
name = "diesel_derives"
version = "2.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a93958254b70bea63b4187ff73d10180599d9d8d177071b7f91e6da4e0c0ad55"
dependencies = [
"diesel_table_macro_syntax",
"dsl_auto_type",
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]]
name = "diesel_table_macro_syntax"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25"
dependencies = [
"syn 2.0.87",
]
[[package]]
@ -1440,7 +1476,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1472,7 +1508,7 @@ checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1504,6 +1540,20 @@ dependencies = [
"serde",
]
[[package]]
name = "dsl_auto_type"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "139ae9aca7527f85f26dd76483eb38533fd84bd571065da1739656ef71c5ff5b"
dependencies = [
"darling",
"either",
"heck 0.5.0",
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]]
name = "dtoa"
version = "1.0.9"
@ -1654,7 +1704,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1831,7 +1881,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1937,7 +1987,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -2165,7 +2215,7 @@ dependencies = [
"once_cell",
"pin-project-lite",
"smallvec",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -2201,7 +2251,7 @@ dependencies = [
"memchr",
"once_cell",
"smallvec",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -2215,7 +2265,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -2305,7 +2355,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -2706,21 +2756,21 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
name = "interpulse"
version = "1.2.0"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0231234632fd030df5027cd8d8c4c4f27a1177d6a18790f9e45a2a188491973a"
checksum = "e6dfab7ec77a9dc51f9c1986c3bfd9ab5c06ffcac5a4149329010a4bc01e52f7"
dependencies = [
"bytes",
"chrono",
"serde",
"serde_json",
"specta",
"thiserror",
"thiserror 2.0.12",
]
[[package]]
@ -2771,7 +2821,7 @@ dependencies = [
"stronghold-derive",
"stronghold-utils",
"stronghold_engine",
"thiserror",
"thiserror 1.0.64",
"zeroize",
]
@ -2861,7 +2911,7 @@ dependencies = [
"combine",
"jni-sys",
"log",
"thiserror",
"thiserror 1.0.64",
"walkdir",
"windows-sys 0.45.0",
]
@ -2905,7 +2955,7 @@ dependencies = [
"jsonptr",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -3101,6 +3151,16 @@ dependencies = [
"zip",
]
[[package]]
name = "libsqlite3-sys"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad8935b44e7c13394a179a438e0cebba0fe08fe01b54f152e29a93b5cf993fd4"
dependencies = [
"pkg-config",
"vcpkg",
]
[[package]]
name = "linux-raw-sys"
version = "0.4.14"
@ -3338,7 +3398,7 @@ dependencies = [
"once_cell",
"png",
"serde",
"thiserror",
"thiserror 1.0.64",
"windows-sys 0.59.0",
]
@ -3360,7 +3420,7 @@ dependencies = [
"ndk-sys",
"num_enum",
"raw-window-handle",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -3502,7 +3562,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -3552,7 +3612,7 @@ dependencies = [
"proc-macro-crate 2.0.2",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -3849,7 +3909,7 @@ dependencies = [
"tauri",
"tauri-specta",
"tempfile",
"thiserror",
"thiserror 1.0.64",
"tokio",
"tokio-stream",
"toml 0.8.2",
@ -3901,7 +3961,7 @@ dependencies = [
"tauri-plugin-updater",
"tauri-plugin-window-state",
"tauri-specta",
"thiserror",
"thiserror 1.0.64",
"tokio",
"tracing",
"tracing-error",
@ -3914,7 +3974,53 @@ name = "onelauncher_macros"
version = "0.1.0-alpha.2"
dependencies = [
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
name = "onelauncher_new"
version = "0.1.0-alpha.2"
dependencies = [
"async_zip",
"base64 0.22.1",
"bytes",
"chrono",
"diesel",
"dirs 5.0.1",
"discord-rich-presence",
"flate2",
"futures",
"indicatif",
"interpulse",
"lazy_static",
"md5",
"murmur2",
"onelauncher_gamemode",
"rand 0.8.5",
"regex",
"reqwest",
"serde",
"serde_ini",
"serde_json",
"serde_repr",
"serde_with",
"sha1_smol",
"sha2",
"specta",
"sysinfo",
"tauri",
"tauri-specta",
"thiserror 1.0.64",
"tokio",
"tokio-stream",
"tracing",
"tracing-appender",
"tracing-error",
"tracing-subscriber",
"url",
"uuid 1.10.0",
"whoami",
"zip",
]
[[package]]
@ -3943,7 +4049,7 @@ dependencies = [
"serde",
"sys-info",
"tempfile",
"thiserror",
"thiserror 1.0.64",
"tokio",
"tracing",
"uuid 1.10.0",
@ -4216,7 +4322,7 @@ dependencies = [
"phf_shared 0.11.2",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -4263,7 +4369,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -4480,7 +4586,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30"
dependencies = [
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -4529,7 +4635,7 @@ dependencies = [
"rustc-hash",
"rustls",
"socket2",
"thiserror",
"thiserror 1.0.64",
"tokio",
"tracing",
]
@ -4546,7 +4652,7 @@ dependencies = [
"rustc-hash",
"rustls",
"slab",
"thiserror",
"thiserror 1.0.64",
"tinyvec",
"tracing",
]
@ -4684,7 +4790,7 @@ dependencies = [
"rand_chacha 0.3.1",
"simd_helpers",
"system-deps",
"thiserror",
"thiserror 1.0.64",
"v_frame",
"wasm-bindgen",
]
@ -4746,7 +4852,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
dependencies = [
"getrandom 0.2.15",
"libredox",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -5064,7 +5170,7 @@ dependencies = [
"proc-macro2",
"quote",
"serde_derive_internals",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -5161,7 +5267,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -5172,7 +5278,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -5206,7 +5312,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -5257,7 +5363,7 @@ dependencies = [
"darling",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -5469,7 +5575,7 @@ dependencies = [
"serde",
"serde_json",
"specta-macros",
"thiserror",
"thiserror 1.0.64",
"time",
"uuid 1.10.0",
]
@ -5494,7 +5600,7 @@ dependencies = [
"Inflector",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -5504,7 +5610,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12260cbb21abb2e83a0375b1521867910e3aed8a7afa782206150ce552cd2e5a"
dependencies = [
"specta",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -5515,7 +5621,7 @@ checksum = "b1e4472229365ceb6395487e3a60d921ad8e21f9ad06eaecc396f098902c9adc"
dependencies = [
"specta",
"specta-serde",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -5600,7 +5706,7 @@ dependencies = [
"nix 0.24.3",
"rand 0.8.5",
"serde",
"thiserror",
"thiserror 1.0.64",
"windows 0.36.1",
"zeroize",
]
@ -5629,7 +5735,7 @@ dependencies = [
"paste",
"serde",
"stronghold-runtime",
"thiserror",
"thiserror 1.0.64",
"zeroize",
]
@ -5658,7 +5764,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -5691,9 +5797,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.79"
version = "2.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
dependencies = [
"proc-macro2",
"quote",
@ -5815,7 +5921,7 @@ checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -5877,7 +5983,7 @@ dependencies = [
"tauri-runtime",
"tauri-runtime-wry",
"tauri-utils",
"thiserror",
"thiserror 1.0.64",
"tokio",
"tracing",
"tray-icon",
@ -5930,9 +6036,9 @@ dependencies = [
"serde",
"serde_json",
"sha2",
"syn 2.0.79",
"syn 2.0.87",
"tauri-utils",
"thiserror",
"thiserror 1.0.64",
"time",
"url",
"uuid 1.10.0",
@ -5948,7 +6054,7 @@ dependencies = [
"heck 0.5.0",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
"tauri-codegen",
"tauri-utils",
]
@ -5983,7 +6089,7 @@ dependencies = [
"serde_json",
"tauri",
"tauri-plugin",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -6000,7 +6106,7 @@ dependencies = [
"tauri",
"tauri-plugin",
"tauri-utils",
"thiserror",
"thiserror 1.0.64",
"url",
"windows-registry 0.3.0",
"windows-result 0.2.0",
@ -6020,7 +6126,7 @@ dependencies = [
"tauri",
"tauri-plugin",
"tauri-plugin-fs",
"thiserror",
"thiserror 1.0.64",
"url",
]
@ -6040,7 +6146,7 @@ dependencies = [
"serde_repr",
"tauri",
"tauri-plugin",
"thiserror",
"thiserror 1.0.64",
"url",
"uuid 1.10.0",
]
@ -6062,7 +6168,7 @@ dependencies = [
"shared_child",
"tauri",
"tauri-plugin",
"thiserror",
"thiserror 1.0.64",
"tokio",
]
@ -6076,7 +6182,7 @@ dependencies = [
"serde",
"serde_json",
"tauri",
"thiserror",
"thiserror 1.0.64",
"windows-sys 0.59.0",
"zbus",
]
@ -6103,7 +6209,7 @@ dependencies = [
"tauri",
"tauri-plugin",
"tempfile",
"thiserror",
"thiserror 1.0.64",
"time",
"tokio",
"url",
@ -6123,7 +6229,7 @@ dependencies = [
"serde_json",
"tauri",
"tauri-plugin",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -6140,7 +6246,7 @@ dependencies = [
"serde",
"serde_json",
"tauri-utils",
"thiserror",
"thiserror 1.0.64",
"url",
"windows 0.58.0",
]
@ -6186,7 +6292,7 @@ dependencies = [
"specta-typescript",
"tauri",
"tauri-specta-macros",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -6198,7 +6304,7 @@ dependencies = [
"heck 0.5.0",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -6229,7 +6335,7 @@ dependencies = [
"serde_json",
"serde_with",
"swift-rs",
"thiserror",
"thiserror 1.0.64",
"toml 0.8.2",
"url",
"urlpattern",
@ -6283,7 +6389,16 @@ version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
dependencies = [
"thiserror-impl",
"thiserror-impl 1.0.64",
]
[[package]]
name = "thiserror"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
dependencies = [
"thiserror-impl 2.0.12",
]
[[package]]
@ -6294,7 +6409,18 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
name = "thiserror-impl"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]]
@ -6400,7 +6526,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -6522,7 +6648,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf"
dependencies = [
"crossbeam-channel",
"thiserror",
"thiserror 1.0.64",
"time",
"tracing-subscriber",
]
@ -6535,7 +6661,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -6605,7 +6731,7 @@ dependencies = [
"once_cell",
"png",
"serde",
"thiserror",
"thiserror 1.0.64",
"windows-sys 0.59.0",
]
@ -6637,7 +6763,7 @@ dependencies = [
"rustls",
"rustls-pki-types",
"sha1",
"thiserror",
"thiserror 1.0.64",
"utf-8",
]
@ -6944,7 +7070,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
"wasm-bindgen-shared",
]
@ -6978,7 +7104,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -7165,7 +7291,7 @@ checksum = "1d228f15bba3b9d56dde8bddbee66fa24545bd17b48d5128ccf4a8742b18e431"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -7174,7 +7300,7 @@ version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3a3e2eeb58f82361c93f9777014668eb3d07e7d174ee4c819575a9208011886"
dependencies = [
"thiserror",
"thiserror 1.0.64",
"windows 0.58.0",
"windows-core 0.58.0",
]
@ -7316,7 +7442,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -7327,7 +7453,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -7338,7 +7464,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -7349,7 +7475,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -7714,7 +7840,7 @@ dependencies = [
"sha2",
"soup3",
"tao-macros",
"thiserror",
"thiserror 1.0.64",
"tracing",
"webkit2gtk",
"webkit2gtk-sys",
@ -7887,7 +8013,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -7908,7 +8034,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -7933,7 +8059,7 @@ dependencies = [
"pbkdf2",
"rand 0.8.5",
"sha1",
"thiserror",
"thiserror 1.0.64",
"time",
"zeroize",
"zopfli",

View file

@ -4,6 +4,7 @@ members = [
"apps/testing", # onelauncher_test -- test the core crate in a cli setting
"apps/desktop", # onelauncher_gui -- the rust code for our tauri app
"packages/core", # onelauncher -- the rust core for onelauncher
"packages/core_new",
"packages/macros", # onelauncher_macros -- utility procedural macros for onelauncher
"packages/gamemode", # onelauncher_gamemode -- rust wrapper for feral gamemode
"packages/utils" # onelauncher_utils -- standard utilities for use within all crates
@ -31,7 +32,6 @@ onelauncher_gamemode = { path = "./packages/gamemode" }
onelauncher_utils = { path = "./packages/utils" }
# # ============= TAURI ============= # #
# tauri uses latest crates.io rc channel
tauri = { version = "2.0", features = [
"rustls-tls",
"tracing",
@ -39,22 +39,13 @@ tauri = { version = "2.0", features = [
"uuid",
"protocol-asset"
] }
# tauri-build is the codegen utility for our tauri buildscript.
tauri-build = { version = "2.0" }
# tauri-plugin-shell adds a bridge for opening urls and paths in the frontend.
tauri-plugin-shell = { version = "2.0" }
# tauri-plugin-window-state saves the window position and size to be restored.
tauri-plugin-window-state = { version = "2.0" }
# tauri-plugin-single-instance ensures that only one instance of the app is running.
tauri-plugin-single-instance = { version = "2.0" }
# tauri-plugin-clipboard-manager adds a bridge for reading/writing to the clipboard.
tauri-plugin-clipboard-manager = { version = "2.0" }
# tauri-plugin-updater allows for us to use it's functionality for in-app updates.
tauri-plugin-updater = { version = "2.0" }
# tauri-plugin-dialog adds a bridge for opening file manager and message dialogs.
tauri-plugin-dialog = { version = "2.0" }
# tauri-plugin-deep-link adds a way to handle custom uri schemes (onelauncher://)
tauri-plugin-deep-link = { version = "2.0" }
# # ============= CORE ============= # #
@ -67,23 +58,19 @@ specta = { version = "2.0.0-rc.20", features = [
"derive",
"time"
] }
# tauri-specta is the tauri adapter for specta.
tauri-specta = { version = "2.0.0-rc.20", features = [ "javascript", "typescript", "derive" ] }
# specta-typescript is the typescript adapter for specta.
specta-typescript = { version = "=0.0.7" }
# core utilities for minecraft and mod management with pulseflow apis
interpulse = { version = "=1.2.0", features = [ "specta" ] }
interpulse = { version = "=1.2.2", features = [ "specta" ] }
# # ============= SECURITY ============= # #
thiserror = { version = "1.0" }
anyhow = { version = "1.0" }
iota_stronghold = { version = "2.1" }
zeroize = { version = "1.8", features = [ "zeroize_derive" ] }
# # ============= LOGGING ============= # #
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3", features = [ "chrono", "env-filter" ] }
tracing-error = { version = "0.2" }
tracing-appender = { version = "0.2" }
iota_stronghold = { version = "2.1" }
zeroize = { version = "1.8", features = [ "zeroize_derive" ] }
# # ============= SERIALIZATION ============= # #
serde = { version = "1.0", features = [ "derive" ] }
@ -139,6 +126,15 @@ md5 = { version = "0.7.0" }
bytes = { version = "1.7" }
# # ============= UTILITY ============= # #
diesel = { version = "2.2.0", features = [
"sqlite",
"returning_clauses_for_sqlite_3_35",
"serde_json",
"uuid",
"chrono"
] }
thiserror = { version = "1.0" }
anyhow = { version = "1.0" }
async-channel = { version = "2.3" }
mimalloc = { version = "0.1" }
pin-project-lite = { version = "0.2" }

64
TODO.md
View file

@ -1,64 +0,0 @@
# todo list
- [ ] **remove clusterpath, just switch to pathbuf or string in prisma, and refactor package api**
- [ ] **splash screen and reduce startup times**
- [x] fix missing jars and libraries when launching clusters
- [ ] migrate launcher backend storage to `prisma-client-rust` (see `prisma` branch).
- maybe use `sqlx` instead to avoid unnecessary bloat (but also i don't like sqlx lol)
- todo: also add caching to the prisma schema
- [ ] migrate api commands that currently use `tauri-specta` but don't actually rely on `tauri` to `rspc`
- waiting on `rspc` to update to the latest version (hopefully once tauri comes out of rc)
- [ ] bump `tauri` to stable v2 when it releases.
- [x] bump `tauri` to latest rc v2.
- [ ] test all major version/loader combos launching and mod loading.
- legacy fabric, babric, nilloader, java agent support
- nilloader <https://github.com/modrinth/labrinth/issues/903> <https://github.com/orgs/modrinth/discussions/45>
- [ ] shared cluster resources and options (<https://github.com/enjarai/shared-resources>)
- [ ] utils testing, dom testing, client testing, e2e testing
- [ ] ftb, technic, and tlauncher importing
- [ ] better debug logging and mc logging, for the launcher and spawn
- [ ] implement forgewrapper instead of processing ourselves
- [ ] allow per-cluster sandboxing
- [x] implement gamemode
- [x] better toml support
- [ ] make all tauri events into tauri_specta events
- [ ] apple and windows signing
- [ ] calendar ian button easter egg
- [x] modal stacking
- [x] popup visibility toggled
- [x] smooth animations/animation accessibility
- [x] cluster grouping
- [ ] cluster reorganizing (drag n drop)
- [x] different cluster views
- [x] settings tsx
- [x] packages api
- [ ] curseforge api
- [x] browser tsx
- [ ] importing tsx
- [ ] mrpack tsx
- [x] launch the game
- [x] self updater
- [x] authentication
- [x] manifest fetching
- [ ] tauri updater v1 -> v2
- [x] fix old intel gpus <https://github.com/MultiMC/Launcher/issues/1276#issuecomment-774541617>
- [ ] fix cmd+a on macos not selecting all text
- [ ] fix cmd+c on macos not pasting in oauth and entire launcher
- [ ] hotfix some webkitgtk problems if possible
- [x] fetching from screenshots
- [ ] inferring metadata from zip
- [ ] inferring metadata from modrinth api
- [ ] feature parity with prism:
- [ ]
- [ ] feature parity with modrinth app:
- [ ]
- [ ] reduce bundle size (<https://bundlephobia.com>):
- [ ] markdown-it (157kb) - lots of alternatives
- [ ] highlight.js (143kb) - shiki is a good alternative i think
- [ ] assets (63kb in icons and a lot more in .pngs) - we need to optimize our own assets, the ones from libs are negligable (default_instance_cover_ and header jpgs specifically)
- [ ] reduce app size (release binary) including in appimage (10mb right now, aiming for less than 14mb total release)
- [ ] drag and drop files into the launcher window (mods and modpack files)
- [ ] <https://github.com/gorilla-devs/GDLauncher-Carbon> and <https://github.com/gorilla-devs/libium>
- [ ] <https://github.com/gorilla-devs/furse> and <https://github.com/gorilla-devs/ferinth>
- [ ] add `minecraft.modpack.name` jvm arg based on installed modpack in `run_credentials`
- [ ] backwards compatibility from <https://github.com/PrismLauncher/PrismLauncher/blob/develop/libraries/launcher/org/prismlauncher/SystemProperties.java>

View file

@ -31,6 +31,7 @@
"frontend": "pnpm --filter @onelauncher/frontend -- ",
"client": "pnpm --filter @onelauncher/client -- ",
"desktop": "pnpm --filter @onelauncher/desktop -- ",
"core_new": "pnpm --filter @onelauncher/core_new -- ",
"scripts": "pnpm --filter @onelauncher/scripts -- ",
"testing": "pnpm --filter @onelauncher/testing --",
"tauri": "pnpm desktop tauri-ext",

View file

@ -1,3 +1,4 @@
#![allow(clippy::all)]
//! # `OneLauncher`
//!
//! A library used as a core for our launcher and Rust APIs.

View file

@ -86,7 +86,7 @@ impl ClusterPath {
/// Get the full [`PathBuf`] of the current cluster path.
pub async fn full_path(&self) -> crate::Result<PathBuf> {
let state = State::get().await?;
let state: std::sync::Arc<tokio::sync::RwLockReadGuard<'_, State>> = State::get().await?;
let clusters_dir = state.directories.clusters_dir().await;
Ok(clusters_dir.join(&self.0))
}

View file

@ -18,13 +18,13 @@ pub fn sha1_files(files: Vec<&PathBuf>) -> Vec<Option<String>> {
hashes
}
pub fn mda5(bytes: &[u8]) -> String {
pub fn md5(bytes: &[u8]) -> String {
let digest = md5::compute(bytes);
format!("{:x}", digest)
}
pub fn md5_file(file: &PathBuf) -> Result<String> {
Ok(mda5(&std::fs::read(file)?))
Ok(md5(&std::fs::read(file)?))
}
pub fn md5_files(files: Vec<&PathBuf>) -> Vec<Option<String>> {

View file

@ -0,0 +1,85 @@
[package]
name = "onelauncher_new"
description = "The core of OneLauncher"
version = { workspace = true }
license = { workspace = true }
edition = { workspace = true }
repository = { workspace = true }
documentation = { workspace = true }
readme = { workspace = true }
homepage = { workspace = true }
authors = { workspace = true }
[lib]
path = "src/lib.rs"
[features]
default = []
tauri = [ "dep:tauri", "dep:tauri-specta", "specta" ]
specta = [ "dep:specta" ]
cli = [ "dep:indicatif" ]
[lints]
workspace = true
[dependencies]
interpulse = { workspace = true }
# logging
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
tracing-error = { workspace = true }
tracing-appender = { workspace = true }
# serialization
serde = { workspace = true }
serde_json = { workspace = true }
serde_ini = { workspace = true }
serde_repr = { workspace = true }
serde_with = { workspace = true }
# utils
diesel = { workspace = true }
tokio = { workspace = true }
tokio-stream = { workspace = true }
futures = { workspace = true }
uuid = { workspace = true }
thiserror = { workspace = true }
chrono = { workspace = true }
reqwest = { workspace = true }
regex = { workspace = true }
sysinfo = { workspace = true }
whoami = { workspace = true }
lazy_static = { workspace = true }
rand = { workspace = true }
url = { workspace = true }
# integration
discord-rich-presence = { workspace = true }
# crypto
sha1_smol = { workspace = true }
sha2 = { workspace = true }
murmur2 = { workspace = true }
md5 = { workspace = true }
# io
zip = { workspace = true }
async_zip = { workspace = true }
dirs = { workspace = true }
bytes = { workspace = true }
base64 = { workspace = true }
flate2 = { workspace = true }
# features[tauri]
tauri = { workspace = true, optional = true }
tauri-specta = { workspace = true, optional = true }
# features[specta]
specta = { workspace = true, optional = true }
# features[cli]
indicatif = { workspace = true, optional = true }
[target.'cfg(target_os = "linux")'.dependencies]
onelauncher_gamemode = { workspace = true }

View file

@ -0,0 +1,8 @@
# For documentation on how to configure this file,
# see https://diesel.rs/guides/configuring-diesel-cli
[print_schema]
file = "src/schema.rs"
custom_type_derives = [ "diesel::query_builder::QueryId", "Clone" ]

View file

View file

@ -0,0 +1 @@
-- this is the init migration, it is not reversible

View file

@ -0,0 +1,64 @@
create table cluster_groups (
id integer not null,
name text not null,
constraint cluster_groups_pk primary key (id autoincrement)
);
create table java_versions (
id integer not null,
major_version integer not null,
display_name text not null,
absolute_path text not null,
full_version text not null,
constraint java_versions_pk primary key (id autoincrement)
);
create table packages (
file_name text not null,
display_name text not null,
display_version text not null,
type_id integer not null,
provider_id integer not null,
provider_version text not null,
mc_versions text not null,
mc_loader text not null,
hash text not null,
icon_url text,
constraint packages_pk primary key (type_id, file_name)
);
create table setting_profiles (
name text not null,
java_id integer,
res_w integer,
res_h integer,
force_fullscreen integer,
mem_max integer,
launch_args text,
launch_env text,
hook_pre text,
hook_wrapper text,
hook_post text,
constraint setting_profiles_pk primary key (name),
constraint setting_profiles_java_versions_id_fk foreign key (java_id) references java_versions
);
create table clusters (
path text not null,
created_at integer default (unixepoch()) not null,
updated_at integer default (unixepoch()) not null,
group_id integer,
name text not null,
mc_version text not null,
mc_loader text not null,
mc_loader_version text,
last_played integer,
overall_played integer,
icon_url text,
setting_profile_name text,
linked_pack_id text,
linked_pack_version integer,
constraint clusters_pk primary key (path),
constraint clusters_cluster_groups_id_fk foreign key (group_id) references cluster_groups,
constraint clusters_setting_profiles_name_fk foreign key (setting_profile_name) references setting_profiles
);

View file

@ -0,0 +1,18 @@
{
"name": "@onelauncher/core_new",
"version": "0.2.0-alpha.1",
"description": "Next-generation open source Minecraft launcher core",
"license": "GPL-3.0-only",
"repository": {
"type": "git",
"url": "git@github.com:polyfrost/onelauncher",
"directory": "packages/core-new"
},
"bugs": "https://github.com/polyfrost/onelauncher/issues",
"sideEffects": false,
"scripts": {
"cargo": "cargo",
"binary": "cargo run --bin",
"diesel": "diesel"
}
}

View file

@ -0,0 +1,11 @@
use onelauncher_new::io::Dirs;
#[tokio::main]
async fn main() {
let dirs = Dirs::get().await.expect("couldn't initialize dirs");
println!("Base dir: {:?}", dirs.base_dir());
println!("Launcher logs dir: {:?}", dirs.launcher_logs_dir());
println!("Metadata dir: {:?}", dirs.metadata_dir());
println!("DB file: {:?}", dirs.db_file());
}

View file

@ -0,0 +1,109 @@
//! **`OneLauncher` Constants**
//!
//! Public constant variables and strings that are used throughout the launcher.
//! Can be shared publically, any secrets should be stored in [`crate::store::credentials`].
// =========== Core Metadata ===========
/// The name of the launcher.
pub const NAME: &str = match option_env!("LAUNCHER_NAME") {
Some(name) => name,
None => "OneLauncher",
};
/// The version of the launcher (from `../Cargo.toml` env).
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
// =========== Default Ingress ===========
/// The amount of attempts to fetch a file before a request fails.
pub const FETCH_ATTEMPTS: usize = 3;
/// The total ingress capacity of the CLI, provided to [`indicatif`].
#[cfg(feature = "cli")]
pub const CLI_TOTAL_INGRESS: u64 = 1000;
/// The newline which we replace in metadata files.
pub const DUMMY_REPLACE_NEWLINE: &str = "\n";
// =========== Authentication ===========
/// Our Discord RPC client ID.
pub const DISCORD_RPC_CLIENT_ID: &str = "1274084193193955408";
/// Our Microsoft client ID.
pub const MICROSOFT_CLIENT_ID: &str = "9eac3a4e-8cdd-43ef-863e-49cd601b1f03";
/// Mojang/Microsoft client ID.
pub const MINECRAFT_CLIENT_ID: &str = "00000000402b5328";
/// Mojang/Microsoft login redirect URI.
pub const MINECRAFT_REDIRECT_URL: &str = "https://login.live.com/oauth20_desktop.srf";
/// Mojang/Microsoft login xboxlive scopes to get tokens.
pub const MINECRAFT_SCOPES: &str = "service::user.auth.xboxlive.com::MBI_SSL";
// =========== API ===========
// !!! URLS must NOT have a trailing slash. !!!
/// The Modrinth API base url.
pub const MODRINTH_API_URL: &str = "https://api.modrinth.com/v2";
/// The Modrinth V3 API base url. Used for things like fetching information about organizations.
pub const MODRINTH_V3_API_URL: &str = "https://api.modrinth.com/v3";
/// The Curseforge API base url.
pub const CURSEFORGE_API_URL: &str = "https://api.curseforge.com";
/// The Curseforge API key. Reserved for use in Polyfrost projects only. Do not use in other projects without permission from the Polyfrost team.
pub const CURSEFORGE_API_KEY: &str = "$2a$10$6utA1UNSmFPrE/Lh7b7ndeeGmiOkjKNY8kpFB0fsmE/d42ZAfFgCe";
/// The Minecraft game ID on Curseforge.
pub const CURSEFORGE_GAME_ID: u32 = 432;
/// Our metadata API base url.
pub const METADATA_API_URL: &str = "https://meta.polyfrost.org";
/// Featured packages API url.
pub const FEATURED_PACKAGES_URL: &str = "https://polyfrost.org/meta/onelauncher/featured.json";
/// <https://mclo.gs>/ API base url.
pub const MCLOGS_API_URL: &str = "https://api.mclo.gs/1";
/// <https://skyclient.co/> metadata base url.
pub const SKYCLIENT_BASE_URL: &str = "https://raw.githubusercontent.com/SkyblockClient/SkyblockClient-REPO/refs/heads/main/v1";
// =========== Paths ===========
/// The public `settings.json` file used to store the global [`Settings`] state.
///
/// [`Settings`]: crate::store::Settings
pub const SETTINGS_FILE: &str = "settings.json";
/// The public `authentication.json` file used to store the global [`MinecraftAuth`] state.
///
/// [`MinecraftAuth`]: crate::store::MinecraftAuth
pub const AUTH_FILE: &str = "authentication.json";
/// The public `processor.json` file used to store the global [`Processor`] state.
///
/// [`Processor`]: crate::store::Processor
pub const PROCESSOR_FILE: &str = "processor.json";
/// The current [`Settings`] format version, bumped for breaking changes.
/// If updated, a config file migration logic **NEEDS** to be implemented.
///
/// [`Settings`]: crate::store::Settings
pub const CURRENT_SETTINGS_FORMAT_VERSION: u32 = 1;
// =========== Hacky Mojang-spec OS constants ===========
#[cfg(target_os = "windows")]
pub const TARGET_OS: &str = "windows";
#[cfg(target_os = "macos")]
pub const TARGET_OS: &str = "osx";
#[cfg(target_os = "linux")]
pub const TARGET_OS: &str = "linux";
#[cfg(target_arch = "x86")]
pub const NATIVE_ARCH: &str = "32";
#[cfg(target_arch = "x86_64")]
pub const NATIVE_ARCH: &str = "64";
#[cfg(all(not(target_arch = "x86_64"), not(target_arch = "x86")))]
pub const NATIVE_ARCH: &str = "64";
// =========== Platform ===========
/// The default java executable on Windows or anything else.
pub const JAVA_BIN: &str = if cfg!(windows) { "javaw.exe" } else { "java" };
/// The bit width on x64 or x32 architectures.
pub const ARCH_WIDTH: &str = if cfg!(target_pointer_width = "64") {
"64"
} else {
"32"
};
/// Evaluates to `\r\n` on windows, and `\n` on everything else.
pub const LINE_ENDING: &str = if cfg!(windows) { "\r\n" } else { "\n" };

View file

@ -0,0 +1,7 @@
#[derive(thiserror::Error, Debug)]
pub enum LauncherError {
#[error(transparent)]
DirError(#[from] crate::io::DirectoryError),
}
pub type LauncherResult<T> = Result<T, LauncherError>;

View file

@ -0,0 +1,90 @@
use std::path::PathBuf;
use tokio::sync::OnceCell;
use crate::{constants, LauncherResult};
/// The static [`OnceCell<RwLock<Dirs>>`] for storing the global directory state.
/// Should be initialized as soon as possible (preferably before logging)
static DIRS_GLOBAL: OnceCell<Dirs> = OnceCell::const_new();
pub struct Dirs {
base_dir: PathBuf,
}
impl Dirs {
pub async fn get() -> LauncherResult<&'static Self> {
DIRS_GLOBAL.get_or_try_init(async || {
Self::initialize()
}).await
}
fn initialize() -> LauncherResult<Self> {
let base_dir = env_path("LAUNCHER_DIR")
.or_else(|| Some(dirs::data_dir()?.join(constants::NAME)))
.ok_or(DirectoryError::BaseDir)?;
Ok(Self {
base_dir
})
}
/// Get the base directory for the launcher.
#[must_use]
pub const fn base_dir(&self) -> &PathBuf {
&self.base_dir
}
/// Get the launcher's logs directory.
#[must_use]
pub fn launcher_logs_dir(&self) -> PathBuf {
self.base_dir().join("logs")
}
#[must_use]
pub fn db_file(&self) -> PathBuf {
self.base_dir().join("user_data.db")
}
/// Get the `config_dir/metadata` folder within the core config directory.
#[inline]
#[must_use]
pub fn metadata_dir(&self) -> PathBuf {
self.base_dir().join("metadata")
}
/// Get the `config_dir/metadata/libraries` folder for Minecraft libraries.
#[must_use]
pub fn libraries_dir(&self) -> PathBuf {
self.metadata_dir().join("libraries")
}
/// Get the `config_dir/metadata/natives` folder for Minecraft natives.
#[must_use]
pub fn natives_dir(&self) -> PathBuf {
self.metadata_dir().join("natives")
}
/// Get the `config_dir/metadata/java` directory.
#[must_use]
pub fn java_dir(&self) -> PathBuf {
self.metadata_dir().join("java")
}
/// Get the `config_dir/metadata/caches` directory.
#[must_use]
pub fn caches_dir(&self) -> PathBuf {
self.metadata_dir().join("caches")
}
}
#[derive(Debug, thiserror::Error)]
pub enum DirectoryError {
#[error("Failed to get the base directory for the launcher.")]
BaseDir,
}
pub fn env_path(name: &str) -> Option<PathBuf> {
std::env::var_os(name).map(PathBuf::from)
}

View file

@ -0,0 +1,3 @@
mod dirs;
pub use dirs::*;

View file

@ -0,0 +1,16 @@
// Private (accessible by crate only) modules
// Modules which are not re-exported
pub mod io;
pub mod constants;
pub mod schema;
// Modules which are re-exported
mod state;
mod error;
mod logger;
// Re-exported modules
pub use state::State;
pub use error::*;
pub use logger::start_logger;

View file

@ -0,0 +1,76 @@
// Handling for the live development logging
// This will log to the console, and will not log to a file
#[cfg(debug_assertions)]
pub async fn start_logger() {
use tracing_subscriber::prelude::*;
let filter = tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(format!("{}=debug", env!("CARGO_PKG_NAME"))));
let subscriber = tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::layer()
.with_ansi(true)
.with_file(true)
.with_line_number(true)
.with_level(true)
.with_thread_names(true)
.pretty()
)
.with(filter)
.with(tracing_error::ErrorLayer::default());
tracing::subscriber::set_global_default(subscriber)
.expect("setting default subscriber failed");
}
// Handling for the live production logging
// This will log to a file in the logs directory, and will not show any logs in the console
#[cfg(not(debug_assertions))]
pub async fn start_logger() {
use chrono::Local;
use std::fs::OpenOptions;
use tracing_subscriber::fmt::time::ChronoLocal;
use tracing_subscriber::prelude::*;
use crate::io::Dirs;
// Initialize and get logs directory path
let logs_dir = Dirs::get().await?.launcher_logs_dir();
let log_file_name = format!("launcher_{}.log", Local::now().format("%Y%m%d_%H%M%S"));
let log_file_path = logs_dir.join(log_file_name);
if let Err(err) = std::fs::create_dir_all(&logs_dir) {
eprintln!("Could not create logs directory: {err}");
}
let file = match OpenOptions::new()
.create(true)
.append(true)
.open(&log_file_path)
{
Ok(file) => file,
Err(e) => {
eprintln!("Could not start open log file: {e}");
return None;
}
};
let filter = tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(format!("{}=info", env!("CARGO_PKG_NAME"))));
let subscriber = tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::layer()
.compact()
.with_writer(file)
.with_ansi(false)
.with_timer(ChronoLocal::rfc_3339()),
)
.with(filter)
.with(tracing_error::ErrorLayer::default());
tracing::subscriber::set_global_default(subscriber)
.expect("Setting default subscriber failed");
}

View file

@ -0,0 +1,80 @@
// @generated automatically by Diesel CLI.
diesel::table! {
cluster_groups (id) {
id -> Integer,
name -> Text,
}
}
diesel::table! {
clusters (path) {
path -> Text,
created_at -> Integer,
updated_at -> Integer,
group_id -> Nullable<Integer>,
name -> Text,
mc_version -> Text,
mc_loader -> Text,
mc_loader_version -> Nullable<Text>,
last_played -> Nullable<Integer>,
overall_played -> Nullable<Integer>,
icon_url -> Nullable<Text>,
setting_profile_name -> Nullable<Text>,
linked_pack_id -> Nullable<Text>,
linked_pack_version -> Nullable<Integer>,
}
}
diesel::table! {
java_versions (id) {
id -> Integer,
major_version -> Integer,
display_name -> Text,
absolute_path -> Text,
full_version -> Text,
}
}
diesel::table! {
packages (file_name, type_id) {
file_name -> Text,
display_name -> Text,
display_version -> Text,
type_id -> Integer,
provider_id -> Integer,
provider_version -> Text,
mc_versions -> Text,
mc_loader -> Text,
hash -> Text,
icon_url -> Nullable<Text>,
}
}
diesel::table! {
setting_profiles (name) {
name -> Text,
java_id -> Nullable<Integer>,
res_w -> Nullable<Integer>,
res_h -> Nullable<Integer>,
force_fullscreen -> Nullable<Integer>,
mem_max -> Nullable<Integer>,
launch_args -> Nullable<Text>,
launch_env -> Nullable<Text>,
hook_pre -> Nullable<Text>,
hook_wrapper -> Nullable<Text>,
hook_post -> Nullable<Text>,
}
}
diesel::joinable!(clusters -> cluster_groups (group_id));
diesel::joinable!(clusters -> setting_profiles (setting_profile_name));
diesel::joinable!(setting_profiles -> java_versions (java_id));
diesel::allow_tables_to_appear_in_same_query!(
cluster_groups,
clusters,
java_versions,
packages,
setting_profiles,
);

View file

@ -0,0 +1,40 @@
use std::sync::Arc;
use tokio::sync::{OnceCell, RwLock};
use crate::LauncherResult;
/// The static [`OnceCell<RwLock<State>>`] for storing the global runtime launcher state.
static LAUNCHER_STATE: OnceCell<RwLock<State>> = OnceCell::const_new();
pub struct State {
}
impl State {
/// Get the current global launcher state (or initialize it)
pub async fn get() -> LauncherResult<Arc<tokio::sync::RwLockReadGuard<'static, Self>>> {
Ok(Arc::new(
LAUNCHER_STATE
.get_or_try_init(Self::initialize)
.await?
.read()
.await,
))
}
/// Get and lock writing to the current global launcher state (or initalize it)
pub async fn get_and_write() -> LauncherResult<tokio::sync::RwLockWriteGuard<'static, Self>> {
Ok(LAUNCHER_STATE
.get_or_try_init(Self::initialize)
.await?
.write()
.await)
}
async fn initialize() -> LauncherResult<RwLock<Self>> {
Ok(RwLock::new(Self {
}))
}
}

View file

@ -199,6 +199,7 @@ https://learn.microsoft.com/windows/package-manager/winget/
Write-Host
Write-Host 'Installing Rust tools...' -ForegroundColor Yellow
cargo install cargo-watch
cargo install diesel_cli --no-default-features --features sqlite
if ($LASTEXITCODE -ne 0) {
Exit-WithError 'Failed to install Rust tools'
}

View file

@ -116,10 +116,10 @@ case "$(uname)" in
echo "installing dependencies with dnf..."
# For Enterprise Linux, you also need "Development Tools" instead of "C Development Tools and Libraries"
if ! { sudo dnf group install "C Development Tools and Libraries" || sudo dnf group install "Development Tools"; }; then
err 'We were unable to install the "C Development Tools and Libraries"/"Development Tools" package.' \
'Please open an issue if you feel that this is incorrect.'
fi
# if ! { sudo dnf group install "C Development Tools and Libraries" || sudo dnf group install "Development Tools"; }; then
# err 'We were unable to install the "C Development Tools and Libraries"/"Development Tools" package.' \
# 'Please open an issue if you feel that this is incorrect.'
# fi
# Tauri dependencies
set -- openssl webkit2gtk4.1-devel openssl-devel curl wget file libappindicator-gtk3-devel \
@ -185,6 +185,8 @@ if [ "${CI:-}" != "true" ]; then
echo "installing rust tools..."
_tools="cargo-watch"
echo "$_tools" | xargs cargo install
cargo install diesel_cli --no-default-features --features sqlite
fi
echo 'your machine has been setup for onelauncher development!'

2
pnpm-lock.yaml generated
View file

@ -227,6 +227,8 @@ importers:
packages/core: {}
packages/core-new: {}
packages/distribution: {}
packages/gamemode: {}