tools: add sync-version.js to sync package.json -> Tauri files

- Add tools/sync-version.js script to read root package.json version
  and update src-tauri/tauri.conf.json and src-tauri/Cargo.toml.
- Update only the [package] version line in Cargo.toml to preserve formatting.
- Include JSON read/write helpers and basic error handling/reporting.
This commit is contained in:
2026-01-13 07:21:51 +01:00
parent abb7cafaed
commit 694f335408
50 changed files with 1128 additions and 6186 deletions

View File

@@ -6,17 +6,20 @@ This document describes the desktop (Tauri) application architecture, build pipe
- **Frontend (WebView)**: Vanilla HTML/CSS/JS in [src/index.html](src/index.html), [src/main.js](src/main.js), [src/styles.css](src/styles.css)
- **Tauri host (Rust)**: Command layer + device discovery in [src-tauri/src/lib.rs](src-tauri/src/lib.rs)
- **Native audio engine (Rust)**: FFmpeg decode + CPAL output in [src-tauri/src/player.rs](src-tauri/src/player.rs)
- **Cast sidecar (Node executable)**: Google Cast control via `castv2-client` in [sidecar/index.js](sidecar/index.js)
- **Packaging utilities**:
- Sidecar binary copy/rename step: [tools/copy-binaries.js](tools/copy-binaries.js)
- Windows EXE icon patch: [tools/post-build-rcedit.js](tools/post-build-rcedit.js)
- Optional FFmpeg bundling helper: [tools/copy-ffmpeg.js](tools/copy-ffmpeg.js) (see [tools/ffmpeg/README.md](tools/ffmpeg/README.md))
Data flow:
1. UI actions call JS functions in `main.js`.
2. When in **Cast mode**, JS calls Tauri commands via `window.__TAURI__.core.invoke()`.
3. The Rust backend discovers Cast devices via mDNS and stores `{ deviceName -> ip }`.
4. On `cast_play/stop/volume`, Rust spawns (or reuses) a **sidecar process**, then sends newline-delimited JSON commands to the sidecar stdin.
2. JS calls Tauri commands via `window.__TAURI__.core.invoke()` (for both local playback and casting).
3. In **Local mode**, Rust spawns FFmpeg and plays decoded PCM via CPAL.
4. In **Cast mode**, the Rust backend discovers Cast devices via mDNS and stores `{ deviceName -> ip }`.
5. On `cast_play/stop/volume`, Rust spawns (or reuses) a **sidecar process**, then sends newline-delimited JSON commands to the sidecar stdin.
## Running and building
@@ -113,6 +116,29 @@ When a device is resolved:
### Commands
### Native player commands (local playback)
Local playback is handled by the Rust engine in [src-tauri/src/player.rs](src-tauri/src/player.rs). The UI controls it using these commands:
#### `player_play(url: String) -> Result<(), String>`
- Starts native playback of the provided stream URL.
- Internally spawns FFmpeg to decode into `s16le` PCM and feeds a ring buffer consumed by a CPAL output stream.
- Reports `buffering``playing` based on buffer fill/underrun.
#### `player_stop() -> Result<(), String>`
- Stops the native pipeline and updates state.
#### `player_set_volume(volume: f32) -> Result<(), String>`
- Sets volume in range `[0, 1]`.
#### `player_get_state() -> Result<PlayerState, String>`
- Returns `{ status, url, volume, error }`.
- Used by the UI to keep status text and play/stop button in sync.
#### `list_cast_devices() -> Result<Vec<String>, String>`
- Returns the sorted list of discovered Cast device names.
@@ -214,7 +240,8 @@ State is tracked in JS:
#### Local mode
- Uses `new Audio()` and sets `audio.src = station.url`.
- Uses backend invokes: `player_play`, `player_stop`, `player_set_volume`.
- The UI polls `player_get_state` to reflect `buffering/playing/stopped/error`.
#### Cast mode
@@ -274,7 +301,7 @@ Note:
- `#play-btn`
- Toggles play/stop (`togglePlay()`):
- Local mode: `audio.play()` / `audio.pause()`.
- Local mode: `invoke('player_play')` / `invoke('player_stop')`.
- Cast mode: `invoke('cast_play')` / `invoke('cast_stop')`.
- `#prev-btn`
- Previous station (`playPrev()``setStationByIndex()`).
@@ -284,7 +311,7 @@ Note:
### Volume
- `#volume-slider`
- Local: sets `audio.volume`.
- Local: `invoke('player_set_volume')`.
- Cast: `invoke('cast_set_volume')`.
- Persists `localStorage.volume`.
- `#mute-btn`