diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 624f76f2..cf58d394 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1752,6 +1752,16 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "open" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2078c0039e6a54a0c42c28faa984e115fb4c2d5bf2208f77d1961002df8576f8" +dependencies = [ + "pathdiff", + "windows-sys 0.42.0", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -1812,6 +1822,12 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + [[package]] name = "percent-encoding" version = "2.3.1" @@ -2734,9 +2750,11 @@ dependencies = [ "ignore", "objc", "once_cell", + "open", "percent-encoding", "rand 0.8.5", "raw-window-handle", + "regex", "rfd", "semver", "serde", @@ -2792,6 +2810,7 @@ dependencies = [ "png", "proc-macro2", "quote", + "regex", "semver", "serde", "serde_json", @@ -3563,6 +3582,21 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ee5e275231f07c6e240d14f34e1b635bf1faa1c76c57cfd59a5cdb9848e4278" +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -3626,6 +3660,12 @@ dependencies = [ "windows-targets 0.52.4", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -3650,6 +3690,12 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -3674,6 +3720,12 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -3698,6 +3750,12 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -3722,6 +3780,12 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -3734,6 +3798,12 @@ version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -3758,6 +3828,12 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 0e9a9fcd..d3ebaa41 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "1.5.1", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.6.0", features = [ "dialog-confirm", "window-set-focus", "window-request-user-attention"] } +tauri = { version = "1.6.0", features = [ "shell-open", "dialog-confirm", "window-set-focus", "window-request-user-attention"] } ffmpeg-sidecar = "1.0.1" base64 = "0.22.0" tauri-plugin-deep-link = { git = "https://github.com/FabianLars/tauri-plugin-deep-link", branch = "main" } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 043d419f..8d538c24 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -3,7 +3,7 @@ "build": { "beforeBuildCommand": "npm run build", "beforeDevCommand": "npm run dev", - "devPath": "http://localhost:5173", + "devPath": "http://localhost:5173/jext-reborn/", "distDir": "../build" }, "package": { @@ -19,6 +19,9 @@ "dialog": { "confirm": true }, + "shell": { + "open": true + }, "all": false }, "bundle": { diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a98bea4a..b6ce93d4 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -28,6 +28,8 @@ import { computePosition, autoUpdate, offset, shift, flip, arrow } from '@floating-ui/dom'; import { onMount } from 'svelte'; import { UserAttentionType, appWindow } from '@tauri-apps/api/window'; + import { confirm } from '@tauri-apps/api/dialog'; + import { open } from '@tauri-apps/api/shell'; import { base } from '$app/paths'; storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow }); @@ -48,6 +50,31 @@ appWindow.requestUserAttention(UserAttentionType.Critical); appWindow.setFocus(); }); + + try { + (async () => { + const currentVersion = await fetch(`${base}/_app/version.json`).then((res) => res.json()); + const latestVersion = await fetch('https://spartacus04.github.io/jext-reborn/_app/version.json').then((res) => + res.json() + ); + + if (currentVersion.version !== latestVersion.version) { + const update = await confirm('A new version of the Jext Companion App is available. Do you want to update?'); + + if (update) { + const response = await fetch( + 'https://api.github.com/repos/spartacus04/jext-reborn/actions/workflows/build-tauri.yml/runs?status=success&per_page=1' + ); + + const json = await response.json(); + + if (json.total_count == 0) return; + + open(json.workflow_runs[0].html_url); + } + } + })(); + } catch(_) { } } onMount(async () => { diff --git a/svelte.config.js b/svelte.config.js index 447e147c..08a18a17 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -8,8 +8,9 @@ const config = { kit: { adapter: adapter(), paths: { - base: '/jext-reborn' + base: process.env.TAURI_PLATFORM == undefined ? '/jext-reborn' : '' } } }; + export default config;