🐛 fix: preformance improvements
This commit is contained in:
parent
8f928d6305
commit
a5ff33a912
16 changed files with 791 additions and 710 deletions
|
|
@ -24,14 +24,14 @@
|
|||
"@rspc/tauri": "^0.2.0",
|
||||
"@solid-primitives/refs": "^1.0.8",
|
||||
"@solidjs/router": "^0.14.1",
|
||||
"@tanstack/solid-query": "^5.51.2",
|
||||
"@tanstack/solid-query": "^5.51.9",
|
||||
"@tauri-apps/api": "^2.0.0-beta.13",
|
||||
"@tauri-apps/plugin-clipboard-manager": "2.1.0-beta.5",
|
||||
"@tauri-apps/plugin-shell": "github:tauri-apps/tauri-plugin-shell#v2",
|
||||
"@thisbeyond/solid-dnd": "^0.7.5",
|
||||
"@thisbeyond/solid-select": "^0.15.0",
|
||||
"@unocss/reset": "^0.61.4",
|
||||
"@untitled-theme/icons-solid": "^0.10.4",
|
||||
"@unocss/reset": "^0.61.5",
|
||||
"@untitled-theme/icons-solid": "^0.10.5",
|
||||
"overlayscrollbars": "^2.9.2",
|
||||
"overlayscrollbars-solid": "^0.5.5",
|
||||
"solid-js": "^1.8.18",
|
||||
|
|
@ -39,13 +39,13 @@
|
|||
"uuid": "^10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@solidjs/testing-library": "^0.8.8",
|
||||
"@solidjs/testing-library": "^0.8.9",
|
||||
"@tauri-apps/cli": "^2.0.0-beta.20",
|
||||
"@testing-library/jest-dom": "^6.4.6",
|
||||
"@testing-library/jest-dom": "^6.4.8",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"jsdom": "^24.1.0",
|
||||
"jsdom": "^24.1.1",
|
||||
"sass": "^1.77.8",
|
||||
"unocss": "^0.61.4",
|
||||
"unocss": "^0.61.5",
|
||||
"vite-plugin-solid": "^2.10.2",
|
||||
"vite-plugin-solid-svg": "^0.8.1",
|
||||
"vite-tsconfig-paths": "^4.3.2"
|
||||
|
|
|
|||
|
|
@ -5,34 +5,29 @@ fn main() {
|
|||
.plugin(
|
||||
"onelauncher",
|
||||
tauri_build::InlinedPlugin::new().commands(&[
|
||||
// User
|
||||
"begin_msa",
|
||||
"finish_msa",
|
||||
"get_users",
|
||||
"get_user",
|
||||
"remove_user",
|
||||
|
||||
// Cluster
|
||||
"create_cluster",
|
||||
"remove_cluster",
|
||||
"get_cluster",
|
||||
"get_clusters",
|
||||
"run_cluster",
|
||||
|
||||
// Processor
|
||||
"get_running_clusters",
|
||||
"get_processes_by_path",
|
||||
"kill_process",
|
||||
|
||||
// Settings
|
||||
"get_settings",
|
||||
"set_settings",
|
||||
|
||||
// Metadata
|
||||
"get_minecraft_versions",
|
||||
|
||||
// Other
|
||||
"get_program_info",
|
||||
// User
|
||||
"begin_msa",
|
||||
"finish_msa",
|
||||
"get_users",
|
||||
"get_user",
|
||||
"remove_user",
|
||||
// Cluster
|
||||
"create_cluster",
|
||||
"remove_cluster",
|
||||
"get_cluster",
|
||||
"get_clusters",
|
||||
"run_cluster",
|
||||
// Processor
|
||||
"get_running_clusters",
|
||||
"get_processes_by_path",
|
||||
"kill_process",
|
||||
// Settings
|
||||
"get_settings",
|
||||
"set_settings",
|
||||
// Metadata
|
||||
"get_minecraft_versions",
|
||||
// Other
|
||||
"get_program_info",
|
||||
]),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,32 +20,27 @@ macro_rules! collect_commands {
|
|||
)
|
||||
.commands(tauri_specta::collect_commands![
|
||||
// User
|
||||
begin_msa,
|
||||
begin_msa,
|
||||
finish_msa,
|
||||
get_users,
|
||||
get_user,
|
||||
remove_user,
|
||||
|
||||
// Cluster
|
||||
// Cluster
|
||||
create_cluster,
|
||||
remove_cluster,
|
||||
remove_cluster,
|
||||
get_cluster,
|
||||
get_clusters,
|
||||
run_cluster,
|
||||
|
||||
// Processor
|
||||
get_running_clusters,
|
||||
get_processes_by_path,
|
||||
kill_process,
|
||||
|
||||
// Settings
|
||||
run_cluster,
|
||||
// Processor
|
||||
get_running_clusters,
|
||||
get_processes_by_path,
|
||||
kill_process,
|
||||
// Settings
|
||||
get_settings,
|
||||
set_settings,
|
||||
|
||||
// Metadata
|
||||
get_minecraft_versions,
|
||||
|
||||
// Other
|
||||
// Metadata
|
||||
get_minecraft_versions,
|
||||
// Other
|
||||
get_program_info,
|
||||
])
|
||||
}};
|
||||
|
|
@ -90,41 +85,48 @@ pub async fn create_cluster(props: CreateCluster) -> Result<Uuid, String> {
|
|||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn remove_cluster(uuid: Uuid) -> Result<(), String> {
|
||||
let path = ClusterPath::find_by_uuid(uuid).await?;
|
||||
Ok(cluster::remove(&path).await?)
|
||||
let path = ClusterPath::find_by_uuid(uuid).await?;
|
||||
Ok(cluster::remove(&path).await?)
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn run_cluster(uuid: Uuid) -> Result<(Uuid, u32), String> {
|
||||
let path = ClusterPath::find_by_uuid(uuid).await?;
|
||||
let c_lock = cluster::run(&path).await?;
|
||||
let path = ClusterPath::find_by_uuid(uuid).await?;
|
||||
let c_lock = cluster::run(&path).await?;
|
||||
|
||||
let p_uuid = c_lock.read().await.uuid;
|
||||
let p_pid = c_lock
|
||||
.read()
|
||||
.await
|
||||
.current_child
|
||||
.read()
|
||||
.await
|
||||
.id()
|
||||
.unwrap_or(0);
|
||||
|
||||
let p_uuid = c_lock.read().await.uuid;
|
||||
let p_pid = c_lock.read().await.current_child.read().await.id().unwrap_or(0);
|
||||
|
||||
// processor::wait_for(&mut proc).await?;
|
||||
|
||||
Ok((p_uuid, p_pid))
|
||||
Ok((p_uuid, p_pid))
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_running_clusters() -> Result<Vec<Cluster>, String> {
|
||||
Ok(processor::get_running_clusters().await?)
|
||||
Ok(processor::get_running_clusters().await?)
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_processes_by_path(path: ClusterPath) -> Result<Vec<Uuid>, String> {
|
||||
Ok(processor::get_uuids_by_cluster_path(path).await?)
|
||||
Ok(processor::get_uuids_by_cluster_path(path).await?)
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn kill_process(uuid: Uuid) -> Result<(), String> {
|
||||
processor::kill_by_uuid(uuid).await?;
|
||||
Ok(())
|
||||
processor::kill_by_uuid(uuid).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// #[specta::specta]
|
||||
|
|
@ -168,8 +170,8 @@ pub async fn kill_process(uuid: Uuid) -> Result<(), String> {
|
|||
#[tauri::command]
|
||||
pub async fn get_cluster(uuid: Uuid) -> Result<Cluster, String> {
|
||||
match cluster::get_by_uuid(uuid, None).await? {
|
||||
Some(cluster) => Ok(cluster),
|
||||
None => Err("Cluster does not exist".into())
|
||||
Some(cluster) => Ok(cluster),
|
||||
None => Err("Cluster does not exist".into()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +190,9 @@ pub async fn get_clusters() -> Result<Vec<Cluster>, String> {
|
|||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_minecraft_versions() -> Result<Vec<Version>, String> {
|
||||
Ok(onelauncher::api::metadata::get_minecraft_versions().await?.versions)
|
||||
Ok(onelauncher::api::metadata::get_minecraft_versions()
|
||||
.await?
|
||||
.versions)
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
|
|
@ -271,4 +275,4 @@ pub async fn remove_user(uuid: Uuid) -> Result<(), String> {
|
|||
|
||||
// #[specta::specta]
|
||||
// #[tauri::command]
|
||||
// pub async fn
|
||||
// pub async fn
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
"connect-src": ["https://modrinth.com", "https://api.modrinth.com", "https://polyfrost.org", "https://*.polyfrost.org", "https://*.cloudflare.com", "https://api.mclo.gs"],
|
||||
"img-src": ["'self'", "tauri:", "https:", "data:", "blob:", "'unsafe-inline'", "asset:", "https://asset.localhost"],
|
||||
"script-src": ["'self'", "https://*.cloudflare.com", "https://*.polyfrost.org"],
|
||||
"frame-src": ["https://*.cloudflare.com", "https://www.youtube.com", "https://www.youtube-nocookie.com", "https://discord.com", "'self'"],
|
||||
"frame-src": ["https://*.cloudflare.com", "https://www.youtube.com", "https://www.youtube-nocookie.com", "https://discord.com", "https://*.githubusercontent.com", "'self'"],
|
||||
"style-src": ["unsafe-inline", "'self'"]
|
||||
},
|
||||
"pattern": {
|
||||
|
|
|
|||
|
|
@ -3,13 +3,9 @@ import type { JSX, ParentProps } from 'solid-js';
|
|||
import { For, createEffect, splitProps } from 'solid-js';
|
||||
|
||||
type SidebarProps = ParentProps & {
|
||||
state: {
|
||||
[key: string]: any;
|
||||
};
|
||||
state: Record<string, any>;
|
||||
base: string;
|
||||
links: {
|
||||
[key: string]: ([JSX.Element, string, string] | undefined)[];
|
||||
};
|
||||
links: Record<string, ([JSX.Element, string, string] | undefined)[]>;
|
||||
};
|
||||
|
||||
function Sidebar(props: SidebarProps) {
|
||||
|
|
|
|||
|
|
@ -107,14 +107,18 @@ pub async fn create_cluster(
|
|||
.await?;
|
||||
}
|
||||
|
||||
if !skip.unwrap_or(false) {
|
||||
// let cluster = cluster.clone();
|
||||
// tokio::task::spawn(async move {
|
||||
if let Err(err) = crate::game::install_minecraft(&cluster, None, false).await {
|
||||
tracing::error!("failed to install Minecraft while creating cluster {}: {}", cluster.uuid, err);
|
||||
}
|
||||
// });
|
||||
}
|
||||
if !skip.unwrap_or(false) {
|
||||
// let cluster = cluster.clone();
|
||||
// tokio::task::spawn(async move {
|
||||
if let Err(err) = crate::game::install_minecraft(&cluster, None, false).await {
|
||||
tracing::error!(
|
||||
"failed to install Minecraft while creating cluster {}: {}",
|
||||
cluster.uuid,
|
||||
err
|
||||
);
|
||||
}
|
||||
// });
|
||||
}
|
||||
|
||||
State::sync().await?;
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ pub async fn list(clear: Option<bool>) -> crate::Result<Vec<Cluster>> {
|
|||
// pub async fn list_grouped(clear: Option<bool>) -> crate::Result<HashMap<String, Cluster>> {
|
||||
// let clusters = list(clear).await?;
|
||||
// let mut map = HashMap::new();
|
||||
|
||||
|
||||
// }
|
||||
|
||||
/// run a Minecraft [`Cluster`] using the default credentials.
|
||||
|
|
|
|||
|
|
@ -53,9 +53,12 @@ impl ClusterPath {
|
|||
ClusterPath(path.into())
|
||||
}
|
||||
|
||||
pub async fn find_by_uuid(uuid: Uuid) -> crate::Result<Self> {
|
||||
Ok(crate::cluster::get_by_uuid(uuid, None).await?.ok_or(anyhow::anyhow!("Cluster does not exist"))?.cluster_path())
|
||||
}
|
||||
pub async fn find_by_uuid(uuid: Uuid) -> crate::Result<Self> {
|
||||
Ok(crate::cluster::get_by_uuid(uuid, None)
|
||||
.await?
|
||||
.ok_or(anyhow::anyhow!("Cluster does not exist"))?
|
||||
.cluster_path())
|
||||
}
|
||||
|
||||
/// Get the full [`PathBuf`] of the current cluster path.
|
||||
pub async fn full_path(&self) -> crate::Result<PathBuf> {
|
||||
|
|
@ -325,20 +328,6 @@ impl std::fmt::Display for Loader {
|
|||
}
|
||||
}
|
||||
|
||||
impl Loader {
|
||||
/// Get the loader version to lowercase for metadata fetching.
|
||||
pub(crate) fn as_meta(&self) -> &'static str {
|
||||
match *self {
|
||||
Self::Vanilla => "vanilla",
|
||||
Self::Forge => "forge",
|
||||
Self::Fabric => "fabric",
|
||||
Self::NeoForge => "neoforge",
|
||||
Self::Quilt => "quilt",
|
||||
Self::LegacyFabric => "legacyfabric",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Custom Java arguments on a per-cluster basis.
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use std::collections::HashMap;
|
|||
use std::fmt::Write;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::constants::{MICROSOFT_CLIENT_ID, SCOPES, REDIRECT_URL};
|
||||
use crate::constants::{MICROSOFT_CLIENT_ID, REDIRECT_URL, SCOPES};
|
||||
|
||||
const AUTH_STORE: &str = "authentication.json";
|
||||
|
||||
|
|
@ -657,13 +657,13 @@ async fn xsts_authorize(
|
|||
"/xsts/authorize",
|
||||
json!({
|
||||
"RelyingParty": "rp://api.minecraftservices.com/",
|
||||
"TokenType": "JWT",
|
||||
"Properties": {
|
||||
"SandboxId": "RETAIL",
|
||||
"UserTokens": [authorize.user_token.token],
|
||||
"DeviceToken": device_token,
|
||||
"TitleToken": authorize.title_token.token,
|
||||
},
|
||||
"TokenType": "JWT",
|
||||
"Properties": {
|
||||
"SandboxId": "RETAIL",
|
||||
"UserTokens": [authorize.user_token.token],
|
||||
"DeviceToken": device_token,
|
||||
"TitleToken": authorize.title_token.token,
|
||||
},
|
||||
}),
|
||||
key,
|
||||
MinecraftAuthStep::XstsAuthorize,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ pub async fn generate_context(
|
|||
_fetch_semaphore: &FetchSemaphore,
|
||||
// credentials: &Credentials,
|
||||
) -> crate::Result<HashMap<PackagePath, Package>> {
|
||||
let mut hashes = HashMap::new();
|
||||
let mut handles = vec![];
|
||||
|
||||
for path in paths {
|
||||
if !path.exists() {
|
||||
|
|
@ -40,22 +40,35 @@ pub async fn generate_context(
|
|||
continue;
|
||||
}
|
||||
}
|
||||
let mut file = tokio::fs::File::open(path.clone())
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, &path))?;
|
||||
let mut buffer = [0u8; 4096];
|
||||
let mut sha512 = sha2::Sha512::new();
|
||||
|
||||
loop {
|
||||
let read = file.read(&mut buffer).await.map_err(IOError::from)?;
|
||||
if read == 0 {
|
||||
break;
|
||||
let handle = tokio::spawn(async move {
|
||||
let mut file = tokio::fs::File::open(path.clone())
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, &path))?;
|
||||
|
||||
let mut buffer = [0u8; 65536];
|
||||
let mut hasher = sha2::Sha512::new();
|
||||
|
||||
loop {
|
||||
let read = file.read(&mut buffer).await.map_err(IOError::from)?;
|
||||
if read == 0 {
|
||||
break;
|
||||
}
|
||||
hasher.update(&buffer[..read]);
|
||||
}
|
||||
sha512.update(&buffer[..read]);
|
||||
}
|
||||
|
||||
let hash = format!("{:x}", sha512.finalize());
|
||||
hashes.insert(hash, path.clone());
|
||||
let hash = format!("{:x}", hasher.finalize());
|
||||
Ok::<_, crate::Error>((hash, path))
|
||||
});
|
||||
|
||||
handles.push(handle);
|
||||
}
|
||||
|
||||
let mut file_path_hashes = HashMap::new();
|
||||
|
||||
for handle in handles {
|
||||
let (hash, path) = handle.await??;
|
||||
file_path_hashes.insert(hash, path);
|
||||
}
|
||||
|
||||
let result = HashMap::new();
|
||||
|
|
|
|||
|
|
@ -266,7 +266,10 @@ pub async fn check_java_instance(path: &Path) -> Option<JavaVersion> {
|
|||
}
|
||||
|
||||
let file_path = tempdir.join("JavaInfo.class");
|
||||
tracing::info!("checking java with {}", file_path.to_string_lossy().to_string());
|
||||
tracing::info!(
|
||||
"checking java with {}",
|
||||
file_path.to_string_lossy().to_string()
|
||||
);
|
||||
io::write(&file_path, bytes).await.ok()?;
|
||||
|
||||
let output = Command::new(&java)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
windows_subsystem = "windows"
|
||||
)]
|
||||
|
||||
use onelauncher::prelude::*;
|
||||
use onelauncher::cluster::create::create_cluster;
|
||||
use onelauncher::prelude::*;
|
||||
|
||||
pub async fn authenticate_mc() -> onelauncher::Result<MinecraftCredentials> {
|
||||
println!("a browser will open, follow login flow");
|
||||
|
|
@ -24,16 +24,14 @@ pub async fn authenticate_mc() -> onelauncher::Result<MinecraftCredentials> {
|
|||
let parsed = url::Url::parse(input.trim()).expect("idk");
|
||||
let code = if let Some((_, code)) = parsed.query_pairs().find(|x| x.0 == "code") {
|
||||
let code = code.clone();
|
||||
code.to_string()
|
||||
code.to_string()
|
||||
} else {
|
||||
panic!()
|
||||
};
|
||||
let creds = minecraft::finish(code.as_str(), login).await?;
|
||||
|
||||
|
||||
println!("logged in {}", creds.username);
|
||||
Ok(creds)
|
||||
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
|
|
|||
10
package.json
10
package.json
|
|
@ -22,17 +22,17 @@
|
|||
"release:node": "pnpm bumpp -r"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@flowr/eslint-config": "^3.8.8",
|
||||
"@types/node": "^20.14.10",
|
||||
"@vitest/ui": "^2.0.3",
|
||||
"@flowr/eslint-config": "^3.9.1",
|
||||
"@types/node": "^20.14.12",
|
||||
"@vitest/ui": "^2.0.4",
|
||||
"bumpp": "^9.4.1",
|
||||
"eslint": "^9.7.0",
|
||||
"eslint-plugin-solid": "^0.14.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsx": "^4.16.2",
|
||||
"typescript": "^5.5.3",
|
||||
"typescript": "^5.5.4",
|
||||
"vite": "^5.3.4",
|
||||
"vitest": "^2.0.3"
|
||||
"vitest": "^2.0.4"
|
||||
},
|
||||
"pnpm": {
|
||||
"patchDependencies": {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
"@rspc/solid-query": "^0.2.3",
|
||||
"@rspc/tauri": "^0.2.0",
|
||||
"@solid-primitives/deep": "^0.2.9",
|
||||
"@tanstack/solid-query": "^5.51.2",
|
||||
"@tanstack/solid-query": "^5.51.9",
|
||||
"fast-equals": "^5.0.1",
|
||||
"plausible-tracker": "^0.3.9",
|
||||
"solid-js": "^1.8.18",
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@
|
|||
"tauri": "tsx tauri.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@flowr/utils": "^3.8.8",
|
||||
"@flowr/utils": "^3.9.1",
|
||||
"@iarna/toml": "^2.2.5",
|
||||
"execa": "^9.3.0",
|
||||
"semver": "^7.6.2",
|
||||
"undici": "^6.19.2"
|
||||
"semver": "^7.6.3",
|
||||
"undici": "^6.19.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/iarna__toml": "^2.0.5",
|
||||
|
|
|
|||
1225
pnpm-lock.yaml
generated
1225
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue