Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.0:** see [docs/releases/v1.3.0.md](docs/releases/v1.3.0.md).
> **What's new in 1.3.1:** see [docs/releases/v1.3.1.md](docs/releases/v1.3.1.md).

**Version 1.3.0 · Windows x64 · English, ไทย, 简体中文, 繁體中文 · GPL-3.0-only**
**Version 1.3.1 · Windows x64 · English, ไทย, 简体中文, 繁體中文 · GPL-3.0-only**

## Install

1. Download `Awake-Modpack-Manager-v1.3.0-Windows-x64-Setup.exe` from the
1. Download `Awake-Modpack-Manager-v1.3.1-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.0-Windows-x64-Setup.exe`).
(`Get-FileHash .\Awake-Modpack-Manager-v1.3.1-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
Expand Down
8 changes: 4 additions & 4 deletions docs/HANDOFF.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Development checkpoint: Manager 1.3.0 and Native Core 0.4.2
# Development checkpoint: Manager 1.3.1 and Native Core 0.4.2

Unreleased until the owner approves the pull request and tags `v1.3.0`.
Unreleased until the owner approves the pull request and tags `v1.3.1`.

## Where things are

- Manager: branch `release/1.3.0`. `npm ci`, then `npm test`, `npm run typecheck`, `cargo test --manifest-path src-tauri/Cargo.toml --lib`.
- Manager: branch `release/1.3.1`. `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/<commit12>/`. `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.

## Architecture added in 0.3.0

- `src-tauri/src/providers.rs`: five modpack catalogs, pack downloads, batched project metadata and update lookups. The CurseForge key stays in the host and the helper's environment.
- `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, add files, Recycle Bin), shell open. Mods are never touched here.
- `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`.
- `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.
Expand Down
22 changes: 22 additions & 0 deletions docs/releases/v1.3.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Awake Modpack Manager 1.3.1

Works with **Awake Launcher 3.2.2**. No Launcher update is needed.

## Added

- **View images on the Files page.** Clicking a picture (`.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.bmp`, `.ico`) now opens it inside the Manager, the same way a text file opens in the editor, instead of answering "This is not a text file". The viewer shows the picture's size in pixels and on disk, fits large pictures to the window, enlarges small textures with sharp pixels, and draws transparent areas over a checkerboard. Pictures are listed with their own icon, and the right-click menu says "View" for them.

## How it behaves

- Pictures are only shown, never changed: there is nothing to save, so going back to the folder never asks.
- A file is shown only if its first bytes are those of a picture format the viewer knows, whatever its name ends in. Anything else is refused with a message.
- Pictures over 16 MB are left to other programs. A picture that is damaged says so instead of showing an empty frame.
- `.svg` files are text and still open in the editor.

## Safety

- The viewer reads through the same path checks as the editor: inside the six content folders only, and never through a link or junction.

## Not verified on a real machine yet

The demo data and the automated tests cover the viewer, and the host's reading and format check have their own tests. Still unverified: the viewer in the desktop app against a real instance.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "awake-modpack-manager",
"private": true,
"version": "1.3.0",
"version": "1.3.1",
"license": "GPL-3.0-only",
"type": "module",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "awake-modpack-manager"
version = "1.3.0"
version = "1.3.1"
description = "Awake Modpack Manager desktop host"
license = "GPL-3.0-only"
repository = "https://github.com/awakenginexe/Awake-Modpack-Manager"
Expand Down
80 changes: 80 additions & 0 deletions src-tauri/src/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const AREAS: [&str; 6] = ["config", "defaultconfigs", "kubejs", "scripts", "reso
const LIST_MAX: usize = 20_000;
/// The largest text file the built-in editor opens or saves.
const TEXT_MAX: u64 = 2 << 20;
/// The largest picture the built-in viewer shows.
const IMAGE_MAX: u64 = 16 << 20;

pub fn is_uuid(id: &str) -> bool {
id.len() == 36 && id.bytes().enumerate().all(|(i, b)| if [8, 13, 18, 23].contains(&i) { b == b'-' } else { b.is_ascii_hexdigit() })
Expand Down Expand Up @@ -163,6 +165,57 @@ pub async fn workspace_write_text(workspace: String, area: String, path: String,
.unwrap_or_else(|e| err("internal", e.to_string()))
}

#[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ImageFile {
/// `data:image/...;base64,...`, the only form the page's content policy lets an `<img>` load from disk.
data_url: String,
size_bytes: u64,
}

/// The picture formats the web view draws, told by their first bytes and never by the file name.
pub fn image_mime(bytes: &[u8]) -> Option<&'static str> {
match bytes {
[0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a, ..] => Some("image/png"),
[0xff, 0xd8, 0xff, ..] => Some("image/jpeg"),
[b'G', b'I', b'F', b'8', b'7' | b'9', b'a', ..] => Some("image/gif"),
[b'R', b'I', b'F', b'F', _, _, _, _, b'W', b'E', b'B', b'P', ..] => Some("image/webp"),
[b'B', b'M', ..] => Some("image/bmp"),
[0, 0, 1, 0, ..] => Some("image/x-icon"),
_ => None,
}
}

fn base64(bytes: &[u8]) -> String {
const ALPHABET: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
let mut out = String::with_capacity(bytes.len().div_ceil(3) * 4);
for chunk in bytes.chunks(3) {
let n = u32::from(chunk[0]) << 16 | u32::from(*chunk.get(1).unwrap_or(&0)) << 8 | u32::from(*chunk.get(2).unwrap_or(&0));
for i in 0..4 {
out.push(if i <= chunk.len() { ALPHABET[(n >> (18 - 6 * i) & 63) as usize] as char } else { '=' });
}
}
out
}

/// A picture for the built-in viewer. Only read, never changed; anything that is not one is refused.
pub fn read_image(path: &Path) -> HostResult<ImageFile> {
let meta = regular_file(path)?;
if meta.len() > IMAGE_MAX {
return err("too-large", "This image is too large to show here (16 MB at most). Open its folder to see it in another program.");
}
let bytes = fs::read(path).or_else(|e| err("io", e.to_string()))?;
let Some(mime) = image_mime(&bytes) else { return err("not-image", "This is not an image the Manager can show.") };
Ok(ImageFile { data_url: format!("data:{mime};base64,{}", base64(&bytes)), size_bytes: bytes.len() as u64 })
}

#[tauri::command]
pub async fn workspace_read_image(workspace: String, area: String, path: String) -> HostResult<ImageFile> {
tauri::async_runtime::spawn_blocking(move || read_image(&checked_path(&game_dir(&workspace)?, &area, &path)?))
.await
.unwrap_or_else(|e| err("internal", e.to_string()))
}

#[derive(Serialize, Debug, Default, PartialEq)]
pub struct AddedFiles {
added: Vec<String>,
Expand Down Expand Up @@ -433,6 +486,33 @@ mod tests {
fs::remove_dir_all(&game).unwrap();
}

#[test]
fn the_viewer_shows_pictures_and_refuses_everything_else() {
let game = scratch("image");
let config = game.join("config");
fs::create_dir_all(config.join("sub")).unwrap();
let png = [0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a, 1, 2];
fs::write(config.join("icon.png"), png).unwrap();
let shown = read_image(&config.join("icon.png")).unwrap();
assert_eq!(shown.data_url, "data:image/png;base64,iVBORw0KGgoBAg==");
assert_eq!(shown.size_bytes, 10);
// The first bytes decide, not the name: a script renamed to .png is not handed to the page as a picture.
fs::write(config.join("fake.png"), "<svg onload=alert(1)>").unwrap();
assert_eq!(read_image(&config.join("fake.png")).unwrap_err().code, "not-image");
fs::write(config.join("empty.png"), "").unwrap();
assert_eq!(read_image(&config.join("empty.png")).unwrap_err().code, "not-image");
fs::write(config.join("big.png"), vec![0u8; IMAGE_MAX as usize + 1]).unwrap();
assert_eq!(read_image(&config.join("big.png")).unwrap_err().code, "too-large");
assert_eq!(read_image(&config.join("sub")).unwrap_err().code, "invalid");
assert_eq!(read_image(&config.join("gone.png")).unwrap_err().code, "not-found");
assert_eq!(image_mime(&[0xff, 0xd8, 0xff, 0xe0]), Some("image/jpeg"));
assert_eq!(image_mime(b"GIF89a.."), Some("image/gif"));
assert_eq!(image_mime(b"RIFF\x10\0\0\0WEBPVP8 "), Some("image/webp"));
assert_eq!(image_mime(b"RIFF\x10\0\0\0WAVEfmt "), None);
assert_eq!((base64(b""), base64(b"f"), base64(b"fo"), base64(b"foo"), base64(b"foob")), ("".into(), "Zg==".into(), "Zm8=".into(), "Zm9v".into(), "Zm9vYg==".into()));
fs::remove_dir_all(&game).unwrap();
}

#[test]
fn adding_files_never_overwrites() {
let root = scratch("add");
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub fn run() {
desktop::workspace_list,
desktop::workspace_recycle,
desktop::workspace_read_text,
desktop::workspace_read_image,
desktop::workspace_write_text,
desktop::workspace_add_files,
content::content_search,
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "Awake Modpack Manager",
"version": "1.3.0",
"version": "1.3.1",
"identifier": "io.github.awakenginexe.AwakeModpackManager",
"build": {
"frontendDist": "../dist",
Expand Down
4 changes: 3 additions & 1 deletion src/backend/ManagerBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,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,
AddedContent, ContentKind, ContentSearchPage, ContentSearchQuery, ContentTextFile, ContentVersion, InstalledContent, ProviderInfo } from './contract';
AddedContent, ContentImage, ContentKind, ContentSearchPage, ContentSearchQuery, ContentTextFile, ContentVersion, InstalledContent, ProviderInfo } from './contract';
import type { LauncherProfile } from './launcher/transport';
import type { ProjectDetail } from './host';

Expand Down Expand Up @@ -66,6 +66,8 @@ export interface ManagerBackend {
/** What is directly inside a content folder (`folder` is relative to the area; its top when absent). */
listContent(instanceId: string, area: ContentArea, folder?: string): Promise<ContentEntry[]>;
readContentText?(instanceId: string, area: ContentArea, path: string): Promise<ContentTextFile>;
/** A picture for the built-in viewer. Rejects for anything that is not one. */
readContentImage?(instanceId: string, area: ContentArea, path: string): Promise<ContentImage>;
/** Save over the file that was read. Rejects if it changed on disk since. Resolves to its new `modifiedMs`. */
writeContentText?(instanceId: string, area: ContentArea, path: string, text: string, expectedModifiedMs: number): Promise<number>;
/** Let the user pick files to copy into a content folder. Null when they cancel; nothing is overwritten. */
Expand Down
1 change: 1 addition & 0 deletions src/backend/composite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export function createCompositeBackend(helper: ManagerBackend, launcher: Manager
recycleContent: async (id, area, paths) => { await byInstance(id).backend.recycleContent?.(id, area, paths); },
openFolder: async (id, area, folder) => { await byInstance(id).backend.openFolder?.(id, area, folder); },
readContentText: (id, area, path) => { const b = byInstance(id).backend; return b.readContentText ? b.readContentText(id, area, path) : noHelper(); },
readContentImage: (id, area, path) => { const b = byInstance(id).backend; return b.readContentImage ? b.readContentImage(id, area, path) : noHelper(); },
writeContentText: (id, area, path, text, expected) => { const b = byInstance(id).backend; return b.writeContentText ? b.writeContentText(id, area, path, text, expected) : noHelper(); },
addContentFiles: (id, area, folder) => { const b = byInstance(id).backend; return b.addContentFiles ? b.addContentFiles(id, area, folder) : noHelper(); },
// Resource packs and shaders are found by the Manager's own side, whichever list is on screen.
Expand Down
2 changes: 2 additions & 0 deletions src/backend/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ export interface ContentEntry {

/** A file opened in the editor. `modifiedMs` goes back with the save, so a newer file on disk is never overwritten. */
export interface ContentTextFile { text: string; modifiedMs: number }
/** A picture to show: `dataUrl` is `data:image/...;base64,...`, checked by the side that read the file. */
export interface ContentImage { dataUrl: string; sizeBytes: number }
export interface AddedContent { added: string[]; skipped: string[] }

/* ---------- Resource packs & shaders (installed straight into their folder, never through a plan) ---------- */
Expand Down
4 changes: 4 additions & 0 deletions src/backend/helper/HelperClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,10 @@ export function createHelperClient(options: HelperClientOptions): ManagerBackend
if (!options.host) return notYet('editing files');
return options.host.workspaceReadText(workspaceOf(instanceId).workspaceId, area, path);
},
async readContentImage(instanceId, area, path) {
if (!options.host) return notYet('viewing images');
return options.host.workspaceReadImage(workspaceOf(instanceId).workspaceId, area, path);
},
async writeContentText(instanceId, area, path, text, expectedModifiedMs) {
if (!options.host) return notYet('editing files');
return options.host.workspaceWriteText(workspaceOf(instanceId).workspaceId, area, path, text, expectedModifiedMs);
Expand Down
4 changes: 3 additions & 1 deletion src/backend/host.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BackendError, type AddedContent, type ContentEntry, 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 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[] }
Expand Down Expand Up @@ -26,6 +26,7 @@ export interface HostApi {
workspaceRecycle(workspace: string, area: string, paths: string[]): Promise<void>;
workspaceOpen(workspace: string, area?: string, folder?: string): Promise<void>;
workspaceReadText(workspace: string, area: string, path: string): Promise<ContentTextFile>;
workspaceReadImage(workspace: string, area: string, path: string): Promise<ContentImage>;
workspaceWriteText(workspace: string, area: string, path: string, text: string, expectedModifiedMs: number): Promise<number>;
workspaceAddFiles(workspace: string, area: string, folder: string): Promise<AddedContent | null>;
contentSearch(query: ContentSearchQuery): Promise<ContentSearchPage>;
Expand Down Expand Up @@ -70,6 +71,7 @@ export function createHostApi(): HostApi {
modUpdates: (items, minecraftVersion, loader) => hostInvoke('mod_updates', { items, minecraftVersion, loader }),
workspaceList: (workspace, area, folder) => hostInvoke('workspace_list', { workspace, area, folder: folder || null }),
workspaceReadText: (workspace, area, path) => hostInvoke('workspace_read_text', { workspace, area, path }),
workspaceReadImage: (workspace, area, path) => hostInvoke('workspace_read_image', { workspace, area, path }),
workspaceWriteText: (workspace, area, path, text, expectedModifiedMs) => hostInvoke('workspace_write_text', { workspace, area, path, text, expectedModifiedMs }),
workspaceAddFiles: (workspace, area, folder) => hostInvoke('workspace_add_files', { workspace, area, folder }),
contentSearch: ({ provider, kind, text, minecraftVersion, offset, limit }) => hostInvoke('content_search', { provider, kind, text, minecraftVersion, offset, limit }),
Expand Down
Loading
Loading