From cd48702156df19ae9c728dee07ea85bfc65dca9e Mon Sep 17 00:00:00 2001 From: awakenginexe <267649137+awakenginexe@users.noreply.github.com> Date: Thu, 12 Nov 2026 01:02:40 +0700 Subject: [PATCH 1/2] release: Awake Modpack Manager 1.3.2 Checking a plan with a CurseForge mod whose author turned off third-party distribution used to stop at "CurseForge project does not allow third-party distribution". The Review page now lists those mods with a button that opens the file's CurseForge download page, an "Open all" button when there are several, and a file picker. While the page waits, the host looks in the Downloads folder and moves the jar whose SHA-1 is the one CurseForge lists into the project's mods folder, then the install leaves the draft. Nothing in mods is overwritten. The helper cannot accept a local file, so the mod shows as a manually added file. --- README.md | 8 +- docs/HANDOFF.md | 7 +- docs/releases/v1.3.2.md | 21 ++++ package-lock.json | 4 +- package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/src/lib.rs | 3 + src-tauri/src/manual.rs | 191 +++++++++++++++++++++++++++++ src-tauri/tauri.conf.json | 2 +- src/backend/ManagerBackend.ts | 9 +- src/backend/composite.ts | 2 + src/backend/contract.ts | 2 + src/backend/helper/HelperClient.ts | 9 ++ src/backend/host.ts | 6 +- src/backend/mock/MockBackend.ts | 16 ++- src/components/ManualDownloads.vue | 98 +++++++++++++++ src/i18n/en.ts | 8 ++ src/i18n/th.ts | 8 ++ src/i18n/zh-CN.ts | 8 ++ src/i18n/zh-TW.ts | 8 ++ src/views/ReviewView.vue | 6 +- tests/components.test.ts | 20 +++ tests/v030.test.ts | 2 + 24 files changed, 427 insertions(+), 17 deletions(-) create mode 100644 docs/releases/v1.3.2.md create mode 100644 src-tauri/src/manual.rs create mode 100644 src/components/ManualDownloads.vue diff --git a/README.md b/README.md index 559f8aa..8a59e43 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,16 @@ A Windows desktop app for building and maintaining Minecraft modpacks. It create projects and installs real mods from Modrinth, with every change reviewed before it is applied. Awake Launcher is not required. -> **What's new in 1.3.1:** see [docs/releases/v1.3.1.md](docs/releases/v1.3.1.md). +> **What's new in 1.3.2:** see [docs/releases/v1.3.2.md](docs/releases/v1.3.2.md). -**Version 1.3.1 · Windows x64 · English, ไทย, 简体中文, 繁體中文 · GPL-3.0-only** +**Version 1.3.2 · Windows x64 · English, ไทย, 简体中文, 繁體中文 · GPL-3.0-only** ## Install -1. Download `Awake-Modpack-Manager-v1.3.1-Windows-x64-Setup.exe` from the +1. Download `Awake-Modpack-Manager-v1.3.2-Windows-x64-Setup.exe` from the [latest release](https://github.com/awakenginexe/Awake-Modpack-Manager/releases/latest). 2. Optional: check it against `SHA256SUMS.txt` from the same release - (`Get-FileHash .\Awake-Modpack-Manager-v1.3.1-Windows-x64-Setup.exe`). + (`Get-FileHash .\Awake-Modpack-Manager-v1.3.2-Windows-x64-Setup.exe`). 3. Run the installer. It installs for your Windows user only (no administrator rights) into `%LOCALAPPDATA%\Awake Modpack Manager`. The installer is **not code-signed** yet, so Windows SmartScreen may warn that it is from an diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index 8452f22..27836b4 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -1,10 +1,10 @@ -# Development checkpoint: Manager 1.3.1 and Native Core 0.4.2 +# Development checkpoint: Manager 1.3.2 and Native Core 0.4.2 -Unreleased until the owner approves the pull request and tags `v1.3.1`. +Unreleased until the owner approves the pull request and tags `v1.3.2`. ## Where things are -- Manager: branch `release/1.3.1`. `npm ci`, then `npm test`, `npm run typecheck`, `cargo test --manifest-path src-tauri/Cargo.toml --lib`. +- Manager: branch `release/1.3.2`. `npm ci`, then `npm test`, `npm run typecheck`, `cargo test --manifest-path src-tauri/Cargo.toml --lib`. - Native Core: Awake Launcher branch `release/3.2.2`. `.github/workflows/native-core-package.yml` builds it with the recorded toolchain and commits a delivery under `native-core/redistribution//`. `scripts/helper-pin.json` pins that delivery. - Release: pushing a version tag runs `.github/workflows/awake-beta.yml`, which builds, verifies, assembles every asset and publishes the release. `SHA256SUMS.txt` is required by in-app updates. @@ -14,6 +14,7 @@ Unreleased until the owner approves the pull request and tags `v1.3.1`. - `src-tauri/src/updater.rs`: GitHub release check and checksum-verified installer run. - `src-tauri/src/desktop.rs`: content folders of a project or managed Launcher instance (list a folder, edit a text file, view an image (1.3.1), add files, Recycle Bin), shell open. Mods are never touched here. - `src-tauri/src/content.rs` (1.3.0): resource pack and shader search, versions and direct, checksum-verified install into `resourcepacks` / `shaderpacks`. +- `src-tauri/src/manual.rs` (1.3.2): restricted CurseForge mods. Names the exact file and its download page, then moves the SHA-1-matching jar from Downloads (or a picked file) into `mods`. The only place the host puts a mod file in place; the helper lists it as a manual file. - `HelperClient.installPack`: one local operation over fetch, upload, create, prepare and apply. A failure removes the created project. - FTB versions become a generated `.mrpack` manifest; ATLauncher and Technic become a CurseForge-format archive of overrides. - Native Core: `workspaces.delete`, `workspaces.rename`, `imports.prepare` with `packAuthoritative`, `removeInventoryIds` and `allowLoaderUpdate`, a helper-only hash cache, batched provider reads and parallel downloads. diff --git a/docs/releases/v1.3.2.md b/docs/releases/v1.3.2.md new file mode 100644 index 0000000..b251e37 --- /dev/null +++ b/docs/releases/v1.3.2.md @@ -0,0 +1,21 @@ +# Awake Modpack Manager 1.3.2 + +Works with **Awake Launcher 3.2.2**. No Launcher update is needed. + +## Added + +- **Mods that can only be downloaded from the CurseForge website.** Some authors turn off third-party distribution, and checking a plan with one of their mods used to stop at "CurseForge project does not allow third-party distribution". The Review page now lists those mods with an **Open download page** button: CurseForge starts the download after a few seconds, the Manager notices the file in your Downloads folder, moves it into the pack and takes the install out of the draft. Check the plan again for the rest of the draft. +- **Open all** opens every download page at once when there is more than one. +- **Choose downloaded file…** is for a download that went somewhere else, or a Downloads folder that is not in its usual place. + +## How it behaves + +- A file is taken only if its SHA-1 is the one CurseForge lists for that exact version, whatever the browser named it. Anything else in Downloads is left alone, and so is a download still in progress. +- Nothing in `mods` is overwritten. If another file already has the name, the download stays where it is. +- The Downloads folder is only looked at while the Review page is waiting for one of these files. +- A mod added this way shows as a manually added file: the helper does not track it, so the Manager does not offer updates for it. A CurseForge export still recognises it by its fingerprint. +- Only mods in your draft are offered. A restricted mod that is pulled in as a dependency still stops the check; add it to the draft yourself to get its download button. + +## Not verified on a real machine yet + +The demo data and the automated tests cover the Review page, and the host's file matching and move have their own tests. Still unverified: the whole flow in the desktop app against CurseForge and a real Downloads folder. diff --git a/package-lock.json b/package-lock.json index 6f5800e..38e2832 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "awake-modpack-manager", - "version": "1.3.1", + "version": "1.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "awake-modpack-manager", - "version": "1.3.1", + "version": "1.3.2", "license": "GPL-3.0-only", "dependencies": { "@lucide/vue": "1.59.0", diff --git a/package.json b/package.json index a970c45..4e45d81 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "awake-modpack-manager", "private": true, - "version": "1.3.1", + "version": "1.3.2", "license": "GPL-3.0-only", "type": "module", "engines": { diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 3f27215..2da195e 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -224,7 +224,7 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "awake-modpack-manager" -version = "1.3.1" +version = "1.3.2" dependencies = [ "md-5", "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 5d89067..4a0b1d7 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "awake-modpack-manager" -version = "1.3.1" +version = "1.3.2" description = "Awake Modpack Manager desktop host" license = "GPL-3.0-only" repository = "https://github.com/awakenginexe/Awake-Modpack-Manager" diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index a48f88d..7648424 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -13,6 +13,7 @@ mod desktop; mod discovery; mod files; mod helper; +mod manual; mod pipe; mod profile_access; mod providers; @@ -114,6 +115,8 @@ pub fn run() { content::content_search, content::content_versions, content::content_install, + manual::manual_sources, + manual::manual_claim, desktop::workspace_forget_missing, desktop::workspace_open, desktop::open_url, diff --git a/src-tauri/src/manual.rs b/src-tauri/src/manual.rs new file mode 100644 index 0000000..be4d812 --- /dev/null +++ b/src-tauri/src/manual.rs @@ -0,0 +1,191 @@ +//! Mods whose CurseForge author turned off third-party distribution. The helper may not download +//! them, so the user downloads each one in their browser and the Manager takes exactly that file +//! from the Downloads folder (or one they pick) into the project's `mods` folder. +//! +//! This is the one place the host puts a mod file in place itself: the helper has no way to accept +//! a local file. A file is taken only if its SHA-1 is the one CurseForge lists, and nothing in +//! `mods` is ever overwritten. The helper then lists it as a manually added file. + +use crate::providers::{blocking, cf_get, cf_post, curseforge_key, encode, err, hex, s, HostResult}; +use serde::{Deserialize, Serialize}; +use serde_json::{json, Value}; +use sha1::{Digest, Sha1}; +use std::fs; +use std::path::{Path, PathBuf}; +use tauri_plugin_dialog::DialogExt; + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Item { + project_id: String, + #[serde(default)] + version_id: Option, +} + +/// One file the user has to download by hand. +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Wanted { + project_id: String, + name: String, + file_name: String, + sha1: String, + size: u64, + /// CurseForge's own download page for this file: it starts the download after a few seconds. + url: String, +} + +/// The newest file for this game version and loader, stable releases first. +pub fn newest_file(project: &Value, minecraft: &str, loader: i64) -> Option { + project["latestFilesIndexes"].as_array()?.iter() + .filter(|f| f["gameVersion"] == minecraft && (loader == 0 || f["modLoader"] == loader)) + .max_by_key(|f| (f["releaseType"] == 1, f["fileId"].as_i64().unwrap_or(0)))?["fileId"].as_i64() +} + +/// A mod file name that can only ever name a jar directly inside `mods`. +fn jar_name(name: &str) -> bool { + !name.is_empty() && name.len() <= 200 && !name.starts_with(['.', ' ']) && name.to_ascii_lowercase().ends_with(".jar") && !name.chars().any(|c| c.is_control() || r#"<>:"/\|?*"#.contains(c)) +} + +pub fn wanted(project: &Value, file: &Value) -> Option { + let page = s(&project["links"], "websiteUrl"); + let sha1 = file["hashes"].as_array()?.iter().find(|h| h["algo"] == 1).map(|h| s(h, "value").to_ascii_lowercase())?; + let (id, file_name) = (file["id"].as_i64()?, s(file, "fileName")); + // Without a checksum there is no telling which download is the right one, so it is not offered. + (page.starts_with("https://www.curseforge.com/") && sha1.len() == 40 && jar_name(file_name)).then(|| Wanted { + project_id: project["id"].as_i64().unwrap_or(0).to_string(), + name: s(project, "name").into(), + file_name: file_name.into(), + sha1, + size: file["fileLength"].as_u64().unwrap_or(0), + url: format!("{}/download/{id}", page.trim_end_matches('/')), + }) +} + +/// Which of these CurseForge projects must be downloaded by hand, and the exact file for each. +#[tauri::command] +pub async fn manual_sources(items: Vec, minecraft_version: String, loader: String) -> HostResult> { + blocking(move || { + if curseforge_key().is_none() { + return Ok(vec![]); + } + let loader = match loader.as_str() { "forge" => 1, "fabric" => 4, "quilt" => 5, "neoforge" => 6, _ => 0 }; + let ids: Vec = items.iter().filter_map(|i| i.project_id.parse().ok()).collect(); + let mut out = vec![]; + for chunk in ids.chunks(500) { + let page = cf_post("/mods", &json!({"modIds": chunk, "filterPcOnly": false}))?; + for project in page["data"].as_array().into_iter().flatten().filter(|p| p["allowModDistribution"] == false) { + let id = project["id"].as_i64().unwrap_or(0); + let chosen = items.iter().find(|i| i.project_id == id.to_string()).and_then(|i| i.version_id.as_ref()?.parse::().ok()); + let Some(file_id) = chosen.or_else(|| newest_file(project, &minecraft_version, loader)) else { continue }; + let file = cf_get(&format!("/mods/{id}/files/{}", encode(&file_id.to_string())))?; + out.extend(wanted(project, &file["data"])); + } + } + Ok(out) + }) + .await +} + +fn sha1_of(path: &Path) -> Option { + let mut hash = Sha1::new(); + std::io::copy(&mut fs::File::open(path).ok()?, &mut hash).ok()?; + Some(hex(&hash.finalize())) +} + +/// Move each wanted file found among `candidates` into `mods`. Returns the project ids now in place. +pub fn claim(mods: &Path, wanted: &[Wanted], candidates: &[PathBuf]) -> HostResult> { + let mut done = vec![]; + for w in wanted.iter().filter(|w| jar_name(&w.file_name) && w.sha1.len() == 40) { + let target = mods.join(&w.file_name); + if fs::symlink_metadata(&target).is_ok() { + // Already there from an earlier pass. A different file of the same name is left alone. + if sha1_of(&target).as_deref() == Some(&w.sha1) { + done.push(w.project_id.clone()); + } + continue; + } + // Size first, so a folder full of other jars is not hashed on every pass. A download still + // in progress has another name or another size, and never the right checksum. + let found = candidates.iter().find(|p| fs::metadata(p).is_ok_and(|m| m.is_file() && m.len() == w.size) && sha1_of(p).as_deref() == Some(&w.sha1)); + let Some(source) = found else { continue }; + fs::create_dir_all(mods).or_else(|e| err("io", e.to_string()))?; + if fs::rename(source, &target).is_err() { + // Downloads on another drive: copy under a temporary name, then remove the download. + let partial = mods.join(format!(".{}.{}.partial", w.file_name, std::process::id())); + if let Err(e) = fs::copy(source, &partial).and_then(|_| fs::rename(&partial, &target)) { + let _ = fs::remove_file(&partial); + return err("io", format!("{}: {e}", w.file_name)); + } + let _ = fs::remove_file(source); + } + done.push(w.project_id.clone()); + } + Ok(done) +} + +fn jars_in(dir: &Path) -> Vec { + fs::read_dir(dir).into_iter().flatten().flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|x| x.eq_ignore_ascii_case("jar"))).collect() +} + +/// Look for the wanted files in Downloads, or (`pick`) in files the user chooses, and move the ones +/// found into the project's `mods` folder. None when the user cancels the file dialog. +#[tauri::command] +pub async fn manual_claim(app: tauri::AppHandle, workspace: String, wanted: Vec, pick: bool) -> HostResult>> { + blocking(move || { + let mods = crate::export::game_folder(&workspace)?.join("mods"); + let candidates = if pick { + let Some(picked) = app.dialog().file().add_filter("Jar", &["jar"]).blocking_pick_files() else { return Ok(None) }; + picked.into_iter().filter_map(|p| p.into_path().ok()).collect() + } else { + // shortcut: assumes Downloads is %USERPROFILE%\Downloads; a moved Downloads folder or another + // browser folder goes through the file dialog. Upgrade to SHGetKnownFolderPath if that bites. + std::env::var_os("USERPROFILE").map_or(vec![], |home| jars_in(&Path::new(&home).join("Downloads"))) + }; + claim(&mods, &wanted, &candidates).map(Some) + }) + .await +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn the_exact_file_is_named_with_its_download_page() { + let project = json!({"id": 7, "name": "LuckPerms GUI", "allowModDistribution": false, "links": {"websiteUrl": "https://www.curseforge.com/minecraft/mc-mods/luckperms-gui"}, + "latestFilesIndexes": [{"gameVersion": "1.20.1", "modLoader": 1, "releaseType": 2, "fileId": 30}, {"gameVersion": "1.20.1", "modLoader": 1, "releaseType": 1, "fileId": 20}, {"gameVersion": "1.20.1", "modLoader": 4, "releaseType": 1, "fileId": 40}, {"gameVersion": "1.21", "modLoader": 1, "releaseType": 1, "fileId": 50}]}); + assert_eq!(newest_file(&project, "1.20.1", 1), Some(20), "a release beats a newer beta"); + assert_eq!(newest_file(&project, "1.19", 1), None); + let file = json!({"id": 20, "fileName": "lpgui-1.0.jar", "fileLength": 3, "hashes": [{"algo": 2, "value": "x"}, {"algo": 1, "value": "A9993E364706816ABA3E25717850C26C9CD0D89D"}]}); + let w = wanted(&project, &file).unwrap(); + assert_eq!(w, Wanted { project_id: "7".into(), name: "LuckPerms GUI".into(), file_name: "lpgui-1.0.jar".into(), sha1: "a9993e364706816aba3e25717850c26c9cd0d89d".into(), size: 3, url: "https://www.curseforge.com/minecraft/mc-mods/luckperms-gui/download/20".into() }); + assert_eq!(wanted(&project, &json!({"id": 20, "fileName": "../evil.jar", "hashes": file["hashes"]})), None); + assert_eq!(wanted(&project, &json!({"id": 20, "fileName": "a.jar", "hashes": []})), None, "no checksum, no offer"); + } + + #[test] + fn only_the_file_with_the_listed_checksum_is_moved_and_nothing_is_overwritten() { + let root = std::env::temp_dir().join(format!("awake-mm-manual-{}", std::process::id())); + let _ = fs::remove_dir_all(&root); + let (downloads, mods) = (root.join("dl"), root.join("mods")); + fs::create_dir_all(&downloads).unwrap(); + // sha1("abc"); the browser renamed the download, and a same-size impostor sits next to it. + let w = |id: &str, name: &str| Wanted { project_id: id.into(), name: id.into(), file_name: name.into(), sha1: "a9993e364706816aba3e25717850c26c9cd0d89d".into(), size: 3, url: String::new() }; + fs::write(downloads.join("mod (1).jar"), "abc").unwrap(); + fs::write(downloads.join("other.jar"), "xyz").unwrap(); + fs::write(downloads.join("notes.txt"), "abc").unwrap(); + assert_eq!(jars_in(&downloads).len(), 2); + assert!(claim(&mods, &[w("1", "mod.jar")], &[downloads.join("other.jar")]).unwrap().is_empty()); + assert_eq!(claim(&mods, &[w("1", "mod.jar"), w("2", "..\\up.jar")], &jars_in(&downloads)).unwrap(), ["1"]); + assert_eq!(fs::read_to_string(mods.join("mod.jar")).unwrap(), "abc"); + assert!(!downloads.join("mod (1).jar").exists() && downloads.join("other.jar").exists()); + assert_eq!(claim(&mods, &[w("1", "mod.jar")], &[]).unwrap(), ["1"], "already in place"); + // A different file already has the name: it stays, and the download is not taken. + fs::write(mods.join("taken.jar"), "old").unwrap(); + fs::write(downloads.join("taken.jar"), "abc").unwrap(); + assert!(claim(&mods, &[w("3", "taken.jar")], &jars_in(&downloads)).unwrap().is_empty()); + assert_eq!(fs::read_to_string(mods.join("taken.jar")).unwrap(), "old"); + fs::remove_dir_all(&root).unwrap(); + } +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 0a48499..3fe7fbd 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "Awake Modpack Manager", - "version": "1.3.1", + "version": "1.3.2", "identifier": "io.github.awakenginexe.AwakeModpackManager", "build": { "frontendDist": "../dist", diff --git a/src/backend/ManagerBackend.ts b/src/backend/ManagerBackend.ts index a2544f4..c661b8e 100644 --- a/src/backend/ManagerBackend.ts +++ b/src/backend/ManagerBackend.ts @@ -1,7 +1,7 @@ import type { Accepted, ImportInspection, LoaderKind, WorkspaceSnapshot, ProjectVersion, ProviderId, VersionCatalog, ApplyRequest, ContentArea, ContentEntry, CreateInstanceRequest, Draft, ExportFormat, ExportReport, ExportRequest, Handshake, InstallPackRequest, PackSearchPage, PackSearchQuery, PackVersion, InstanceSummary, InstanceWarning, Installation, ModInventory, - OperationStatus, RecoveryStatus, ResolvedPlan, SearchPage, SearchQuery, DependencyResolution, VersionRef, WorkspaceExportItem, ExportFileMatch, ExportRestriction, InstanceZipResult, + OperationStatus, RecoveryStatus, ResolvedPlan, SearchPage, SearchQuery, DependencyResolution, VersionRef, WorkspaceExportItem, ExportFileMatch, ExportRestriction, InstanceZipResult, ManualDownload, AddedContent, ContentImage, ContentKind, ContentSearchPage, ContentSearchQuery, ContentTextFile, ContentVersion, InstalledContent, ProviderInfo } from './contract'; import type { LauncherProfile } from './launcher/transport'; import type { ProjectDetail } from './host'; @@ -120,6 +120,13 @@ export interface ManagerBackend { exportMatches?(instanceId: string, target: ProviderId, fileNames: string[]): Promise; /** Which of these CurseForge projects players must download by hand. */ exportRestricted?(instanceId: string, projectIds: string[]): Promise; + /** Which of these CurseForge installs the helper may not download, with the exact file to get by hand. */ + manualDownloads?(instanceId: string, items: { projectId: string; versionId?: string }[]): Promise; + /** + * Move those files, once downloaded, into the instance's mods folder: from Downloads, or (`pick`) from + * files the user chooses. Resolves with the project ids now in place; null when the user cancels. + */ + claimManualDownloads?(instanceId: string, wanted: ManualDownload[], pick: boolean): Promise; /** Describe exactly these mods for a provider format, asking the provider only for what that format needs. */ prepareExport?(instanceId: string, format: 'mrpack' | 'curseforge', entries: WorkspaceExportItem[], onProgress?: (done: number, total: number) => void): Promise; /** Save the whole pack, mod files included, where the user chooses. Null when they cancel. */ diff --git a/src/backend/composite.ts b/src/backend/composite.ts index c992ada..474531b 100644 --- a/src/backend/composite.ts +++ b/src/backend/composite.ts @@ -233,6 +233,8 @@ export function createCompositeBackend(helper: ManagerBackend, launcher: Manager forgetMissingMods: (id) => { const b = byInstance(id).backend; return b.forgetMissingMods ? b.forgetMissingMods(id) : noHelper(); }, exportMatches: (id, target, names) => { const b = byInstance(id).backend; return b.exportMatches ? b.exportMatches(id, target, names) : noHelper(); }, exportRestricted: (id, ids) => { const b = byInstance(id).backend; return b.exportRestricted ? b.exportRestricted(id, ids) : noHelper(); }, + manualDownloads: async (id, items) => byInstance(id).backend.manualDownloads?.(id, items) ?? [], + claimManualDownloads: async (id, wanted, pick) => byInstance(id).backend.claimManualDownloads?.(id, wanted, pick) ?? [], prepareExport: (id, format, entries, onProgress) => { const b = byInstance(id).backend; return b.prepareExport ? b.prepareExport(id, format, entries, onProgress) : noHelper(); }, exportInstanceZip: (id, meta, onProgress) => { const b = byInstance(id).backend; return b.exportInstanceZip ? b.exportInstanceZip(id, meta, onProgress) : noHelper(); }, snapshotWorkspace: (id, onProgress) => { const b = byInstance(id).backend; return b.snapshotWorkspace ? b.snapshotWorkspace(id, onProgress) : noHelper(); }, diff --git a/src/backend/contract.ts b/src/backend/contract.ts index 71db2e4..020e2b8 100644 --- a/src/backend/contract.ts +++ b/src/backend/contract.ts @@ -473,6 +473,8 @@ export type WorkspaceExportItem = | { kind: 'replaced'; fileName: string; provider: ProviderId; projectId: string; versionId: string; name: string }; /** A CurseForge mod whose author turned off third-party distribution. */ export interface ExportRestriction { projectId: string; name: string; pageUrl?: string } +/** One restricted CurseForge file the user downloads in their browser; `url` is its download page. */ +export interface ManualDownload { projectId: string; name: string; fileName: string; sha1: string; size: number; url: string } export interface InstanceZipResult { path: string; files: number; bytes: number } export interface RecoveryStatus { diff --git a/src/backend/helper/HelperClient.ts b/src/backend/helper/HelperClient.ts index 4876d91..ca5cc67 100644 --- a/src/backend/helper/HelperClient.ts +++ b/src/backend/helper/HelperClient.ts @@ -854,6 +854,15 @@ export function createHelperClient(options: HelperClientOptions): ManagerBackend const metas = await options.host.projectMeta(projectIds.map((projectId) => ({ provider: 'curseforge' as const, projectId }))); return metas.filter((m) => m.restricted).map((m) => ({ projectId: m.projectId, name: m.name, pageUrl: m.pageUrl })); }, + async manualDownloads(instanceId, items) { + if (!options.host) return []; + const w = workspaceOf(instanceId); + return options.host.manualSources(items, w.minecraftVersion, w.loader.id); + }, + async claimManualDownloads(instanceId, wanted, pick) { + if (!options.host) return []; + return options.host.manualClaim(workspaceOf(instanceId).workspaceId, wanted, pick); + }, async prepareExport(instanceId, format, entries, onProgress) { if (!has('mods.list')) return notYet('export'); const w = workspaceOf(instanceId); diff --git a/src/backend/host.ts b/src/backend/host.ts index b2a9cd4..b229c9d 100644 --- a/src/backend/host.ts +++ b/src/backend/host.ts @@ -1,4 +1,4 @@ -import { BackendError, type AddedContent, type ContentEntry, type ContentImage, type ContentKind, type ContentSearchPage, type ContentSearchQuery, type ContentTextFile, type ContentVersion, type InstalledContent, type ExportFileMatch, type InstanceZipResult, type PackHit, type PackProviderId, type PackProviderInfo, type PackVersion, type ProviderId } from './contract'; +import { BackendError, type AddedContent, type ContentEntry, type ContentImage, type ContentKind, type ContentSearchPage, type ContentSearchQuery, type ContentTextFile, type ContentVersion, type InstalledContent, type ExportFileMatch, type InstanceZipResult, type ManualDownload, type PackHit, type PackProviderId, type PackProviderInfo, type PackVersion, type ProviderId } from './contract'; /** A pack the desktop host downloaded and verified, ready to upload to the helper. */ export interface FetchedPack { token: string; format: 'mrpack' | 'curseforge'; size: number; sha256: string; notes: string[] } @@ -35,6 +35,8 @@ export interface HostApi { /** Drop the helper's records of mods whose file is gone. Resolves with the file names forgotten. */ workspaceForgetMissing(workspace: string): Promise; exportMatch(workspace: string, target: ProviderId, fileNames: string[]): Promise; + manualSources(items: { projectId: string; versionId?: string }[], minecraftVersion: string, loader: string): Promise; + manualClaim(workspace: string, wanted: ManualDownload[], pick: boolean): Promise; exportInstance(workspace: string, meta: { fileName: string; name: string; version: string; minecraft: string; loader: string }, onProgress?: (written: number, total: number) => void): Promise; } @@ -86,6 +88,8 @@ export function createHostApi(): HostApi { workspaceForgetMissing: (workspace) => hostInvoke('workspace_forget_missing', { workspace }), workspaceOpen: (workspace, area, folder) => hostInvoke('workspace_open', { workspace, area: area ?? null, folder: folder || null }), exportMatch: (workspace, target, fileNames) => hostInvoke('export_match', { workspace, target, fileNames }), + manualSources: (items, minecraftVersion, loader) => hostInvoke('manual_sources', { items, minecraftVersion, loader }), + manualClaim: (workspace, wanted, pick) => hostInvoke('manual_claim', { workspace, wanted, pick }), async exportInstance(workspace, meta, onProgress) { const { listen } = await import('@tauri-apps/api/event'); const stop = await listen<{ done: number; total: number }>('export-progress', (e) => onProgress?.(e.payload.done, e.payload.total)); diff --git a/src/backend/mock/MockBackend.ts b/src/backend/mock/MockBackend.ts index 0d16343..0f0124e 100644 --- a/src/backend/mock/MockBackend.ts +++ b/src/backend/mock/MockBackend.ts @@ -1,4 +1,4 @@ -import type { AddedContent, ContentHit, ContentImage, ContentKind, ContentSearchPage, ContentSearchQuery, ContentTextFile, ContentVersion, ExportFileMatch, ExportRestriction, InstalledContent, InstanceZipResult, ProviderId, WorkspaceExportItem, WorkspaceSnapshot } from '../contract'; +import type { AddedContent, ContentHit, ContentImage, ContentKind, ContentSearchPage, ContentSearchQuery, ContentTextFile, ContentVersion, ExportFileMatch, ExportRestriction, InstalledContent, InstanceZipResult, ManualDownload, ProviderId, WorkspaceExportItem, WorkspaceSnapshot } from '../contract'; import { ALL_CAPABILITIES, BackendError, TERMINAL_STATES, type Accepted, type ApplyRequest, type Capability, type ContentArea, type ContentEntry, type CreateInstanceRequest, @@ -234,12 +234,26 @@ export class MockBackend implements ManagerBackend { const inst = this.instance(draft.instanceId); if (inst.revision !== draft.baseRevision) throw new BackendError('stale-revision', 'The instance changed since this draft was made.'); if (!inst.manageable) throw new BackendError('instance-busy', inst.blockedReason ?? 'Instance cannot be managed now.'); + if (this.restrictedIn(draft.changes).length) throw new BackendError('provider-restricted', 'CurseForge project does not allow third-party distribution.', 'PROVIDER_RESTRICTED'); const plan = this.resolve(draft); this.plans.set(plan.planId, { plan, draft }); return plan; }); } + /** Demo: every 13th CurseForge project has third-party distribution turned off. */ + private restrictedIn(changes: { kind: string; provider?: string; projectId?: string }[]) { + return changes.flatMap((c) => (c.kind === 'install' && c.provider === 'curseforge' && Number(c.projectId!.split('-')[1]) % 13 === 0 ? [c.projectId!] : [])); + } + async manualDownloads(_instanceId: string, items: { projectId: string }[]): Promise { + return this.restrictedIn(items.map((i) => ({ kind: 'install', provider: 'curseforge', projectId: i.projectId }))) + .map((id) => ({ projectId: id, name: `Restricted demo mod ${id}`, fileName: `${id}.jar`, sha1: 'a'.repeat(40), size: 1000, url: 'https://www.curseforge.com/minecraft/mc-mods' })); + } + /** Demo: nothing ever arrives in Downloads; choosing a file "finds" every download. */ + async claimManualDownloads(_instanceId: string, wanted: ManualDownload[], pick: boolean): Promise { + return pick ? wanted.map((w) => w.projectId) : []; + } + preparePlan(planId: string): Promise { return this.call(() => { const stored = this.plans.get(planId); diff --git a/src/components/ManualDownloads.vue b/src/components/ManualDownloads.vue new file mode 100644 index 0000000..921981f --- /dev/null +++ b/src/components/ManualDownloads.vue @@ -0,0 +1,98 @@ + + + + + diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 29279dd..4de4296 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -693,6 +693,14 @@ export const en = { exportOpenPage: "Open page", exportOpenNext: "Open next {count}", skipRestricted: "its author does not allow third-party distribution", + manualTitle: "Download from CurseForge yourself ({count})", + manualHint: "The author only allows downloads from the CurseForge website. Open the page and the download starts after a few seconds. The Manager watches your Downloads folder and adds the file to the pack by itself.", + manualOpen: "Open download page", + manualOpenAll: "Open all", + manualPick: "Choose downloaded file…", + manualWaiting: "Waiting for {file}", + manualAdded: "Added to the pack: {names}", + manualNoMatch: "None of the chosen files is one of these downloads.", shareWorking: "Connecting {name} so you can manage it here. Large packs can take a minute.", shareLoading: "Loading {name}'s mods…", shareReleasing: "Giving {name} back to Awake Launcher…", diff --git a/src/i18n/th.ts b/src/i18n/th.ts index 49703a4..6d38c3b 100644 --- a/src/i18n/th.ts +++ b/src/i18n/th.ts @@ -695,6 +695,14 @@ export const th: Catalog = { exportOpenPage: "เปิดหน้าม็อด", exportOpenNext: "เปิดอีก {count} หน้า", skipRestricted: "ผู้สร้างไม่อนุญาตให้แจกจ่ายผ่านบุคคลที่สาม", + manualTitle: "ต้องดาวน์โหลดจาก CurseForge เอง ({count})", + manualHint: "ผู้สร้างอนุญาตให้ดาวน์โหลดจากเว็บไซต์ CurseForge เท่านั้น เปิดหน้าเว็บแล้วการดาวน์โหลดจะเริ่มในไม่กี่วินาที Manager จะคอยดูโฟลเดอร์ Downloads และเพิ่มไฟล์เข้าแพ็กให้เอง", + manualOpen: "เปิดหน้าดาวน์โหลด", + manualOpenAll: "เปิดทั้งหมด", + manualPick: "เลือกไฟล์ที่ดาวน์โหลดแล้ว…", + manualWaiting: "กำลังรอ {file}", + manualAdded: "เพิ่มเข้าแพ็กแล้ว: {names}", + manualNoMatch: "ไฟล์ที่เลือกไม่ตรงกับไฟล์ที่ต้องดาวน์โหลด", shareWorking: "กำลังเชื่อมต่อ {name} เพื่อจัดการจากที่นี่ แพ็กขนาดใหญ่อาจใช้เวลาสักครู่", shareLoading: "กำลังโหลดม็อดของ {name}…", shareReleasing: "กำลังคืนสิทธิ์ {name} ให้ Awake Launcher…", diff --git a/src/i18n/zh-CN.ts b/src/i18n/zh-CN.ts index acd1c99..5b84bea 100644 --- a/src/i18n/zh-CN.ts +++ b/src/i18n/zh-CN.ts @@ -695,6 +695,14 @@ export const zhCN: Catalog = { exportOpenPage: "打开页面", exportOpenNext: "打开接下来 {count} 个", skipRestricted: "作者不允许第三方分发", + manualTitle: "需要自行从 CurseForge 下载({count})", + manualHint: "作者只允许从 CurseForge 网站下载。打开页面后,下载会在几秒后开始。Manager 会留意你的“下载”文件夹,并自动把文件加入整合包。", + manualOpen: "打开下载页面", + manualOpenAll: "全部打开", + manualPick: "选择已下载的文件…", + manualWaiting: "正在等待 {file}", + manualAdded: "已加入整合包:{names}", + manualNoMatch: "所选文件都不是这些下载项。", shareWorking: "正在连接 {name},以便在此管理。大型整合包可能需要一分钟左右。", shareLoading: "正在加载 {name} 的模组…", shareReleasing: "正在将 {name} 交还给 Awake Launcher…", diff --git a/src/i18n/zh-TW.ts b/src/i18n/zh-TW.ts index ae5e9e3..1fa7112 100644 --- a/src/i18n/zh-TW.ts +++ b/src/i18n/zh-TW.ts @@ -695,6 +695,14 @@ export const zhTW: Catalog = { exportOpenPage: "開啟頁面", exportOpenNext: "開啟接下來 {count} 個", skipRestricted: "作者不允許第三方散布", + manualTitle: "需要自行從 CurseForge 下載({count})", + manualHint: "作者只允許從 CurseForge 網站下載。開啟頁面後,下載會在幾秒後開始。Manager 會留意你的「下載」資料夾,並自動把檔案加入模組包。", + manualOpen: "開啟下載頁面", + manualOpenAll: "全部開啟", + manualPick: "選擇已下載的檔案…", + manualWaiting: "正在等待 {file}", + manualAdded: "已加入模組包:{names}", + manualNoMatch: "所選檔案都不是這些下載項目。", shareWorking: "正在連接 {name},以便在此管理。大型整合包可能需要一分鐘左右。", shareLoading: "正在載入 {name} 的模組…", shareReleasing: "正在將 {name} 交還給 Awake Launcher…", diff --git a/src/views/ReviewView.vue b/src/views/ReviewView.vue index 7381774..6da58e2 100644 --- a/src/views/ReviewView.vue +++ b/src/views/ReviewView.vue @@ -12,6 +12,7 @@ import { } from '@lucide/vue'; import Avatar from '../components/Avatar.vue'; import DependencyConflicts from '../components/DependencyConflicts.vue'; +import ManualDownloads from '../components/ManualDownloads.vue'; import { mergeResolutions } from '../domain/conflicts'; import type { DependencyResolution } from '../backend/contract'; import VirtualList from '../components/VirtualList.vue'; @@ -22,6 +23,8 @@ const session = useSession(); const { review, inventory } = session; const acknowledged = ref(false); const confirmDiscard = ref(false); +/** Restricted CurseForge files still waited for; their panel replaces the bare "not applied" error. */ +const manualPending = ref(0); const draft = computed(() => session.draft.value); const changes = computed(() => draft.value?.changes ?? []); @@ -228,7 +231,8 @@ function reasonText(i: PlanItem) {

{{ t('applyAccepted') }}

{{ t('applyLostReply') }}

-