diff options
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/pnpm-lock.yaml | 130 | ||||
| -rw-r--r-- | ui/src/App.svelte | 168 |
2 files changed, 286 insertions, 12 deletions
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"} </button> + <button + onclick={openJavaDownloadModal} + class="bg-indigo-600 hover:bg-indigo-500 text-white px-4 py-2 rounded transition-colors whitespace-nowrap" + > + Download Java + </button> </div> {#if javaInstallations.length > 0} @@ -782,6 +858,98 @@ </div> {/if} + {#if showJavaDownloadModal} + <div + class="fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm" + onclick={closeJavaDownloadModal} + > + <div + class="bg-zinc-900 border border-zinc-700 rounded-xl p-6 w-full max-w-md shadow-2xl" + onclick={(e) => e.stopPropagation()} + > + <div class="flex justify-between items-center mb-6"> + <h3 class="text-xl font-bold">Download Java (Adoptium)</h3> + {#if !isDownloadingJava} + <button + onclick={closeJavaDownloadModal} + class="text-zinc-500 hover:text-white transition text-xl" + > + ✕ + </button> + {/if} + </div> + <div class="space-y-4"> + <!-- Version Selection --> + <div> + <label class="block text-sm font-bold text-zinc-400 mb-2">Java Version</label> + <select + bind:value={selectedJavaVersion} + disabled={isDownloadingJava} + class="w-full bg-zinc-950 border border-zinc-700 rounded p-3 text-white focus:border-indigo-500 outline-none disabled:opacity-50" + > + {#each availableJavaVersions as ver} + <option value={ver}> + Java {ver} {ver === 21 ? "(Recommended)" : ver === 17 ? "(LTS)" : ver === 8 ? "(Legacy)" : ""} + </option> + {/each} + </select> + <p class="text-xs text-zinc-500 mt-1"> + MC 1.20.5+ requires Java 21, MC 1.17-1.20.4 requires Java 17, older versions require Java 8 + </p> + </div> + + <!-- Image Type Selection --> + <div> + <label class="block text-sm font-bold text-zinc-400 mb-2">Type</label> + <div class="flex gap-3"> + <button + onclick={() => selectedImageType = "jre"} + disabled={isDownloadingJava} + class="flex-1 p-3 rounded border transition-colors disabled:opacity-50 {selectedImageType === 'jre' ? 'border-indigo-500 bg-indigo-950/30 text-white' : 'border-zinc-700 bg-zinc-950 text-zinc-400 hover:border-zinc-500'}" + > + <div class="font-bold">JRE</div> + <div class="text-xs opacity-70">runtime environment</div> + </button> + <button + onclick={() => selectedImageType = "jdk"} + disabled={isDownloadingJava} + class="flex-1 p-3 rounded border transition-colors disabled:opacity-50 {selectedImageType === 'jdk' ? 'border-indigo-500 bg-indigo-950/30 text-white' : 'border-zinc-700 bg-zinc-950 text-zinc-400 hover:border-zinc-500'}" + > + <div class="font-bold">JDK</div> + <div class="text-xs opacity-70">development kit</div> + </button> + </div> + </div> + + <!-- Status --> + {#if javaDownloadStatus} + <div class="p-3 rounded {javaDownloadStatus.startsWith('✓') ? 'bg-green-950/50 border border-green-700 text-green-400' : javaDownloadStatus.includes('failed') || javaDownloadStatus.includes('Failed') ? 'bg-red-950/50 border border-red-700 text-red-400' : 'bg-zinc-800 border border-zinc-700 text-zinc-300'}"> + <p class="text-sm">{javaDownloadStatus}</p> + </div> + {/if} + + <!-- Download Button --> + <button + onclick={downloadJava} + disabled={isDownloadingJava || availableJavaVersions.length === 0} + class="w-full bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed text-white p-3 rounded font-bold transition-colors flex items-center justify-center gap-2" + > + {#if isDownloadingJava} + <div class="animate-spin rounded-full h-5 w-5 border-2 border-white/30 border-t-white"></div> + Downloading... + {:else} + Download Java {selectedJavaVersion} {selectedImageType.toUpperCase()} + {/if} + </button> + + <p class="text-xs text-zinc-500 text-center"> + Provided by <a href="https://adoptium.net" class="text-indigo-400 hover:underline" onclick={(e) => { e.preventDefault(); openLink("https://adoptium.net"); }}>Eclipse Adoptium</a> + </p> + </div> + </div> + </div> + {/if} + <style> @keyframes progress { from { |