From 79d280c923cb635c7d043b782880918de93a3ac8 Mon Sep 17 00:00:00 2001 From: vishwas0developers Date: Sun, 7 Jun 2026 16:46:24 +0530 Subject: [PATCH 1/7] Fix detection for newer ADB devices and improve Windows build scripts --- build.bat | 95 +++++++++++++++++++++++++++++++++++++ build.ps1 | 115 +++++++++++++++++++++++++++++++++++++++++++++ build_Portable.bat | 15 ++++++ flake.nix | 14 +++--- package-lock.json | 4 +- package.json | 2 +- start.bat | 6 +++ 7 files changed, 241 insertions(+), 10 deletions(-) create mode 100644 build.bat create mode 100644 build.ps1 create mode 100644 build_Portable.bat create mode 100644 start.bat diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..c59cc5c --- /dev/null +++ b/build.bat @@ -0,0 +1,95 @@ +@echo off +setlocal EnableDelayedExpansion +cd /d "%~dp0" + +REM ───────────────────────────────────────────────────────────────────────────── +REM ScrcpyGUI — Windows build script +REM Requires: Node.js, npm, Rust (rustup), Tauri CLI (installed via npm) +REM Usage: double-click this file, or run it from any terminal. +REM ───────────────────────────────────────────────────────────────────────────── + +REM ── 1. Inject Cargo into PATH for this session ─────────────────────────────── +set "CARGO_BIN=%USERPROFILE%\.cargo\bin" +if exist "%CARGO_BIN%\cargo.exe" ( + set "PATH=%CARGO_BIN%;%PATH%" +) else ( + echo. + echo ERROR: Rust ^(cargo.exe^) was not found. + echo Expected location: %CARGO_BIN% + echo Install Rust from: https://rustup.rs + echo After installing, re-run this script. + echo. + pause + exit /b 1 +) + +REM ── 2. Verify required tools are reachable ─────────────────────────────────── +echo Checking prerequisites... +for %%T in (node npm cargo) do ( + where %%T >nul 2>&1 + if !ERRORLEVEL! neq 0 ( + echo [FAIL] %%T not found in PATH. + echo Install %%T and restart your terminal, then re-run this script. + pause + exit /b 1 + ) + echo [OK] %%T +) + +REM ── 3. Install npm dependencies ────────────────────────────────────────────── +echo. +echo npm install... +call npm install +if !ERRORLEVEL! neq 0 ( + echo. + echo ERROR: npm install failed ^(exit code !ERRORLEVEL!^). + pause + exit /b !ERRORLEVEL! +) + +REM ── 4. Build with Tauri ─────────────────────────────────────────────────────── +REM NOTE: Tauri's beforeBuildCommand in tauri.conf.json already runs +REM "npm run build" ^(tsc + Vite^) internally — no need to call it separately. +REM NOTE: First Rust compilation can take 5-15 minutes. +echo. +echo npm run tauri build... +echo ^(First Rust compilation may take 5-15 minutes — please wait.^) +echo. +call npm run tauri build +if !ERRORLEVEL! neq 0 ( + echo. + echo ERROR: Tauri build failed ^(exit code !ERRORLEVEL!^). + echo Scroll up to read the Rust/Tauri compiler error. + pause + exit /b !ERRORLEVEL! +) + +REM ── 5. Locate installer artifacts ──────────────────────────────────────────── +set "NSIS_DIR=src-tauri\target\release\bundle\nsis" +set "MSI_DIR=src-tauri\target\release\bundle\msi" +set "FOUND=0" +echo. +echo Build succeeded. Checking for installer artifacts... + +if exist "%NSIS_DIR%\*.exe" ( + echo. + echo [NSIS installer] + for %%F in ("%NSIS_DIR%\*.exe") do echo %%~nxF --^> %NSIS_DIR%\%%~nxF + set "FOUND=1" +) +if exist "%MSI_DIR%\*.msi" ( + echo. + echo [MSI installer] + for %%F in ("%MSI_DIR%\*.msi") do echo %%~nxF --^> %MSI_DIR%\%%~nxF + set "FOUND=1" +) +if "!FOUND!"=="0" ( + echo No installer bundle found. Tauri may require NSIS or WiX Toolset. + echo - NSIS ^(free^): https://nsis.sourceforge.io/Download + echo - WiX Toolset ^(free^): https://wixtoolset.org/ + echo. + echo Raw portable binary: src-tauri\target\release\scrcpy-gui-v4.exe +) + +echo. +pause diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..a7eb71d --- /dev/null +++ b/build.ps1 @@ -0,0 +1,115 @@ +#Requires -Version 5.1 +<# +.SYNOPSIS + Builds ScrcpyGUI via Tauri and produces a Windows installer bundle. +.DESCRIPTION + - Ensures Rust/Cargo is on PATH (rustup default location). + - Validates node, npm, and cargo before starting. + - Runs: npm install → npm run tauri build + (Tauri's beforeBuildCommand in tauri.conf.json runs the Vite frontend build automatically.) + - Saves full output to build.log in the project root. + - Pauses with a clear message on any failure. +#> + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +# ── Paths ───────────────────────────────────────────────────────────────────── +$Root = $PSScriptRoot +$LogFile = Join-Path $Root 'build.log' +$BundleDir = Join-Path $Root 'src-tauri\target\release\bundle\windows' + +# ── Logging ─────────────────────────────────────────────────────────────────── +'' | Set-Content $LogFile # truncate / create +function Log { + param([string]$Msg, [ConsoleColor]$Color = 'Cyan') + $line = "[$(Get-Date -Format 'HH:mm:ss')] $Msg" + Write-Host $line -ForegroundColor $Color + Add-Content -Path $LogFile -Value $line +} + +function Fail { + param([string]$Msg) + Log "ERROR: $Msg" -Color Red + Log "Full log saved to: $LogFile" -Color Yellow + Write-Host '' + Write-Host 'Press Enter to close...' -ForegroundColor Yellow + $null = Read-Host + exit 1 +} + +# ── Ensure Cargo is on PATH ─────────────────────────────────────────────────── +$CargoBin = Join-Path $env:USERPROFILE '.cargo\bin' +if (Test-Path (Join-Path $CargoBin 'cargo.exe')) { + if ($env:PATH -notlike "*$CargoBin*") { + $env:PATH = "$CargoBin;$env:PATH" + Log "Added $CargoBin to PATH for this session." + } +} else { + Fail "Rust/Cargo not found at $CargoBin.`nInstall Rust from: https://rustup.rs" +} + +# ── Verify required tools ───────────────────────────────────────────────────── +Log '── Checking prerequisites ──────────────────────────────────────' +foreach ($tool in @('node', 'npm', 'cargo')) { + $cmd = Get-Command $tool -ErrorAction SilentlyContinue + if ($cmd) { + $ver = & $tool --version 2>&1 + Log " $tool → $($cmd.Source) ($($ver -replace "`n",''))" + } else { + Fail "$tool not found in PATH. Ensure it is installed and restart VS Code." + } +} + +# ── Change into project root ────────────────────────────────────────────────── +Set-Location $Root + +# ── npm install ─────────────────────────────────────────────────────────────── +Log '' +Log '── npm install ─────────────────────────────────────────────────' +& npm install 2>&1 | Tee-Object -FilePath $LogFile -Append +if ($LASTEXITCODE -ne 0) { + Fail "npm install failed (exit code $LASTEXITCODE). See $LogFile for details." +} + +# ── Tauri build ─────────────────────────────────────────────────────────────── +# Tauri's beforeBuildCommand ("npm run build") runs tsc + vite automatically. +# No need to run "npm run build" separately. +Log '' +Log '── npm run tauri build ──────────────────────────────────────────' +Log ' (this compiles Rust + bundles the frontend — first run takes 5-15 min)' +& npm run tauri build 2>&1 | Tee-Object -FilePath $LogFile -Append +if ($LASTEXITCODE -ne 0) { + Fail "tauri build failed (exit code $LASTEXITCODE). See $LogFile for details." +} + +# ── Locate artifacts ────────────────────────────────────────────────────────── +Log '' +Log '── Build complete — locating installer artifacts ────────────────' -Color Green + +if (Test-Path $BundleDir) { + $exes = @(Get-ChildItem $BundleDir -Filter '*.exe' -ErrorAction SilentlyContinue) + $msis = @(Get-ChildItem $BundleDir -Filter '*.msi' -ErrorAction SilentlyContinue) + + if ($exes.Count -gt 0) { + Log " Installer EXE(s) in $BundleDir :" -Color Green + $exes | ForEach-Object { Log " $($_.Name) ($([math]::Round($_.Length/1MB,1)) MB)" -Color Green } + } + if ($msis.Count -gt 0) { + Log " MSI(s) in $BundleDir :" -Color Green + $msis | ForEach-Object { Log " $($_.Name) ($([math]::Round($_.Length/1MB,1)) MB)" -Color Green } + } + if ($exes.Count -eq 0 -and $msis.Count -eq 0) { + Log " No installer found in $BundleDir" -Color Yellow + Log " The app binary is at: src-tauri\target\release\scrcpy-gui-v4.exe" -Color Yellow + } +} else { + Log " Bundle directory not found: $BundleDir" -Color Yellow + Log " The app binary may be at: src-tauri\target\release\scrcpy-gui-v4.exe" -Color Yellow +} + +Log '' +Log "Full build log saved to: $LogFile" -Color Green +Write-Host '' +Write-Host 'Press Enter to close...' -ForegroundColor Cyan +$null = Read-Host diff --git a/build_Portable.bat b/build_Portable.bat new file mode 100644 index 0000000..75c8651 --- /dev/null +++ b/build_Portable.bat @@ -0,0 +1,15 @@ +@echo off +REM Build ScrcpyGUI and generate a Windows executable bundle. +cd /d "%~dp0" + +echo Installing npm dependencies... +call npm install +if errorlevel 1 exit /b %errorlevel% + +echo Building the application with Tauri... +call npm run tauri build +if errorlevel 1 exit /b %errorlevel% + +echo Build complete. +echo Output bundle should be available under src-tauri\target\release\bundle\windows +pause diff --git a/flake.nix b/flake.nix index 2479cea..ded7481 100644 --- a/flake.nix +++ b/flake.nix @@ -82,9 +82,9 @@ desktopItems = [ (pkgs.makeDesktopItem { - name = "scrcpy-gui-v3"; - exec = "scrcpy-gui-v3"; - icon = "scrcpy-gui-v3"; + name = "scrcpy-gui-v4"; + exec = "scrcpy-gui-v4"; + icon = "scrcpy-gui-v4"; desktopName = "ScrcpyGUI"; comment = "A modern GUI for Scrcpy written in React and Rust"; categories = [ @@ -97,15 +97,15 @@ postInstall = '' # Install the standard sized icons for size in 32 64 128; do - install -Dm644 icons/''${size}x''${size}.png $out/share/icons/hicolor/''${size}x''${size}/apps/scrcpy-gui-v3.png + install -Dm644 icons/''${size}x''${size}.png $out/share/icons/hicolor/''${size}x''${size}/apps/scrcpy-gui-v4.png done # Install high-resolution icons for GNOME/modern desktops - install -Dm644 icons/128x128@2x.png $out/share/icons/hicolor/256x256/apps/scrcpy-gui-v3.png - install -Dm644 icons/icon.png $out/share/icons/hicolor/512x512/apps/scrcpy-gui-v3.png + install -Dm644 icons/128x128@2x.png $out/share/icons/hicolor/256x256/apps/scrcpy-gui-v4.png + install -Dm644 icons/icon.png $out/share/icons/hicolor/512x512/apps/scrcpy-gui-v4.png # Install a fallback pixmap just in case - install -Dm644 icons/icon.png $out/share/pixmaps/scrcpy-gui-v3.png + install -Dm644 icons/icon.png $out/share/pixmaps/scrcpy-gui-v4.png ''; preFixup = '' diff --git a/package-lock.json b/package-lock.json index 5322832..5e8eb7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "scrcpy-gui-v3", + "name": "scrcpy-gui-v4", "version": "4.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "scrcpy-gui-v3", + "name": "scrcpy-gui-v4", "version": "4.0.1", "dependencies": { "@tailwindcss/postcss": "4.2.4", diff --git a/package.json b/package.json index a86e72c..f104076 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "scrcpy-gui-v3", + "name": "scrcpy-gui-v4", "private": true, "version": "4.0.1", "type": "module", diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..e3b9f7e --- /dev/null +++ b/start.bat @@ -0,0 +1,6 @@ +@echo off +REM Start ScrcpyGUI for temporary testing in development mode. +cd /d "%~dp0" + +echo Starting ScrcpyGUI development server... +call npm run tauri dev From 877f2181e6bacdd44ae246519766012f0800776e Mon Sep 17 00:00:00 2001 From: vishwas0developers Date: Fri, 12 Jun 2026 15:18:22 +0530 Subject: [PATCH 2/7] refactor: remove splashscreen and fix modal positioning - Remove splashscreen window configuration from tauri.conf.json - Delete close_splashscreen command and splashscreen show logic - Set main window visible by default - Remove 500ms delay and splashscreen close call in App.tsx startup - Change OnboardingModal container from fixed to absolute for proper layering - Bump version to 4.0.1 --- src-tauri/Cargo.lock | 2 +- src-tauri/src/lib.rs | 19 ------------------- src-tauri/tauri.conf.json | 13 +------------ src/App.tsx | 12 +++++------- src/components/OnboardingModal.tsx | 2 +- 5 files changed, 8 insertions(+), 40 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 3968c30..823bff8 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3208,7 +3208,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scrcpy-gui-v3" -version = "4.0.0" +version = "4.0.1" dependencies = [ "chrono", "flate2", diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 2ad505d..e346ef5 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -63,11 +63,6 @@ pub fn run() { processes: Mutex::new(HashMap::new()), }); - // Show splashscreen instantly - if let Some(splash_window) = app.get_webview_window("splashscreen") { - splash_window.show().unwrap(); - } - Ok(()) }) .invoke_handler(tauri::generate_handler![ @@ -91,7 +86,6 @@ pub fn run() { commands::get_scrcpy_bin_dir, commands::run_terminal_command, commands::check_scrcpy_update, - close_splashscreen, get_app_version ]) .run(tauri::generate_context!()) @@ -102,16 +96,3 @@ pub fn run() { fn get_app_version(app: tauri::AppHandle) -> String { app.package_info().version.to_string() } - -#[tauri::command] -async fn close_splashscreen(window: tauri::Window) { - // Get the main window - if let Some(main_window) = window.get_webview_window("main") { - // Show the main window - main_window.show().unwrap(); - } - // Close the splashscreen window - if let Some(splash_window) = window.get_webview_window("splashscreen") { - splash_window.close().unwrap(); - } -} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index dbf9d52..1396923 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -16,22 +16,11 @@ "title": "ScrcpyGUI", "width": 1200, "height": 890, - "visible": false, + "visible": true, "resizable": false, "center": true, "transparent": false, "decorations": true - }, - { - "label": "splashscreen", - "url": "splashscreen.html", - "width": 500, - "height": 400, - "visible": false, - "decorations": false, - "transparent": true, - "center": true, - "alwaysOnTop": true } ], "security": { diff --git a/src/App.tsx b/src/App.tsx index 4105b89..4430256 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -103,21 +103,19 @@ function App() { }; useEffect(() => { - // Initial setup: fetch version and close splashscreen + // Initial setup: fetch version for the header const initApp = async () => { try { + const startedAt = performance.now(); const v = await getVersion(); setAppVersion(v); - - const { invoke } = await import('@tauri-apps/api/core'); - await invoke('close_splashscreen'); + console.info(`[startup] version loaded in ${Math.round(performance.now() - startedAt)}ms`); } catch (e) { console.error("Initialization failed:", e); } }; - const timer = setTimeout(initApp, 500); - return () => clearTimeout(timer); + void initApp(); }, []); useEffect(() => { @@ -288,7 +286,7 @@ function App() { return ( -
+