Merge commit '81ec068747a39e927c42273011252daaa58f1e14' into feature-clean

This commit is contained in:
2024-12-26 16:51:17 +03:00
361 changed files with 25873 additions and 23923 deletions

2
apps/app/.gitignore vendored
View File

@@ -2,3 +2,5 @@
# will have compiled files and executables
/target/
# Generated by tauri, metadata generated at compile time
/gen/

View File

@@ -1,6 +1,6 @@
[package]
name = "theseus_gui"
version = "0.8.9"
version = "0.9.2"
description = "The Modrinth App is a desktop application for managing your Minecraft mods"
license = "GPL-3.0-only"
repository = "https://github.com/modrinth/code/apps/app/"
@@ -8,22 +8,23 @@ edition = "2021"
build = "build.rs"
[build-dependencies]
tauri-build = { version = "2.0.0-rc", features = ["codegen"] }
tauri-build = { version = "2.0.3", features = ["codegen"] }
[dependencies]
theseus = { path = "../../packages/app-lib", features = ["tauri"] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_with = "3.0.0"
tauri = { version = "2.0.0-rc", features = ["devtools", "macos-private-api", "protocol-asset", "unstable"] }
tauri-plugin-window-state = "2.0.0-rc"
tauri-plugin-deep-link = "2.0.0-rc"
tauri-plugin-os = "2.0.0-rc"
tauri-plugin-shell = "2.0.0-rc"
tauri-plugin-dialog = "2.0.0-rc"
tauri-plugin-updater = { version = "2.0.0-rc" }
tauri-plugin-single-instance = { version = "2.0.0-rc" }
tauri = { version = "2.1.1", features = ["devtools", "macos-private-api", "protocol-asset", "unstable"] }
tauri-plugin-window-state = "2.2.0"
tauri-plugin-deep-link = "2.2.0"
tauri-plugin-os = "2.2.0"
tauri-plugin-opener = "2.2.1"
tauri-plugin-dialog = "2.2.0"
tauri-plugin-updater = { version = "2.3.0" }
tauri-plugin-single-instance = { version = "2.2.0" }
tokio = { version = "1", features = ["full"] }
thiserror = "1.0"
@@ -59,7 +60,7 @@ objc = "0.2.7"
rand = "0.8.5"
[target.'cfg(target_os = "linux")'.dependencies]
tauri-plugin-updater = { version = "2.0.0-rc", optional = true, features = ["native-tls-vendored", "zip"], default-features = false }
tauri-plugin-updater = { version = "2.3.0", optional = true, features = ["native-tls-vendored", "zip"], default-features = false }
[features]
# by default Tauri runs in production mode

View File

@@ -213,6 +213,19 @@ fn main() {
.default_permission(
DefaultPermissionRule::AllowAllCommands,
),
)
.plugin(
"friends",
InlinedPlugin::new()
.commands(&[
"friends",
"friend_statuses",
"add_friend",
"remove_friend",
])
.default_permission(
DefaultPermissionRule::AllowAllCommands,
),
),
)
.expect("Failed to run tauri-build");

View File

@@ -2,9 +2,7 @@
"identifier": "core",
"description": "",
"local": true,
"windows": [
"main"
],
"windows": ["main"],
"permissions": [
"core:default",
"core:path:default",
@@ -27,4 +25,4 @@
"core:window:allow-start-dragging",
"core:webview:allow-set-webview-zoom"
]
}
}

View File

@@ -6,7 +6,7 @@
"permissions": [
"dialog:allow-open",
"dialog:allow-confirm",
"shell:allow-open",
"opener:default",
"os:allow-platform",
"os:allow-version",
"os:allow-os-type",
@@ -33,6 +33,7 @@
"cache:default",
"settings:default",
"tags:default",
"utils:default"
"utils:default",
"friends:default"
]
}

View File

@@ -2,10 +2,6 @@
"identifier": "updater",
"description": "",
"local": true,
"windows": [
"main"
],
"permissions": [
"updater:default"
]
"windows": ["main"],
"permissions": ["updater:default"]
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
{"core":{"identifier":"core","description":"","local":true,"windows":["main"],"permissions":["core:default","core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-create","core:window:allow-maximize","core:window:allow-toggle-maximize","core:window:allow-unmaximize","core:window:allow-minimize","core:window:allow-unminimize","core:window:allow-show","core:window:allow-hide","core:window:allow-close","core:window:allow-set-decorations","core:window:allow-start-dragging","core:webview:allow-set-webview-zoom"]},"plugins":{"identifier":"plugins","description":"","local":true,"windows":["main"],"permissions":["dialog:allow-open","dialog:allow-confirm","shell:allow-open","os:allow-platform","os:allow-version","os:allow-os-type","os:allow-family","os:allow-arch","os:allow-exe-extension","os:allow-locale","os:allow-hostname","deep-link:default","window-state:default","window-state:allow-restore-state","window-state:allow-save-window-state","auth:default","import:default","jre:default","logs:default","metadata:default","mr-auth:default","profile-create:default","pack:default","process:default","profile:default","cache:default","settings:default","tags:default","utils:default"]},"updater":{"identifier":"updater","description":"","local":true,"windows":["main"],"permissions":["updater:default"]}}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -9,11 +9,11 @@
"fix": "cargo fmt && cargo clippy --fix"
},
"devDependencies": {
"@tauri-apps/cli": "2.0.0-rc.16"
"@tauri-apps/cli": "2.1.0"
},
"dependencies": {
"@modrinth/app-frontend": "workspace:*",
"@modrinth/app-lib": "workspace:*",
"@modrinth/daedalus": "workspace:*"
}
}
}

