From f093d2a310627aa3ee5a2820339f8a18bd251e81 Mon Sep 17 00:00:00 2001 From: "Begonia, HE" <163421589+BegoniaHe@users.noreply.github.com> Date: Wed, 14 Jan 2026 05:12:31 +0100 Subject: feat(java): integrate Adoptium API for Java runtime download Add automatic Java (Temurin) download and installation feature: - Add Adoptium API v3 integration to fetch latest Java releases - Support JRE and JDK image types with version selection (8/11/17/21) - Implement platform detection for macOS, Linux, and Windows - Add SHA256 checksum verification for downloaded archives - Add tar.gz extraction support with Unix permission preservation - Handle macOS-specific Java path structure (Contents/Home/bin) - Add frontend UI with version selector and download progress - Register Tauri commands: fetch_adoptium_java, download_adoptium_java, fetch_available_java_versions Dependencies added: sha2, flate2, tar, dirs --- ui/pnpm-lock.yaml | 130 ++++++++++++++++++++++++++++++++++++++---- ui/src/App.svelte | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 286 insertions(+), 12 deletions(-) (limited to 'ui') diff --git a/ui/pnpm-lock.yaml b/ui/pnpm-lock.yaml index d48c01e..0accf90 100644 --- a/ui/pnpm-lock.yaml +++ b/ui/pnpm-lock.yaml @@ -124,28 +124,24 @@ packages: engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - libc: [glibc] '@rolldown/binding-linux-arm64-musl@1.0.0-beta.50': resolution: {integrity: sha512-L0zRdH2oDPkmB+wvuTl+dJbXCsx62SkqcEqdM+79LOcB+PxbAxxjzHU14BuZIQdXcAVDzfpMfaHWzZuwhhBTcw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - libc: [musl] '@rolldown/binding-linux-x64-gnu@1.0.0-beta.50': resolution: {integrity: sha512-gyoI8o/TGpQd3OzkJnh1M2kxy1Bisg8qJ5Gci0sXm9yLFzEXIFdtc4EAzepxGvrT2ri99ar5rdsmNG0zP0SbIg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - libc: [glibc] '@rolldown/binding-linux-x64-musl@1.0.0-beta.50': resolution: {integrity: sha512-zti8A7M+xFDpKlghpcCAzyOi+e5nfUl3QhU023ce5NCgUxRG5zGP2GR9LTydQ1rnIPwZUVBWd4o7NjZDaQxaXA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - libc: [musl] '@rolldown/binding-openharmony-arm64@1.0.0-beta.50': resolution: {integrity: sha512-eZUssog7qljrrRU9Mi0eqYEPm3Ch0UwB+qlWPMKSUXHNqhm3TvDZarJQdTevGEfu3EHAXJvBIe0YFYr0TPVaMA==} @@ -237,28 +233,24 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] - libc: [glibc] '@tailwindcss/oxide-linux-arm64-musl@4.1.18': resolution: {integrity: sha512-1px92582HkPQlaaCkdRcio71p8bc8i/ap5807tPRDK/uw953cauQBT8c5tVGkOwrHMfc2Yh6UuxaH4vtTjGvHg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - libc: [musl] '@tailwindcss/oxide-linux-x64-gnu@4.1.18': resolution: {integrity: sha512-v3gyT0ivkfBLoZGF9LyHmts0Isc8jHZyVcbzio6Wpzifg/+5ZJpDiRiUhDLkcr7f/r38SWNe7ucxmGW3j3Kb/g==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - libc: [glibc] '@tailwindcss/oxide-linux-x64-musl@4.1.18': resolution: {integrity: sha512-bhJ2y2OQNlcRwwgOAGMY0xTFStt4/wyU6pvI6LSuZpRgKQwxTec0/3Scu91O8ir7qCR3AuepQKLU/kX99FouqQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - libc: [musl] '@tailwindcss/oxide-wasm32-wasi@4.1.18': resolution: {integrity: sha512-LffYTvPjODiP6PT16oNeUQJzNVyJl1cjIebq/rWWBF+3eDst5JGEFSc5cWxyRCJ0Mxl+KyIkqRxk1XPEs9x8TA==} @@ -296,6 +288,77 @@ packages: '@tauri-apps/api@2.9.1': resolution: {integrity: sha512-IGlhP6EivjXHepbBic618GOmiWe4URJiIeZFlB7x3czM0yDHHYviH1Xvoiv4FefdkQtn6v7TuwWCRfOGdnVUGw==} + '@tauri-apps/cli-darwin-arm64@2.9.6': + resolution: {integrity: sha512-gf5no6N9FCk1qMrti4lfwP77JHP5haASZgVbBgpZG7BUepB3fhiLCXGUK8LvuOjP36HivXewjg72LTnPDScnQQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + + '@tauri-apps/cli-darwin-x64@2.9.6': + resolution: {integrity: sha512-oWh74WmqbERwwrwcueJyY6HYhgCksUc6NT7WKeXyrlY/FPmNgdyQAgcLuTSkhRFuQ6zh4Np1HZpOqCTpeZBDcw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + + '@tauri-apps/cli-linux-arm-gnueabihf@2.9.6': + resolution: {integrity: sha512-/zde3bFroFsNXOHN204DC2qUxAcAanUjVXXSdEGmhwMUZeAQalNj5cz2Qli2elsRjKN/hVbZOJj0gQ5zaYUjSg==} + engines: {node: '>= 10'} + cpu: [arm] + os: [linux] + + '@tauri-apps/cli-linux-arm64-gnu@2.9.6': + resolution: {integrity: sha512-pvbljdhp9VOo4RnID5ywSxgBs7qiylTPlK56cTk7InR3kYSTJKYMqv/4Q/4rGo/mG8cVppesKIeBMH42fw6wjg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + + '@tauri-apps/cli-linux-arm64-musl@2.9.6': + resolution: {integrity: sha512-02TKUndpodXBCR0oP//6dZWGYcc22Upf2eP27NvC6z0DIqvkBBFziQUcvi2n6SrwTRL0yGgQjkm9K5NIn8s6jw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + + '@tauri-apps/cli-linux-riscv64-gnu@2.9.6': + resolution: {integrity: sha512-fmp1hnulbqzl1GkXl4aTX9fV+ubHw2LqlLH1PE3BxZ11EQk+l/TmiEongjnxF0ie4kV8DQfDNJ1KGiIdWe1GvQ==} + engines: {node: '>= 10'} + cpu: [riscv64] + os: [linux] + + '@tauri-apps/cli-linux-x64-gnu@2.9.6': + resolution: {integrity: sha512-vY0le8ad2KaV1PJr+jCd8fUF9VOjwwQP/uBuTJvhvKTloEwxYA/kAjKK9OpIslGA9m/zcnSo74czI6bBrm2sYA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + + '@tauri-apps/cli-linux-x64-musl@2.9.6': + resolution: {integrity: sha512-TOEuB8YCFZTWVDzsO2yW0+zGcoMiPPwcUgdnW1ODnmgfwccpnihDRoks+ABT1e3fHb1ol8QQWsHSCovb3o2ENQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + + '@tauri-apps/cli-win32-arm64-msvc@2.9.6': + resolution: {integrity: sha512-ujmDGMRc4qRLAnj8nNG26Rlz9klJ0I0jmZs2BPpmNNf0gM/rcVHhqbEkAaHPTBVIrtUdf7bGvQAD2pyIiUrBHQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + + '@tauri-apps/cli-win32-ia32-msvc@2.9.6': + resolution: {integrity: sha512-S4pT0yAJgFX8QRCyKA1iKjZ9Q/oPjCZf66A/VlG5Yw54Nnr88J1uBpmenINbXxzyhduWrIXBaUbEY1K80ZbpMg==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + + '@tauri-apps/cli-win32-x64-msvc@2.9.6': + resolution: {integrity: sha512-ldWuWSSkWbKOPjQMJoYVj9wLHcOniv7diyI5UAJ4XsBdtaFB0pKHQsqw/ItUma0VXGC7vB4E9fZjivmxur60aw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + + '@tauri-apps/cli@2.9.6': + resolution: {integrity: sha512-3xDdXL5omQ3sPfBfdC8fCtDKcnyV7OqyzQgfyT5P3+zY6lcPqIYKQBvUasNvppi21RSdfhy44ttvJmftb0PCDw==} + engines: {node: '>= 10'} + hasBin: true + '@tauri-apps/plugin-shell@2.3.4': resolution: {integrity: sha512-ktsRWf8wHLD17aZEyqE8c5x98eNAuTizR1FSX475zQ4TxaiJnhwksLygQz+AGwckJL5bfEP13nWrlTNQJUpKpA==} @@ -441,28 +504,24 @@ packages: engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] - libc: [glibc] lightningcss-linux-arm64-musl@1.30.2: resolution: {integrity: sha512-5Vh9dGeblpTxWHpOx8iauV02popZDsCYMPIgiuw97OJ5uaDsL86cnqSFs5LZkG3ghHoX5isLgWzMs+eD1YzrnA==} engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] - libc: [musl] lightningcss-linux-x64-gnu@1.30.2: resolution: {integrity: sha512-Cfd46gdmj1vQ+lR6VRTTadNHu6ALuw2pKR9lYq4FnhvgBc4zWY1EtZcAc6EffShbb1MFrIPfLDXD6Xprbnni4w==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] - libc: [glibc] lightningcss-linux-x64-musl@1.30.2: resolution: {integrity: sha512-XJaLUUFXb6/QG2lGIW6aIk6jKdtjtcffUT0NKvIqhSBY3hh9Ch+1LCeH80dR9q9LBjG3ewbDjnumefsLsP6aiA==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] - libc: [musl] lightningcss-win32-arm64-msvc@1.30.2: resolution: {integrity: sha512-FZn+vaj7zLv//D/192WFFVA0RgHawIcHqLX9xuWiQt7P0PtdFEVaxgF9rjM/IRYHQXNnk61/H/gb2Ei+kUQ4xQ==} @@ -808,6 +867,53 @@ snapshots: '@tauri-apps/api@2.9.1': {} + '@tauri-apps/cli-darwin-arm64@2.9.6': + optional: true + + '@tauri-apps/cli-darwin-x64@2.9.6': + optional: true + + '@tauri-apps/cli-linux-arm-gnueabihf@2.9.6': + optional: true + + '@tauri-apps/cli-linux-arm64-gnu@2.9.6': + optional: true + + '@tauri-apps/cli-linux-arm64-musl@2.9.6': + optional: true + + '@tauri-apps/cli-linux-riscv64-gnu@2.9.6': + optional: true + + '@tauri-apps/cli-linux-x64-gnu@2.9.6': + optional: true + + '@tauri-apps/cli-linux-x64-musl@2.9.6': + optional: true + + '@tauri-apps/cli-win32-arm64-msvc@2.9.6': + optional: true + + '@tauri-apps/cli-win32-ia32-msvc@2.9.6': + optional: true + + '@tauri-apps/cli-win32-x64-msvc@2.9.6': + optional: true + + '@tauri-apps/cli@2.9.6': + optionalDependencies: + '@tauri-apps/cli-darwin-arm64': 2.9.6 + '@tauri-apps/cli-darwin-x64': 2.9.6 + '@tauri-apps/cli-linux-arm-gnueabihf': 2.9.6 + '@tauri-apps/cli-linux-arm64-gnu': 2.9.6 + '@tauri-apps/cli-linux-arm64-musl': 2.9.6 + '@tauri-apps/cli-linux-riscv64-gnu': 2.9.6 + '@tauri-apps/cli-linux-x64-gnu': 2.9.6 + '@tauri-apps/cli-linux-x64-musl': 2.9.6 + '@tauri-apps/cli-win32-arm64-msvc': 2.9.6 + '@tauri-apps/cli-win32-ia32-msvc': 2.9.6 + '@tauri-apps/cli-win32-x64-msvc': 2.9.6 + '@tauri-apps/plugin-shell@2.3.4': dependencies: '@tauri-apps/api': 2.9.1 diff --git a/ui/src/App.svelte b/ui/src/App.svelte index 9b7fe93..02cc173 100644 --- a/ui/src/App.svelte +++ b/ui/src/App.svelte @@ -57,6 +57,16 @@ is_64bit: boolean; } + interface JavaDownloadInfo { + version: string; + release_name: string; + download_url: string; + file_name: string; + file_size: number; + checksum: string | null; + image_type: string; + } + let versions: Version[] = []; let selectedVersion = ""; let currentAccount: Account | null = null; @@ -70,6 +80,13 @@ let javaInstallations: JavaInstallation[] = []; let isDetectingJava = false; + let availableJavaVersions: number[] = []; + let selectedJavaVersion = 21; + let selectedImageType: "jre" | "jdk" = "jre"; + let isDownloadingJava = false; + let javaDownloadStatus = ""; + let showJavaDownloadModal = false; + // Login UI State let isLoginModalOpen = false; let loginMode: "select" | "offline" | "microsoft" = "select"; @@ -144,6 +161,59 @@ settings.java_path = path; } + async function openJavaDownloadModal() { + showJavaDownloadModal = true; + javaDownloadStatus = ""; + try { + availableJavaVersions = await invoke("fetch_available_java_versions"); + // Default selection logic + if (availableJavaVersions.includes(21)) { + selectedJavaVersion = 21; + } else if (availableJavaVersions.includes(17)) { + selectedJavaVersion = 17; + } else if (availableJavaVersions.length > 0) { + selectedJavaVersion = availableJavaVersions[availableJavaVersions.length - 1]; + } + } catch (e) { + console.error("Failed to fetch available Java versions:", e); + javaDownloadStatus = "Error fetching Java versions: " + e; + } + } + + function closeJavaDownloadModal() { + if (!isDownloadingJava) { + showJavaDownloadModal = false; + } + } + + async function downloadJava() { + isDownloadingJava = true; + javaDownloadStatus = `Downloading Java ${selectedJavaVersion} ${selectedImageType.toUpperCase()}...`; + + try { + const result: JavaInstallation = await invoke("download_adoptium_java", { + majorVersion: selectedJavaVersion, + imageType: selectedImageType, + customPath: null, + }); + + javaDownloadStatus = `Java ${selectedJavaVersion} installed at ${result.path}`; + settings.java_path = result.path; + + await detectJava(); + + setTimeout(() => { + showJavaDownloadModal = false; + status = `Java ${selectedJavaVersion} is ready to use!`; + }, 1500); + } catch (e) { + console.error("Failed to download Java:", e); + javaDownloadStatus = "Download failed: " + e; + } finally { + isDownloadingJava = false; + } + } + // --- Auth Functions --- function openLoginModal() { @@ -460,6 +530,12 @@ > {isDetectingJava ? "Detecting..." : "Auto Detect"} + {#if javaInstallations.length > 0} @@ -782,6 +858,98 @@ {/if} + {#if showJavaDownloadModal} +
+
e.stopPropagation()} + > +
+

Download Java (Adoptium)

+ {#if !isDownloadingJava} + + {/if} +
+
+ +
+ + +

+ MC 1.20.5+ requires Java 21, MC 1.17-1.20.4 requires Java 17, older versions require Java 8 +

+
+ + +
+ +
+ + +
+
+ + + {#if javaDownloadStatus} +
+

{javaDownloadStatus}

+
+ {/if} + + + + +

+ Provided by { e.preventDefault(); openLink("https://adoptium.net"); }}>Eclipse Adoptium +

+
+
+
+ {/if} +