Implemented standalone builds

This commit is contained in:
Ben committed 2026-07-05 09:24:07 +02:00
1 parent 43213f6220
commit f1c8e2c575
37 files changed
+5771 -10

No files matched your search

+6
View File
@@ -38,3 +38,9 @@ Thumbs.db
# Local user preferences (not shared) # Local user preferences (not shared)
backend/userprefs.json backend/userprefs.json
# ---- Desktop build (PyInstaller sidecar) ----
# The frozen binary + intermediate work. The spec, sidecar.py and
# build_sidecar.sh are source and ARE tracked.
backend/build/
backend/dist/
+81
View File
@@ -0,0 +1,81 @@
# Building Konduktor for Windows
The desktop app can't be cross-compiled — a Windows build must be produced **on
Windows** (Tauri needs the MSVC toolchain + WebView2; PyInstaller must freeze the
backend into a Windows `.exe`). The macOS `.dmg` is built separately on a Mac.
This mirrors the macOS build exactly; only the toolchain install and the
sidecar-build command differ.
## One-time setup
1. **Rust** — install via <https://rustup.rs> (gives the `x86_64-pc-windows-msvc`
toolchain). You also need the **MSVC C++ build tools**: install "Desktop
development with C++" from the Visual Studio Build Tools installer.
2. **WebView2 Runtime** — preinstalled on current Windows 10/11. If missing, get
the Evergreen runtime from Microsoft (Tauri's installer can also bootstrap it).
3. **Python 3.11–3.14** — <https://python.org> (tick "Add to PATH").
4. **Node 18+** — <https://nodejs.org>.
Then, from the repo root:
```powershell
# Backend deps (runtime + build) in a venv
cd backend
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt -r requirements-build.txt
cd ..
# Frontend deps
cd frontend
npm install
cd ..
```
## Build
```powershell
# 1) Freeze + stage the backend sidecar (from the activated backend venv)
cd backend
.\.venv\Scripts\Activate.ps1 # if not already active
.\build_sidecar.ps1 # → frontend\src-tauri\binaries\konduktor-sidecar-<triple>.exe
cd ..
# 2) Build the app
cd frontend
npx tauri build
```
## Output
Installers land in:
```
frontend\src-tauri\target\release\bundle\msi\Konduktor_0.1.0_x64_en-US.msi
frontend\src-tauri\target\release\bundle\nsis\Konduktor_0.1.0_x64-setup.exe
```
Either one installs the app (bundling the sidecar `.exe` alongside it).
## Rebuilding after changes
Same as macOS: if you changed **backend** Python, re-run `build_sidecar.ps1`
first; then `npx tauri build`. Frontend-only changes just need `npx tauri build`
(its `beforeBuildCommand` rebuilds the web app).
## Known Windows caveats
- **Unsigned build → SmartScreen.** We don't code-sign yet, so the first launch
shows a "Windows protected your PC" prompt. Click **More info → Run anyway**.
(Signing is a future step.)
- **Mixed content is already handled.** The webview is forced to the `http`
custom-protocol scheme (`use_https_scheme(false)` in `src-tauri/src/lib.rs`) so
it can fetch the sidecar at `http://127.0.0.1:<port>` without being blocked.
Leave that setting as-is.
- **Sidecar console window.** The sidecar is frozen as a console app (needed for
the `KONDUKTOR_PORT` stdout handshake). Tauri's shell plugin normally spawns it
without a visible window; if a console flashes on launch, tell me and we'll add
the `CREATE_NO_WINDOW` spawn flag.
- **The sidecar must be frozen on Windows** — a macOS-built sidecar won't run.
`build_sidecar.ps1` handles this; just don't copy binaries between OSes.
+58 -4
View File
@@ -64,13 +64,16 @@ npm install
cd .. cd ..
``` ```
### 2. Launch ### 2. Run it (development)
```bash ```bash
./dev.sh ./dev.sh
``` ```
Then open **http://localhost:5173** in your browser. Press `Ctrl-C` to stop. This starts both servers; open **http://localhost:5173** in your browser. Press
`Ctrl-C` to stop. This is the fastest way to try Konduktor or hack on it — the
frontend hot-reloads as you edit. To package a real double-clickable app
instead, see [Build a standalone app](#build-a-standalone-app-production) below.
### 3. Open your collection ### 3. Open your collection
@@ -84,6 +87,55 @@ That's it — you're in.
--- ---
## Build a standalone app (production)
Prefer a real double-clickable app over running the dev servers? Konduktor
packages into a native desktop app (via **Tauri**) that bundles the Python
backend as a sidecar — no terminal, no servers to start by hand.
### Extra prerequisites
On top of the Python 3.11+ and Node 18+ from above:
- **Rust** — install from <https://rustup.rs> (the app shell is Tauri/Rust).
- **PyInstaller** — into the backend venv:
`pip install -r backend/requirements-build.txt`
### macOS
```bash
# 1) Freeze the backend into a sidecar binary (run from the backend venv)
cd backend && source .venv/bin/activate
./build_sidecar.sh
cd ..
# 2) Build the app
cd frontend
npx tauri build
```
You'll get an installer at
`frontend/src-tauri/target/release/bundle/dmg/Konduktor_<version>_aarch64.dmg`
(with the `.app` beside it). Builds are currently **unsigned**, so the first
launch needs a right-click → **Open** to get past Gatekeeper. The `.dmg` is
Apple-Silicon (`aarch64`) only.
> **Faster local builds:** `npx tauri build --debug --bundles app` skips the
> optimizer and the `.dmg`, giving you a runnable `.app` in seconds — handy while
> iterating.
### Windows
Windows can't be cross-built from macOS — the (near-identical) steps to run on a
Windows machine are in **[BUILDING-WINDOWS.md](BUILDING-WINDOWS.md)**.
### Rebuilding after changes
Changed **backend** Python? Re-run `./build_sidecar.sh`, then `npx tauri build`.
Frontend-only change? Just `npx tauri build` — it rebuilds the web app for you.
---
## Saving back to Traktor ## Saving back to Traktor
Playlist edits, tag changes, and prep tweaks all apply live in the app. When Playlist edits, tag changes, and prep tweaks all apply live in the app. When
@@ -103,8 +155,10 @@ play around.
- Konduktor is built on [`traktor-nml-utils`](https://github.com/MrPatben8/traktor-nml-utils) - Konduktor is built on [`traktor-nml-utils`](https://github.com/MrPatben8/traktor-nml-utils)
and speaks Traktor's real file format — no import/export, no separate database. and speaks Traktor's real file format — no import/export, no separate database.
- It's a web app today, with an eye toward a packaged desktop build (Tauri) and - Run it in your browser from source, or package it into a native desktop app
a mobile version down the road. (macOS `.dmg` / Windows `.msi`) that bundles the backend — see
[Build a standalone app](#build-a-standalone-app-production). A mobile version
is on the horizon.
- Under the hood: **FastAPI** (Python) backend + **React / TypeScript / Vite** - Under the hood: **FastAPI** (Python) backend + **React / TypeScript / Vite**
frontend. Curious about internals or contributing? See frontend. Curious about internals or contributing? See
[CLAUDE.md](CLAUDE.md) for the architecture and conventions. [CLAUDE.md](CLAUDE.md) for the architecture and conventions.
+27
View File
@@ -0,0 +1,27 @@
# Build the frozen backend sidecar on Windows (PyInstaller) and stage it for
# Tauri as binaries\konduktor-sidecar-<target-triple>.exe.
# Output: backend\dist\konduktor-sidecar.exe + frontend\src-tauri\binaries\...
#
# Run from a PowerShell prompt with the backend venv's Python on PATH, e.g.:
# cd backend
# .\.venv\Scripts\Activate.ps1
# pip install -r requirements.txt -r requirements-build.txt
# .\build_sidecar.ps1
$ErrorActionPreference = "Stop"
$Root = $PSScriptRoot
Set-Location $Root
# Prefer the venv python if present, else whatever `python` resolves to.
$Py = Join-Path $Root ".venv\Scripts\python.exe"
if (-not (Test-Path $Py)) { $Py = "python" }
& $Py -m PyInstaller --noconfirm --clean konduktor-sidecar.spec
Write-Host "Built: $Root\dist\konduktor-sidecar.exe"
# Stage for Tauri: name with the host target triple + .exe so the shell plugin
# resolves it. (rustc must be on PATH.)
$Triple = (& rustc -vV | Select-String '^host: ').ToString().Replace('host: ', '').Trim()
$Dest = Join-Path $Root "..\frontend\src-tauri\binaries"
New-Item -ItemType Directory -Force -Path $Dest | Out-Null
Copy-Item "$Root\dist\konduktor-sidecar.exe" (Join-Path $Dest "konduktor-sidecar-$Triple.exe") -Force
Write-Host "Staged: $Dest\konduktor-sidecar-$Triple.exe"
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Build the frozen backend sidecar (single-file binary) with PyInstaller and
# stage it for Tauri as binaries/konduktor-sidecar-<target-triple>.
# Output: backend/dist/konduktor-sidecar + frontend/src-tauri/binaries/…
#
# One-time: pip install -r requirements-build.txt (into the backend venv).
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
PY="${PY:-.venv/bin/python}"
"$PY" -m PyInstaller --noconfirm --clean konduktor-sidecar.spec
echo "Built: $ROOT/dist/konduktor-sidecar"
# Stage for Tauri: the sidecar must be named with the host target triple so the
# shell plugin can resolve it in both dev and bundle. (rustc must be on PATH.)
if command -v rustc >/dev/null 2>&1; then
TRIPLE="$(rustc -vV | sed -n 's/host: //p')"
DEST="$ROOT/../frontend/src-tauri/binaries"
mkdir -p "$DEST"
cp "$ROOT/dist/konduktor-sidecar" "$DEST/konduktor-sidecar-$TRIPLE"
echo "Staged: $DEST/konduktor-sidecar-$TRIPLE"
else
echo "warning: rustc not found — skipped staging the Tauri sidecar binary" >&2
fi
+64
View File
@@ -0,0 +1,64 @@
# PyInstaller spec for the Konduktor backend sidecar (Step 1 of the standalone
# build). Produces a single-file binary that serves the FastAPI API on a free
# loopback port. Build with: pyinstaller konduktor-sidecar.spec (or build_sidecar.sh)
#
# The tricky bits this handles:
# - uvicorn imports its loop/protocol backends dynamically → collect_submodules
# - the standard extras (uvloop/httptools/websockets) are native → collect_all
# - traktor-nml-utils parses/serializes via xsdata, which discovers plugins at
# runtime → collect_submodules('xsdata')
# - python-multipart is imported as `multipart` by starlette → hidden import
from PyInstaller.utils.hooks import collect_submodules, collect_all
hiddenimports = []
datas = []
binaries = []
# Dynamically-imported subpackages.
for pkg in ("uvicorn", "xsdata"):
hiddenimports += collect_submodules(pkg)
# Native standard extras — grab modules + shared libs + any data.
for pkg in ("uvloop", "httptools", "websockets"):
d, b, h = collect_all(pkg)
datas += d
binaries += b
hiddenimports += h
# Imported by name, not statically discoverable.
hiddenimports += ["multipart", "anyio"]
a = Analysis(
["sidecar.py"],
pathex=[],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
# watchfiles is dev-reload only; the frozen sidecar never uses --reload.
excludes=["watchfiles"],
noarchive=False,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name="konduktor-sidecar",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True, # keep stdout so the host can read KONDUKTOR_PORT
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
+8 -1
View File
@@ -48,7 +48,14 @@ app = FastAPI(title="Konduktor API", version="0.4.0")
app.add_middleware( app.add_middleware(
CORSMiddleware, CORSMiddleware,
allow_origins=["http://localhost:5173", "http://127.0.0.1:5173"], allow_origins=[
"http://localhost:5173",
"http://127.0.0.1:5173",
# Packaged desktop app: the webview's origin when Tauri loads the built
# frontend (macOS uses tauri://, Windows/Linux use https://tauri.localhost).
"tauri://localhost",
"https://tauri.localhost",
],
allow_methods=["*"], allow_methods=["*"],
allow_headers=["*"], allow_headers=["*"],
) )
+4
View File
@@ -0,0 +1,4 @@
# Build-only dependencies (not needed to run the backend in dev).
# Freezes the backend into a standalone sidecar binary for the desktop build.
# See konduktor-sidecar.spec and build_sidecar.sh.
pyinstaller>=6.16 # 6.16+ supports Python 3.14
+60
View File
@@ -0,0 +1,60 @@
"""PyInstaller entry point for the packaged backend sidecar.
The frozen build launches this. It picks a free localhost port, announces it on
stdout as `KONDUKTOR_PORT=<n>` (so the host process — Tauri — knows where to
send API calls), then serves the FastAPI app on loopback.
Dev is unchanged: `dev.sh` still runs `uvicorn konduktor.main:app` on :8000.
This file exists only for the frozen sidecar.
"""
from __future__ import annotations
import os
import socket
import sys
import threading
import uvicorn
from konduktor.main import app
def _watch_parent_and_exit() -> None:
"""Exit when our parent (the Tauri shell) goes away.
Tauri spawns us with a piped stdin and holds the write end open without
writing anything. If the host process quits — gracefully, via SIGKILL, or by
crashing — the OS closes that pipe and our stdin reads EOF. That's our cue to
shut down, so the backend can never be orphaned (the Rust-side kill-on-exit
only covers the graceful path). When run standalone from a terminal, stdin is
a TTY and this blocks harmlessly forever.
"""
try:
while sys.stdin.buffer.read(1):
pass
except Exception:
pass
os._exit(0)
def _free_port() -> int:
"""Grab an unused loopback port. There's a tiny bind→close→rebind race, but
it's harmless on 127.0.0.1 for a single local sidecar."""
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(("127.0.0.1", 0))
return s.getsockname()[1]
def main() -> None:
# Die with our host so the backend is never left orphaned.
threading.Thread(target=_watch_parent_and_exit, daemon=True).start()
# Honor an explicit port (tests / the host may pin one) else pick a free one.
port = int(os.environ.get("KONDUKTOR_PORT") or _free_port())
# Announce the port BEFORE uvicorn starts logging, and flush, so the parent
# can read one clean line without racing the server's own output.
print(f"KONDUKTOR_PORT={port}", flush=True)
uvicorn.run(app, host="127.0.0.1", port=port, log_level="info")
if __name__ == "__main__":
main()
+245
View File
@@ -20,6 +20,8 @@
}, },
"devDependencies": { "devDependencies": {
"@tailwindcss/postcss": "^4.3.2", "@tailwindcss/postcss": "^4.3.2",
"@tauri-apps/api": "^2.11.1",
"@tauri-apps/cli": "^2.11.4",
"@types/node": "^24.13.2", "@types/node": "^24.13.2",
"@types/react": "^19.2.17", "@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
@@ -1223,6 +1225,249 @@
"url": "https://github.com/sponsors/tannerlinsley" "url": "https://github.com/sponsors/tannerlinsley"
} }
}, },
"node_modules/@tauri-apps/api": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-2.11.1.tgz",
"integrity": "sha512-M2FPuYND2m+wh5hfW9ZpSdxMPdEJovPBWwoHJmwUpysTYNHaOkVFN419m/K0LIgjb/7KU2vBgsUepJWugQCvAA==",
"dev": true,
"license": "Apache-2.0 OR MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/tauri"
}
},
"node_modules/@tauri-apps/cli": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.11.4.tgz",
"integrity": "sha512-R8xGtMpwyetawSqm9kYOuMmEqkhUbvcUy8n0aNXIxollKBLESUu5f4Fx+64hgASYm1H+jSWq6jCW6zqTnH6hqQ==",
"dev": true,
"license": "Apache-2.0 OR MIT",
"bin": {
"tauri": "tauri.js"
},
"engines": {
"node": ">= 10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/tauri"
},
"optionalDependencies": {
"@tauri-apps/cli-darwin-arm64": "2.11.4",
"@tauri-apps/cli-darwin-x64": "2.11.4",
"@tauri-apps/cli-linux-arm-gnueabihf": "2.11.4",
"@tauri-apps/cli-linux-arm64-gnu": "2.11.4",
"@tauri-apps/cli-linux-arm64-musl": "2.11.4",
"@tauri-apps/cli-linux-riscv64-gnu": "2.11.4",
"@tauri-apps/cli-linux-x64-gnu": "2.11.4",
"@tauri-apps/cli-linux-x64-musl": "2.11.4",
"@tauri-apps/cli-win32-arm64-msvc": "2.11.4",
"@tauri-apps/cli-win32-ia32-msvc": "2.11.4",
"@tauri-apps/cli-win32-x64-msvc": "2.11.4"
}
},
"node_modules/@tauri-apps/cli-darwin-arm64": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.11.4.tgz",
"integrity": "sha512-1ryOF3ZhpZ/nemHV5zVwBQBz9jDGKmKPvWPADOhc83ig0P4bMc2iER4NbC6r9sjeIZ6RVQ4g3RZIYvezhcl4TQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-darwin-x64": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.11.4.tgz",
"integrity": "sha512-uFsGQAAfuyz1k/yGLmkWfkBlgKAqZfxqlHmLWx81QU27RJWfmbNHCIq8T8w1e+VClleIuZUjpHWfoE4E3DLo3A==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm-gnueabihf": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.11.4.tgz",
"integrity": "sha512-IaHZn5CdBL21oUmjiVOS1ctw6Ip1O0pjp70FwOWmYz1myWe0SY96ZIj2FYf7pT0m8bI2h/hrs5ZbEXXh44/MkQ==",
"cpu": [
"arm"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-gnu": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.11.4.tgz",
"integrity": "sha512-N41/ukTRVe6XSuUTESuFdGeOW2i7k62tK+6gHK5Kd5/q5RPvvi19GaWAVPPb9u95HSGmTChSolBfzynUsssFaA==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-musl": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.11.4.tgz",
"integrity": "sha512-v277UnT/fB64xAfSroL5N3Km3tLmvATWqJJw/wRI+g6o+HkeD0slyE7gOhNs1MbjE41R7bQOTxMVoL3aomUJmw==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-riscv64-gnu": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-riscv64-gnu/-/cli-linux-riscv64-gnu-2.11.4.tgz",
"integrity": "sha512-qqgNkQ2u1yZHxjhxsZaxUtRDW8dIqIYm33rx/mzwQv0SfY9x1B+iraj8vWeFiXjjSVVhEMepXSOts1TqPzvXNQ==",
"cpu": [
"riscv64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-gnu": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.11.4.tgz",
"integrity": "sha512-2VRNWl84FOH0m2giiDkO2h0QXlcMJeX+zJDpI5kDIQAx6s+geF3v48F4DXfJez4GS/FdoDGnPnw1C2iYGbQ7bQ==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-musl": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.11.4.tgz",
"integrity": "sha512-o9GyhYor/nc7xarmwDE3ka2szuW3uuZzXjHWh64Q8YX5AtSgxdQkFWzrY4O8KiGtVNvFBI14H3Q49Qj5TOIP/A==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-arm64-msvc": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.11.4.tgz",
"integrity": "sha512-ld5Ehb598m0VkYyylRPNeCFsBe/km0jxis6KgMpl3IGY6I/i1RwQXO05I1AsXUXO2WC6AvB/Lw4qTf/asiuEiQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-ia32-msvc": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.11.4.tgz",
"integrity": "sha512-12Hxi0XX/H5VFxO/bGgHkFWhml9VMgEOu9CidjeCeTNQ1l6fpUlbiGgSP7CLI3PFtW9/FfbeHieZ+kyWK5H7CA==",
"cpu": [
"ia32"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-x64-msvc": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.11.4.tgz",
"integrity": "sha512-+vDiqBIU5dMISg/wNvX3sF+ZHfgJGJ5T0AcO+EHNXV9GGAG+P5fzodlDXD3QdKCRgZxMoCm5PPvj3BqLNjBthw==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tybys/wasm-util": { "node_modules/@tybys/wasm-util": {
"version": "0.10.3", "version": "0.10.3",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.3.tgz", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.3.tgz",
+2
View File
@@ -22,6 +22,8 @@
}, },
"devDependencies": { "devDependencies": {
"@tailwindcss/postcss": "^4.3.2", "@tailwindcss/postcss": "^4.3.2",
"@tauri-apps/api": "^2.11.1",
"@tauri-apps/cli": "^2.11.4",
"@types/node": "^24.13.2", "@types/node": "^24.13.2",
"@types/react": "^19.2.17", "@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
+8
View File
@@ -0,0 +1,8 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/gen/schemas
# Frozen backend sidecar — a build artifact (23MB); rebuild with
# backend/build_sidecar.sh. The Rust/config that reference it ARE tracked.
/binaries/
+4960
View File
File diff suppressed because it is too large. Load diff
+27
View File
@@ -0,0 +1,27 @@
[package]
name = "app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
edition = "2021"
rust-version = "1.77.2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2.6.3", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
log = "0.4"
tauri = { version = "2.11.3", features = [] }
tauri-plugin-log = "2"
tauri-plugin-shell = "2" # spawn the Python backend sidecar
tokio = { version = "1", features = ["time"] } # timeout on the port handshake
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
@@ -0,0 +1,11 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "enables the default permissions",
"windows": [
"main"
],
"permissions": [
"core:default"
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

+110
View File
@@ -0,0 +1,110 @@
// Konduktor desktop shell (Tauri v2).
//
// The backend is the frozen Python sidecar (see backend/sidecar.py): on launch
// we spawn it, read the `KONDUKTOR_PORT=<n>` line it prints on stdout, wait for
// it to actually accept connections, then create the app window with an
// initialization script that hands the frontend its API base
// (`window.__KONDUKTOR_API__`). The sidecar is killed when the app exits.
use std::sync::Mutex;
use std::time::Duration;
use tauri::{Manager, WebviewUrl, WebviewWindowBuilder};
use tauri_plugin_shell::process::{CommandChild, CommandEvent};
use tauri_plugin_shell::ShellExt;
/// Holds the running sidecar child so we can terminate it on exit.
struct Sidecar(Mutex<Option<CommandChild>>);
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.manage(Sidecar(Mutex::new(None)))
.setup(|app| {
if cfg!(debug_assertions) {
app.handle().plugin(
tauri_plugin_log::Builder::default()
.level(log::LevelFilter::Info)
.build(),
)?;
}
let handle = app.handle().clone();
// Spawn the frozen backend. In dev/bundle the shell plugin resolves
// the sidecar from `binaries/konduktor-sidecar-<target-triple>`.
let (mut rx, child) = app
.shell()
.sidecar("konduktor-sidecar")
.expect("sidecar binary not found (build it into src-tauri/binaries/)")
.spawn()
.expect("failed to spawn backend sidecar");
app.state::<Sidecar>().0.lock().unwrap().replace(child);
tauri::async_runtime::block_on(async move {
// Read stdout until the backend announces its port (bounded so a
// misbehaving sidecar can't hang the launch forever).
let find_port = async {
while let Some(event) = rx.recv().await {
if let CommandEvent::Stdout(bytes) = event {
let text = String::from_utf8_lossy(&bytes);
for line in text.lines() {
if let Some(p) = line.trim().strip_prefix("KONDUKTOR_PORT=") {
if let Ok(n) = p.trim().parse::<u16>() {
return Some(n);
}
}
}
}
}
None
};
let port = tokio::time::timeout(Duration::from_secs(20), find_port)
.await
.ok()
.flatten()
.expect("backend sidecar did not report a port");
// Keep draining events so the sidecar's stdout/stderr pipes never
// fill and block it; the task ends when the child exits.
tauri::async_runtime::spawn(async move { while rx.recv().await.is_some() {} });
// Wait for the socket to actually accept connections (the port
// line is printed before uvicorn binds).
for _ in 0..200 {
if std::net::TcpStream::connect(("127.0.0.1", port)).is_ok() {
break;
}
std::thread::sleep(Duration::from_millis(50));
}
let inject =
format!("window.__KONDUKTOR_API__ = 'http://127.0.0.1:{port}';");
WebviewWindowBuilder::new(&handle, "main", WebviewUrl::App("index.html".into()))
.title("Konduktor")
.inner_size(1400.0, 900.0)
.min_inner_size(900.0, 600.0)
// On Windows the webview would otherwise be served from
// https://tauri.localhost, and fetching the sidecar over
// http://127.0.0.1 would be blocked as mixed content. Force
// the http custom-protocol scheme so both are http. (No-op on
// macOS, which uses the tauri:// scheme.)
.use_https_scheme(false)
.initialization_script(&inject)
.build()
.expect("failed to create the main window");
});
Ok(())
})
.build(tauri::generate_context!())
.expect("error while building the Tauri application")
.run(|app_handle, event| {
// Terminate the sidecar when the app is quitting.
if let tauri::RunEvent::ExitRequested { .. } = event {
if let Some(child) = app_handle.state::<Sidecar>().0.lock().unwrap().take() {
let _ = child.kill();
}
}
});
}
+6
View File
@@ -0,0 +1,6 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
app_lib::run();
}
+34
View File
@@ -0,0 +1,34 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "Konduktor",
"version": "0.1.0",
"identifier": "com.liquidicestudios.konduktor",
"build": {
"frontendDist": "../dist",
"devUrl": "http://localhost:5173",
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build"
},
"app": {
"withGlobalTauri": true,
"windows": [],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"externalBin": ["binaries/konduktor-sidecar"],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"android": {
"debugApplicationIdSuffix": ".debug"
}
}
}
+17 -5
View File
@@ -158,14 +158,24 @@ export interface SaveResult {
playlists: number playlists: number
} }
// API origin. In the packaged desktop app the frontend is served from
// tauri://localhost, so it can't use relative /api paths — the Tauri shell
// injects window.__KONDUKTOR_API__ (the sidecar's http://127.0.0.1:<port>)
// before any app script runs. In the browser dev server it's undefined, so we
// fall back to relative URLs and let Vite proxy /api to the backend.
export const API_BASE: string =
(typeof window !== 'undefined' &&
(window as unknown as { __KONDUKTOR_API__?: string }).__KONDUKTOR_API__) ||
''
async function getJSON<T>(url: string): Promise<T> { async function getJSON<T>(url: string): Promise<T> {
const res = await fetch(url) const res = await fetch(API_BASE + url)
if (!res.ok) throw new Error(`${res.status} ${res.statusText} — ${url}`) if (!res.ok) throw new Error(`${res.status} ${res.statusText} — ${url}`)
return res.json() as Promise<T> return res.json() as Promise<T>
} }
async function send<T>(method: string, url: string, body?: unknown): Promise<T> { async function send<T>(method: string, url: string, body?: unknown): Promise<T> {
const res = await fetch(url, { const res = await fetch(API_BASE + url, {
method, method,
headers: body ? { 'Content-Type': 'application/json' } : undefined, headers: body ? { 'Content-Type': 'application/json' } : undefined,
body: body ? JSON.stringify(body) : undefined, body: body ? JSON.stringify(body) : undefined,
@@ -233,8 +243,10 @@ export const api = {
save: () => send<SaveResult>('POST', '/api/save'), save: () => send<SaveResult>('POST', '/api/save'),
editTrack: (trackId: string, fields: Record<string, string | number | null>) => editTrack: (trackId: string, fields: Record<string, string | number | null>) =>
send<{ status: string }>('PATCH', '/api/tracks', { track_id: trackId, fields }), send<{ status: string }>('PATCH', '/api/tracks', { track_id: trackId, fields }),
artUrl: (trackId: string) => `/api/tracks/art?track_id=${encodeURIComponent(trackId)}`, artUrl: (trackId: string) =>
audioUrl: (trackId: string) => `/api/tracks/audio?track_id=${encodeURIComponent(trackId)}`, `${API_BASE}/api/tracks/art?track_id=${encodeURIComponent(trackId)}`,
audioUrl: (trackId: string) =>
`${API_BASE}/api/tracks/audio?track_id=${encodeURIComponent(trackId)}`,
trackCues: (trackId: string) => trackCues: (trackId: string) =>
getJSON<TrackCues>(`/api/tracks/cues?track_id=${encodeURIComponent(trackId)}`), getJSON<TrackCues>(`/api/tracks/cues?track_id=${encodeURIComponent(trackId)}`),
createHotcue: (trackId: string, slot: number, start: number, type: number, length = 0) => createHotcue: (trackId: string, slot: number, start: number, type: number, length = 0) =>
@@ -262,7 +274,7 @@ export const api = {
const fd = new FormData() const fd = new FormData()
fd.append('track_id', trackId) fd.append('track_id', trackId)
fd.append('file', file) fd.append('file', file)
const res = await fetch('/api/tracks/art', { method: 'PUT', body: fd }) const res = await fetch(`${API_BASE}/api/tracks/art`, { method: 'PUT', body: fd })
if (!res.ok) throw new Error(`Cover upload failed (${res.status})`) if (!res.ok) throw new Error(`Cover upload failed (${res.status})`)
return res.json() return res.json()
}, },
+16
View File
@@ -82,6 +82,22 @@ export function PrepStrip({ track, playRequest = 0, onError }: Props) {
return audioCtxRef.current return audioCtxRef.current
} }
// Tear everything down when the strip itself unmounts (e.g. the collection
// picker early-returns and replaces the whole UI). Without this, the playback
// source keeps running in an AudioContext that's never closed, so a fresh
// remount plays a SECOND track on top of the orphaned one. Closing both
// contexts is the surefire kill; runs once, on unmount.
useEffect(() => {
return () => {
playbackRef.current?.pause()
scratchRef.current?.dispose()
void audioCtxRef.current?.close()
void scratchCtxRef.current?.close()
audioCtxRef.current = null
scratchCtxRef.current = null
}
}, [])
// The scratch engine gets its OWN AudioContext: a ScriptProcessorNode is // The scratch engine gets its OWN AudioContext: a ScriptProcessorNode is
// unreliable sharing a context with the playback source node (it goes silent // unreliable sharing a context with the playback source node (it goes silent
// once a source has played), so we keep them fully separate. // once a source has played), so we keep them fully separate.