View File

@@ -0,0 +1,33 @@
use tauri::plugin::TauriPlugin;
use theseus::prelude::{UserFriend, UserStatus};
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
tauri::plugin::Builder::new("friends")
.invoke_handler(tauri::generate_handler![
friends,
friend_statuses,
add_friend,
remove_friend
])
.build()
}
#[tauri::command]
pub async fn friends() -> crate::api::Result<Vec<UserFriend>> {
Ok(theseus::friends::friends().await?)
}
#[tauri::command]
pub async fn friend_statuses() -> crate::api::Result<Vec<UserStatus>> {
Ok(theseus::friends::friend_statuses().await?)
}
#[tauri::command]
pub async fn add_friend(user_id: &str) -> crate::api::Result<()> {
Ok(theseus::friends::add_friend(user_id).await?)
}
#[tauri::command]
pub async fn remove_friend(user_id: &str) -> crate::api::Result<()> {
Ok(theseus::friends::remove_friend(user_id).await?)
}

View File

@@ -17,6 +17,7 @@ pub mod tags;
pub mod utils;
pub mod cache;
pub mod friends;
pub type Result<T> = std::result::Result<T, TheseusSerializableError>;

View File

@@ -282,19 +282,59 @@ pub struct EditProfile {
pub game_version: Option<String>,
pub loader: Option<ModLoader>,
pub loader_version: Option<String>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
pub loader_version: Option<Option<String>>,
pub groups: Option<Vec<String>>,
pub linked_data: Option<LinkedData>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
pub linked_data: Option<Option<LinkedData>>,
pub java_path: Option<String>,
pub extra_launch_args: Option<Vec<String>>,
pub custom_env_vars: Option<Vec<(String, String)>>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
pub java_path: Option<Option<String>>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
pub extra_launch_args: Option<Option<Vec<String>>>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
pub custom_env_vars: Option<Option<Vec<(String, String)>>>,
pub memory: Option<MemorySettings>,
pub force_fullscreen: Option<bool>,
pub game_resolution: Option<WindowSize>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
pub memory: Option<Option<MemorySettings>>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
pub force_fullscreen: Option<Option<bool>>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
pub game_resolution: Option<Option<WindowSize>>,
pub hooks: Option<Hooks>,
}
@@ -312,28 +352,40 @@ pub async fn profile_edit(path: &str, edit_profile: EditProfile) -> Result<()> {
if let Some(loader) = edit_profile.loader {
prof.loader = loader;
}
prof.loader_version.clone_from(&edit_profile.loader_version);
prof.linked_data.clone_from(&edit_profile.linked_data);
if let Some(loader_version) = edit_profile.loader_version.clone() {
prof.loader_version = loader_version;
}
if let Some(linked_data) = edit_profile.linked_data.clone() {
prof.linked_data = linked_data;
}
if let Some(groups) = edit_profile.groups.clone() {
prof.groups = groups;
}
prof.java_path.clone_from(&edit_profile.java_path);
prof.memory = edit_profile.memory;
prof.game_resolution = edit_profile.game_resolution;
prof.force_fullscreen = edit_profile.force_fullscreen;
if let Some(java_path) = edit_profile.java_path.clone() {
prof.java_path = java_path;
}
if let Some(memory) = edit_profile.memory {
prof.memory = memory;
}
if let Some(game_resolution) = edit_profile.game_resolution {
prof.game_resolution = game_resolution;
}
if let Some(force_fullscreen) = edit_profile.force_fullscreen {
prof.force_fullscreen = force_fullscreen;
}
if let Some(hooks) = edit_profile.hooks.clone() {
prof.hooks = hooks;
}
prof.modified = chrono::Utc::now();
prof.custom_env_vars
.clone_from(&edit_profile.custom_env_vars);
prof.extra_launch_args
.clone_from(&edit_profile.extra_launch_args);
if let Some(custom_env_vars) = edit_profile.custom_env_vars.clone() {
prof.custom_env_vars = custom_env_vars;
}
if let Some(extra_launch_args) = edit_profile.extra_launch_args.clone()
{
prof.extra_launch_args = extra_launch_args;
}
async { Ok(()) }
})

View File

@@ -7,7 +7,7 @@ use tauri::{
}; // 0.8
const WINDOW_CONTROL_PAD_X: f64 = 9.0;
const WINDOW_CONTROL_PAD_Y: f64 = 16.0;
const WINDOW_CONTROL_PAD_Y: f64 = 10.0;
struct UnsafeWindowHandle(*mut std::ffi::c_void);
unsafe impl Send for UnsafeWindowHandle {}
@@ -42,7 +42,7 @@ fn position_traffic_lights(
let title_bar_container_view = close.superview().superview();
let close_rect: NSRect = msg_send![close, frame];
let button_height = close_rect.size.height;
let button_height = close_rect.size.height + 12.0;
let title_bar_frame_height = button_height + y;
let mut title_bar_rect = NSView::frame(title_bar_container_view);
@@ -58,7 +58,7 @@ fn position_traffic_lights(
for (i, button) in window_buttons.into_iter().enumerate() {
let mut rect: NSRect = NSView::frame(button);
rect.origin.x = x + (i as f64 * space_between);
rect.origin.x = x + (i as f64 * space_between) + 6.0;
button.setFrameOrigin(rect.origin);
}
}

View File

@@ -25,6 +25,7 @@ extern crate objc;
#[tracing::instrument(skip_all)]
#[tauri::command]
async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
tracing::info!("Initializing app event state...");
theseus::EventState::init(app.clone()).await?;
// #[cfg(feature = "updater")]
@@ -35,7 +36,8 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
// let update_fut = updater.check();
// State::init().await?;
// tracing::info!("Initializing app state...");
State::init().await?;
// let check_bar = theseus::init_loading(
// theseus::LoadingBarType::CheckingForUpdates,
@@ -44,7 +46,8 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
// )
// .await?;
// let update = update_fut.await;
// tracing::info!("Checking for updates...");
// let update = update_fut.await;
// drop(check_bar);
@@ -88,6 +91,7 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
State::init().await?;
}
tracing::info!("Finished checking for updates!");
let state = State::get().await?;
app.asset_protocol_scope()
.allow_directory(state.directories.caches_dir(), true)?;
@@ -185,7 +189,7 @@ fn main() {
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_deep_link::init())
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_opener::init())
.plugin(
tauri_plugin_window_state::Builder::default()
.with_filename(
@@ -244,12 +248,9 @@ fn main() {
dbg!(url);
});
if let Some(window) = app.get_window("main") {
// Hide window to prevent white flash on startup
let _ = window.hide();
#[cfg(not(target_os = "linux"))]
{
#[cfg(not(target_os = "linux"))]
{
if let Some(window) = app.get_window("main") {
window.set_shadow(true).unwrap();
}
}
@@ -272,6 +273,7 @@ fn main() {
.plugin(api::tags::init())
.plugin(api::utils::init())
.plugin(api::cache::init())
.plugin(api::friends::init())
.invoke_handler(tauri::generate_handler![
initialize_state,
is_dev,
@@ -285,6 +287,7 @@ fn main() {
builder = builder.plugin(macos::window_ext::init());
}
tracing::info!("Initializing app...");
let app = builder.build(tauri::generate_context!());
match app {
@@ -346,6 +349,7 @@ fn main() {
.show_alert()
.unwrap();
tracing::error!("Error while running tauri application: {:?}", e);
panic!("{1}: {:?}", e, "error while running tauri application")
}
}

View File

@@ -11,12 +11,7 @@
"copyright": "",
"targets": "all",
"externalBin": [],
"icon": [
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"icon": ["icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"],
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
@@ -49,7 +44,7 @@
]
},
"productName": "AstralRinth App",
"version": "0.8.9",
"version": "0.9.2",
"mainBinaryName": "AstralRinth App",
"identifier": "AstralRinthApp",
"plugins": {
@@ -72,29 +67,23 @@
"resizable": true,
"title": "AstralRinth",
"width": 1280,
"minHeight": 750,
"minHeight": 700,
"minWidth": 1100,
"visible": false,
"visible": true,
"zoomHotkeysEnabled": false,
"decorations": false
}
],
"security": {
"assetProtocol": {
"scope": [
"$APPDATA/caches/icons/*",
"$APPCONFIG/caches/icons/*",
"$CONFIG/caches/icons/*"
],
"scope": ["$APPDATA/caches/icons/*", "$APPCONFIG/caches/icons/*", "$CONFIG/caches/icons/*"],
"enable": true
},
"capabilities": ["core", "plugins"],
"csp": {
"default-src": "'self' customprotocol: asset:",
"connect-src": "https://api.github.com ipc: http://ipc.localhost https://modrinth.com https://*.modrinth.com https://*.posthog.com https://*.sentry.io https://api.mclo.gs",
"font-src": [
"https://cdn-raw.modrinth.com/fonts/inter/"
],
"font-src": ["https://cdn-raw.modrinth.com/fonts/inter/"],
"img-src": "https: 'unsafe-inline' 'self' asset: http://asset.localhost blob: data:",
"style-src": "'unsafe-inline' 'self'",
"script-src": "https://*.posthog.com 'self'",