Compare commits
9
Commits
be713620ef
...
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
191148f9b9 | ||
|
|
2f40c60520 | ||
|
|
74501fba5c | ||
|
|
710caeb0fb | ||
|
|
8fe56667c6 | ||
|
|
b0625eafc2 | ||
|
|
4b5606dd15 | ||
|
|
e640ae17e5 | ||
|
|
ddb7a907a1 |
@@ -0,0 +1,82 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
frontend:
|
||||
name: Frontend
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
|
||||
- name: Type check
|
||||
run: npx tsc --noEmit
|
||||
|
||||
- name: Prettier check
|
||||
run: npm run format # make sure this is `prettier --check .`
|
||||
|
||||
- name: Build frontend
|
||||
run: npm run build
|
||||
|
||||
rust:
|
||||
name: Rust (Tauri backend)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
build-essential curl wget file pkg-config \
|
||||
libwebkit2gtk-4.1-dev libxdo-dev libssl-dev \
|
||||
libayatana-appindicator3-dev librsvg2-dev
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
# Tauri's build script checks that frontendDist exists
|
||||
- name: Build frontend
|
||||
run: npm run build
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Rust cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: src-tauri
|
||||
|
||||
- name: Format check
|
||||
run: cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check
|
||||
|
||||
- name: Clippy
|
||||
run: cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings
|
||||
|
||||
- name: Test
|
||||
run: cargo test --manifest-path src-tauri/Cargo.toml
|
||||
@@ -0,0 +1,151 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
API: https://gitea.iceberg.black/api/v1/repos/${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
name: Create release
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
RELEASE_ID: ${{ steps.create.outputs.RELEASE_ID }}
|
||||
steps:
|
||||
- name: Create Gitea release
|
||||
id: create
|
||||
run: |
|
||||
TAG=${GITHUB_REF#refs/tags/}
|
||||
RELEASE_ID=$(curl -s -X POST "$API/releases" \
|
||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\"}" | jq -r '.id')
|
||||
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_OUTPUT
|
||||
|
||||
build-linux:
|
||||
name: Build Linux bundles
|
||||
needs: create-release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
build-essential curl wget file pkg-config \
|
||||
libwebkit2gtk-4.1-dev libxdo-dev libssl-dev \
|
||||
libayatana-appindicator3-dev librsvg2-dev \
|
||||
xdg-utils
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Rust cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: src-tauri
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build Tauri app
|
||||
run: npm run tauri build
|
||||
|
||||
- name: Upload assets
|
||||
run: |
|
||||
for f in src-tauri/target/release/bundle/deb/*.deb \
|
||||
src-tauri/target/release/bundle/rpm/*.rpm \
|
||||
src-tauri/target/release/bundle/appimage/*.AppImage; do
|
||||
[ -f "$f" ] || continue
|
||||
echo "Uploading $f"
|
||||
curl -s -X POST "$API/releases/${{ needs.create-release.outputs.RELEASE_ID }}/assets?name=$(basename "$f")" \
|
||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||
-F "attachment=@$f"
|
||||
done
|
||||
|
||||
build-android:
|
||||
name: Build Android APK
|
||||
needs: create-release
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
NDK_VERSION: 27.0.12077973
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
|
||||
- name: Setup Android SDK
|
||||
uses: https://github.com/android-actions/setup-android@v4
|
||||
with:
|
||||
packages: 'platform-tools'
|
||||
|
||||
- name: Install NDK and platform
|
||||
run: |
|
||||
sdkmanager "platforms;android-36" "build-tools;36.0.0" "ndk;${NDK_VERSION}"
|
||||
echo "NDK_HOME=$ANDROID_HOME/ndk/${NDK_VERSION}" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
|
||||
|
||||
- name: Rust cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: src-tauri
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Setup signing
|
||||
env:
|
||||
KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
||||
STORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
|
||||
KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
|
||||
KEY_PASS: ${{ secrets.ANDROID_KEY_PASSWORD }}
|
||||
run: |
|
||||
echo "$KEYSTORE_B64" | base64 -d > src-tauri/gen/android/upload-keystore.jks
|
||||
{
|
||||
echo "storeFile=upload-keystore.jks"
|
||||
echo "storePassword=$STORE_PASS"
|
||||
echo "keyAlias=$KEY_ALIAS"
|
||||
echo "keyPassword=$KEY_PASS"
|
||||
} > src-tauri/gen/android/keystore.properties
|
||||
|
||||
- name: Build APK
|
||||
run: npm run tauri android build -- --apk
|
||||
|
||||
- name: Upload APK
|
||||
run: |
|
||||
for f in src-tauri/gen/android/app/build/outputs/apk/universal/release/*.apk; do
|
||||
[ -f "$f" ] || continue
|
||||
echo "Uploading $f"
|
||||
curl -s -X POST "$API/releases/${{ needs.create-release.outputs.RELEASE_ID }}/assets?name=$(basename "$f")" \
|
||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||
-F "attachment=@$f"
|
||||
done
|
||||
+2
-1
@@ -22,4 +22,5 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
*.jks
|
||||
*.jks
|
||||
keystore.base64
|
||||
@@ -15,4 +15,11 @@ This template should help get you started developing with Tauri, React and Types
|
||||
|
||||
- Check end to end behavioour
|
||||
|
||||
# TAG
|
||||
|
||||
git tag -a v1.0.0 -m "Release v1.0.0"
|
||||
git push origin v1.0.0
|
||||
git tag -d v1.0.0
|
||||
git push origin --delete v1.0.0
|
||||
|
||||
git tag -d v1.0.0;git push origin --delete v1.0.0;git tag -a v1.0.0 -m "Release v1.0.0";git push origin v1.0.0;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
import js from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
|
||||
export default tseslint.config(
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
ignores: ["node_modules/**", "dist/**", "src-tauri/target/**"],
|
||||
},
|
||||
{
|
||||
files: ["**/*.{js,jsx,ts,tsx}"],
|
||||
plugins: {
|
||||
"react-hooks": reactHooks,
|
||||
},
|
||||
rules: {
|
||||
"react-hooks/rules-of-hooks": "error",
|
||||
"react-hooks/exhaustive-deps": "warn",
|
||||
},
|
||||
}
|
||||
);
|
||||
Generated
+523
-124
File diff suppressed because it is too large
Load Diff
+9
-1
@@ -9,24 +9,32 @@
|
||||
"preview": "vite preview",
|
||||
"tauri": "tauri",
|
||||
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,css}\"",
|
||||
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,css}\""
|
||||
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,css}\"",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2",
|
||||
"@tauri-apps/plugin-opener": "^2.7.2",
|
||||
"@tauri-apps/plugin-os": "^2.4.0",
|
||||
"@tauri-apps/plugin-store": "^2.5.0",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@tauri-apps/cli": "^2",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"@vitejs/plugin-react": "^4.6.0",
|
||||
"eslint": "^10.14.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-prettier": "^5.5.6",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"prettier": "^3.9.6",
|
||||
"typescript": "~5.8.3",
|
||||
"typescript-eslint": "^8.72.1",
|
||||
"vite": "^7.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+441
-446
File diff suppressed because it is too large
Load Diff
@@ -18,9 +18,10 @@ crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2.12.4", features = [] }
|
||||
tauri = { version = "2.12.5", features = [] }
|
||||
tauri-plugin-opener = "2.7.2"
|
||||
tauri-plugin-os = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1.0.154"
|
||||
dsp_thomann = { path = "../../dsp-thomann", features = ["serialization"] }
|
||||
dsp_thomann = { git = "https://gitea.iceberg.black/LucasDLTG/dsp-thomann", features = ["serialization"] }
|
||||
tauri-plugin-store = "2"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
@@ -14,14 +13,19 @@ val tauriProperties = Properties().apply {
|
||||
}
|
||||
}
|
||||
|
||||
// Load signing credentials
|
||||
// Load signing credentials.
|
||||
// Locally: optional (debug builds and `tauri android dev` work without it).
|
||||
// In CI: mandatory, so a broken secrets setup fails loudly instead of
|
||||
// producing an unsigned APK.
|
||||
val keystoreProperties = Properties().apply {
|
||||
val keystoreFile = rootProject.file("keystore.properties")
|
||||
require(keystoreFile.exists()) {
|
||||
"Missing keystore.properties"
|
||||
if (keystoreFile.exists()) {
|
||||
keystoreFile.inputStream().use { load(it) }
|
||||
} else if (System.getenv("CI") != null) {
|
||||
error("Missing keystore.properties in CI")
|
||||
}
|
||||
keystoreFile.inputStream().use { load(it) }
|
||||
}
|
||||
val hasKeystore = keystoreProperties.containsKey("storeFile")
|
||||
|
||||
android {
|
||||
compileSdk = 36
|
||||
@@ -39,20 +43,22 @@ android {
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
val keystorePath = keystoreProperties.getProperty("storeFile")
|
||||
?: error("Missing storeFile")
|
||||
if (hasKeystore) {
|
||||
create("release") {
|
||||
val keystorePath = keystoreProperties.getProperty("storeFile")
|
||||
?: error("Missing storeFile")
|
||||
|
||||
storeFile = rootProject.file(keystorePath)
|
||||
storeFile = rootProject.file(keystorePath)
|
||||
|
||||
storePassword = keystoreProperties.getProperty("storePassword")
|
||||
?: error("Missing storePassword")
|
||||
storePassword = keystoreProperties.getProperty("storePassword")
|
||||
?: error("Missing storePassword")
|
||||
|
||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||
?: error("Missing keyAlias")
|
||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||
?: error("Missing keyAlias")
|
||||
|
||||
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||
?: error("Missing keyPassword")
|
||||
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||
?: error("Missing keyPassword")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +79,9 @@ android {
|
||||
|
||||
getByName("release") {
|
||||
isMinifyEnabled = false
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
if (hasKeystore) {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
|
||||
proguardFiles(
|
||||
*fileTree(".") { include("**/*.pro") }
|
||||
@@ -109,4 +117,4 @@ dependencies {
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
||||
}
|
||||
|
||||
apply(from = "tauri.build.gradle.kts")
|
||||
apply(from = "tauri.build.gradle.kts")
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
storeFile=../../../thomann-release.jks
|
||||
storePassword=gitgit
|
||||
keyAlias=thomann
|
||||
keyPassword=gitgit
|
||||
@@ -1,5 +1,5 @@
|
||||
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
include ':tauri-android'
|
||||
project(':tauri-android').projectDir = new File("C:\\Users\\lsdg\\.cargo\\registry\\src\\index.crates.io-1949cf8c6b5b557f\\tauri-2.12.4\\mobile\\android")
|
||||
project(':tauri-android').projectDir = new File("C:\\Users\\lsdg\\.cargo\\registry\\src\\index.crates.io-1949cf8c6b5b557f\\tauri-2.12.5\\mobile\\android")
|
||||
include ':tauri-plugin-opener'
|
||||
project(':tauri-plugin-opener').projectDir = new File("C:\\Users\\lsdg\\.cargo\\registry\\src\\index.crates.io-1949cf8c6b5b557f\\tauri-plugin-opener-2.7.2\\android")
|
||||
|
||||
@@ -69,8 +69,15 @@ pub fn create_dsp408(
|
||||
let id = *next_id;
|
||||
*next_id += 1;
|
||||
|
||||
#[cfg(mobile)]
|
||||
let mut device = DSPDevice { dsp };
|
||||
|
||||
#[cfg(not(mobile))]
|
||||
let device = DSPDevice { dsp };
|
||||
|
||||
#[cfg(mobile)]
|
||||
device.dsp.set_auto_reconnect(false);
|
||||
|
||||
let mut devices = state.devices.lock().map_err(|e| e.to_string())?;
|
||||
|
||||
devices.insert(id, Arc::new(Mutex::new(device)));
|
||||
@@ -249,6 +256,7 @@ pub async fn lock_device(
|
||||
}
|
||||
|
||||
// Command `0x30`
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[tauri::command]
|
||||
pub async fn set_compressor(
|
||||
state: State<'_, AppState>,
|
||||
@@ -303,6 +311,7 @@ pub async fn set_high_pass(
|
||||
}
|
||||
|
||||
// Command `0x33`
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[tauri::command]
|
||||
pub async fn set_peq_band(
|
||||
state: State<'_, AppState>,
|
||||
|
||||
+20
-3
@@ -4,11 +4,26 @@ mod state;
|
||||
use state::AppState;
|
||||
use tauri::Manager;
|
||||
|
||||
#[cfg(mobile)]
|
||||
fn handle_run_event(app: &tauri::AppHandle, event: &tauri::RunEvent) {
|
||||
if let tauri::RunEvent::WindowEvent {
|
||||
event: tauri::WindowEvent::Focused(false),
|
||||
..
|
||||
} = event
|
||||
{
|
||||
app.state::<AppState>().disconnect_all();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(mobile))]
|
||||
fn handle_run_event(_app: &tauri::AppHandle, _event: &tauri::RunEvent) {}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
let app = tauri::Builder::default()
|
||||
.plugin(tauri_plugin_store::Builder::new().build())
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.plugin(tauri_plugin_os::init()) // added by `tauri add os`
|
||||
.manage(AppState::new())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::create_dsp408,
|
||||
@@ -51,6 +66,8 @@ pub fn run() {
|
||||
state.shutdown();
|
||||
}
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building tauri application");
|
||||
|
||||
app.run(|app, event| handle_run_event(app, &event));
|
||||
}
|
||||
|
||||
@@ -30,4 +30,23 @@ impl AppState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(mobile)]
|
||||
pub fn disconnect_all(&self) {
|
||||
// clone the Arcs so the map lock isn't held while waiting on devices
|
||||
let devices: Vec<Arc<Mutex<DSPDevice>>> = {
|
||||
let map = self.devices.lock().unwrap_or_else(|e| e.into_inner());
|
||||
map.values().cloned().collect()
|
||||
};
|
||||
|
||||
// one thread per device so a stuck device doesn't delay the others
|
||||
for device in devices {
|
||||
std::thread::spawn(move || {
|
||||
let mut d = device.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if d.dsp.connected() {
|
||||
let _ = d.dsp.disconnect();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { stopAllPolling } from './dsp/pollRegistry';
|
||||
import { loadSavedDSPs, saveDSPs, toSaved } from './dsp/dspStorage';
|
||||
import { DSPMode } from './features/dsp408/types';
|
||||
import { useIsMobile } from './hooks/useIsMobile';
|
||||
import { useMobileBackgroundDisconnect } from './dsp/useMobileBackgroundDisconnect';
|
||||
|
||||
function App() {
|
||||
const [dsps, setDsps] = useState<DSP[]>([]);
|
||||
@@ -30,6 +31,9 @@ function App() {
|
||||
|
||||
const dspsRef = useRef(dsps);
|
||||
dspsRef.current = dsps;
|
||||
|
||||
useMobileBackgroundDisconnect(dsps, setDsps, notify); // NEW
|
||||
|
||||
useEffect(() => {
|
||||
return () => stopAllPolling(dspsRef.current);
|
||||
}, []);
|
||||
|
||||
@@ -213,7 +213,6 @@ function ChoiceSelect<T extends string>({
|
||||
latest.current = value;
|
||||
lastCommitted.current = value;
|
||||
setDisplayValue(value);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [value]);
|
||||
|
||||
// When disabled, drop any in-progress interaction, close the list and show the real value.
|
||||
@@ -232,7 +231,6 @@ function ChoiceSelect<T extends string>({
|
||||
latest.current = v;
|
||||
lastCommitted.current = v;
|
||||
setDisplayValue(v);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [disabled]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -286,7 +284,6 @@ function ChoiceSelect<T extends string>({
|
||||
window.removeEventListener('scroll', recalc, true);
|
||||
window.removeEventListener('resize', recalc);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [open]);
|
||||
|
||||
// --- wheel on the trigger ----------------------------------------------
|
||||
|
||||
@@ -288,7 +288,6 @@ function StepperCore<T>({
|
||||
lastCommitted.current = value;
|
||||
setLocalValue(value);
|
||||
setText(formatLabel(value));
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [value, formatLabel]);
|
||||
|
||||
// When disabled, drop any in-progress interaction and show the real value.
|
||||
@@ -309,7 +308,6 @@ function StepperCore<T>({
|
||||
lastCommitted.current = v;
|
||||
setLocalValue(v);
|
||||
setText(formatLabelRef.current(v));
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [disabled]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -431,6 +431,7 @@ export const LinearGraph = forwardRef<LinearGraphHandle, LinearGraphProps>(funct
|
||||
formatX,
|
||||
formatY,
|
||||
draw,
|
||||
cq.w
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -163,9 +163,16 @@ function SignalFlowMatrix({
|
||||
const commitTimers = useRef<Map<string, ReturnType<typeof setTimeout>>>(new Map());
|
||||
|
||||
useEffect(() => {
|
||||
const timers = commitTimers.current;
|
||||
const tooltipTimer = hideTooltipTimer.current;
|
||||
|
||||
return () => {
|
||||
if (hideTooltipTimer.current) clearTimeout(hideTooltipTimer.current);
|
||||
commitTimers.current.forEach(clearTimeout);
|
||||
if (tooltipTimer) {
|
||||
clearTimeout(tooltipTimer);
|
||||
}
|
||||
|
||||
timers.forEach((timer) => clearTimeout(timer));
|
||||
timers.clear();
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -222,7 +222,6 @@ export default function VerticalSlider({
|
||||
const wheelTimeout = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
if (scale === 'log' && !values && (min <= 0 || max <= 0)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
'VerticalSlider: scale="log" requires min > 0 and max > 0. Falling back to linear behavior for out-of-range bounds.'
|
||||
);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { platform } from '@tauri-apps/plugin-os';
|
||||
|
||||
export const isMobileOS: boolean = (() => {
|
||||
try {
|
||||
const p = platform();
|
||||
return p === 'android' || p === 'ios';
|
||||
} catch {
|
||||
return false; // not running inside Tauri (tests, browser dev)
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,54 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { isMobileOS } from './platform';
|
||||
import { forDSP408, setAppBackgrounded, isPolling } from '../features/dsp408/dsp408';
|
||||
import { DSP, isConnected } from '../types';
|
||||
import { SetDsps, NotifyFn } from './dspShared';
|
||||
|
||||
export function useMobileBackgroundDisconnect(
|
||||
dsps: DSP[],
|
||||
setDsps: SetDsps,
|
||||
notify: NotifyFn
|
||||
) {
|
||||
const dspsRef = useRef(dsps);
|
||||
dspsRef.current = dsps;
|
||||
|
||||
useEffect(() => {
|
||||
if (!isMobileOS) return; // desktop: nothing is registered
|
||||
|
||||
const goBackground = () => {
|
||||
setAppBackgrounded(true);
|
||||
for (const d of dspsRef.current) {
|
||||
if (d.type !== 'DSP408') continue;
|
||||
// Rust disconnect is idempotent, so no connection-state filter is needed.
|
||||
// ADJUST: skip demo-mode DSPs here if you don't want them disconnected.
|
||||
void forDSP408(d, setDsps, notify).disconnectForBackground();
|
||||
}
|
||||
};
|
||||
|
||||
const onResume = () => {
|
||||
setAppBackgrounded(false); // allows a MANUAL connect again; never reconnects
|
||||
for (const d of dspsRef.current) {
|
||||
if (d.type !== 'DSP408' || !isPolling(d.id)) continue;
|
||||
const api = forDSP408(d, setDsps, notify);
|
||||
api
|
||||
.updateDSPState()
|
||||
.then((s) => {
|
||||
if (!isConnected({ ...d, state: s } as DSP)) return api.disconnectForBackground();
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
const onVisibility = () => {
|
||||
if (document.visibilityState === 'hidden') goBackground();
|
||||
else onResume();
|
||||
};
|
||||
|
||||
document.addEventListener('visibilitychange', onVisibility);
|
||||
window.addEventListener('pagehide', goBackground);
|
||||
return () => {
|
||||
document.removeEventListener('visibilitychange', onVisibility);
|
||||
window.removeEventListener('pagehide', goBackground);
|
||||
};
|
||||
}, [setDsps, notify]);
|
||||
}
|
||||
@@ -6,7 +6,9 @@ import { sumCurvePoints, sumPhaseCurvePoints } from '../../utils/graph/curve';
|
||||
import { getPeqCurvePoints, getPeqPhasePoints } from '../../utils/graph/peq';
|
||||
import { getCrossoverCurvePoints, getCrossoverPhasePoints } from '../../utils/graph/crossover';
|
||||
import { drawCurves } from '../../utils/graph/draw';
|
||||
import LinearGraph from '../../../../components/LinearGraph/LinearGraph';
|
||||
import LinearGraph, {
|
||||
type LinearGraphHelpers,
|
||||
} from '../../../../components/LinearGraph/LinearGraph';
|
||||
|
||||
// Constant, so compute once instead of every render.
|
||||
const GRAPH_FREQS = logSpace(GRAPH_X_MIN, GRAPH_X_MAX, 1000);
|
||||
@@ -38,7 +40,7 @@ export const MagnitudeGraph = memo(function MagnitudeGraph({
|
||||
);
|
||||
|
||||
const draw = useCallback(
|
||||
({ ctx, toPx }: any) => {
|
||||
({ ctx, toPx }: LinearGraphHelpers) => {
|
||||
drawCurves({
|
||||
ctx,
|
||||
toPx,
|
||||
@@ -87,7 +89,7 @@ export const PhaseGraph = memo(function PhaseGraph({
|
||||
);
|
||||
|
||||
const draw = useCallback(
|
||||
({ ctx, toPx }: any) => {
|
||||
({ ctx, toPx }: LinearGraphHelpers) => {
|
||||
drawCurves({
|
||||
ctx,
|
||||
toPx,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { memo, useCallback, useMemo } from 'react';
|
||||
import { Ratio } from '../../types';
|
||||
import { RATIO_NUMERIC } from '../../constants';
|
||||
import LinearGraph from '../../../../components/LinearGraph/LinearGraph';
|
||||
import LinearGraph, {
|
||||
type LinearGraphHelpers,
|
||||
} from '../../../../components/LinearGraph/LinearGraph';
|
||||
|
||||
const formatTick = (v: number) => Math.round(v).toString();
|
||||
|
||||
@@ -66,7 +68,7 @@ export const CompressorGraph = memo(function CompressorGraph({
|
||||
}, [threshold, ratio, knee]);
|
||||
|
||||
const draw = useCallback(
|
||||
({ ctx, toPx }: any) => {
|
||||
({ ctx, toPx }: LinearGraphHelpers) => {
|
||||
// Unity reference line
|
||||
ctx.strokeStyle = '#6b7280';
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { memo, useCallback, useMemo } from 'react';
|
||||
import { DelayUnit } from '../../types';
|
||||
import { DELAY_RANGES } from '../../constants';
|
||||
import LinearGraph from '../../../../components/LinearGraph/LinearGraph';
|
||||
import { DELAY_UNIT_LABEL } from '../../constants';
|
||||
import LinearGraph, {
|
||||
type LinearGraphHelpers,
|
||||
} from '../../../../components/LinearGraph/LinearGraph';
|
||||
|
||||
const formatY = (v: number) => v.toFixed(0);
|
||||
|
||||
@@ -34,7 +36,7 @@ export const DelayGraph = memo(
|
||||
const formatX = useCallback((v: number) => labelByX.get(Math.round(v)) ?? '', [labelByX]);
|
||||
|
||||
const draw = useCallback(
|
||||
({ ctx, toPx, plot }: any) => {
|
||||
({ ctx, toPx, plot }: LinearGraphHelpers) => {
|
||||
const barWidth = (plot.width / rows.length) * 0.55;
|
||||
|
||||
rows.forEach((row, i) => {
|
||||
|
||||
@@ -2,7 +2,9 @@ import { memo, useCallback, useMemo } from 'react';
|
||||
import { GRAPH_FREQS, GRAPH_X_MAX, GRAPH_X_MIN, GRAPH_Y_MIN, Y_AXIS_STEP } from '../../constants';
|
||||
import { Curve, CurvePoint } from '../../utils/graph/curve';
|
||||
import { drawCurves } from '../../utils/graph/draw';
|
||||
import LinearGraph from '../../../../components/LinearGraph/LinearGraph';
|
||||
import LinearGraph, {
|
||||
type LinearGraphHelpers,
|
||||
} from '../../../../components/LinearGraph/LinearGraph';
|
||||
|
||||
// Expands [baseMin, baseMax] outward to fit whatever the curves actually
|
||||
// contain (e.g. gain + geq + peq stacking past the nominal graph range),
|
||||
@@ -115,7 +117,7 @@ function ResponseGraphInner<T extends string, S>({
|
||||
);
|
||||
|
||||
const draw = useCallback(
|
||||
({ ctx, toPx }: any) => {
|
||||
({ ctx, toPx }: LinearGraphHelpers) => {
|
||||
drawCurves({ ctx, toPx, xMin: GRAPH_X_MIN, xMax: GRAPH_X_MAX, yMin, yMax, curves });
|
||||
},
|
||||
[curves, yMin, yMax]
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { memo, useCallback, useMemo } from 'react';
|
||||
import LinearGraph from '../../../../components/LinearGraph/LinearGraph';
|
||||
import LinearGraph, {
|
||||
type LinearGraphHelpers,
|
||||
} from '../../../../components/LinearGraph/LinearGraph';
|
||||
|
||||
const formatTick = (v: number) => Math.round(v).toString();
|
||||
|
||||
@@ -25,7 +27,7 @@ export const GateGraph = memo(function GateGraph({
|
||||
}, [attack, hold, release]);
|
||||
|
||||
const draw = useCallback(
|
||||
({ toPx, ctx }: any) => {
|
||||
({ ctx, toPx }: LinearGraphHelpers) => {
|
||||
const { t0, t1, t2, t3, t4, t5 } = envelope;
|
||||
|
||||
ctx.strokeStyle = '#fbbf24';
|
||||
|
||||
@@ -4,9 +4,11 @@ import { drawCurves } from '../../utils/graph/draw';
|
||||
import { GRAPH_X_MIN, GRAPH_X_MAX, GRAPH_Y_MIN, GRAPH_Y_MAX, GEQ_CURVE_Q } from '../../constants';
|
||||
import { DiscreteFrequency } from '../../types';
|
||||
import { GEQ_BANDS_LABEL } from '../../constants';
|
||||
import LinearGraph from '../../../../components/LinearGraph/LinearGraph';
|
||||
import { getGeqCurvePoints } from '../../utils/graph/geq';
|
||||
import { LiveBands } from './GeqSection';
|
||||
import LinearGraph, {
|
||||
type LinearGraphHelpers,
|
||||
} from '../../../../components/LinearGraph/LinearGraph';
|
||||
|
||||
const GEQ_FREQS = logSpace(GRAPH_X_MIN, GRAPH_X_MAX, 1000);
|
||||
|
||||
@@ -29,7 +31,7 @@ export const GeqGraph = memo(function GeqGraph({
|
||||
}, [gains, liveBands]);
|
||||
|
||||
const draw = useCallback(
|
||||
({ ctx, toPx }: any) => {
|
||||
({ ctx, toPx }: LinearGraphHelpers) => {
|
||||
drawCurves({
|
||||
ctx,
|
||||
toPx,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { memo, useCallback, useMemo } from 'react';
|
||||
import LinearGraph from '../../../../components/LinearGraph/LinearGraph';
|
||||
import LinearGraph, {
|
||||
type LinearGraphHelpers,
|
||||
} from '../../../../components/LinearGraph/LinearGraph';
|
||||
|
||||
const formatTick = (v: number) => Math.round(v).toString();
|
||||
|
||||
@@ -20,7 +22,7 @@ export const LimiterGraph = memo(function LimiterGraph({ threshold }: { threshol
|
||||
}, [threshold]);
|
||||
|
||||
const draw = useCallback(
|
||||
({ ctx, toPx }: any) => {
|
||||
({ ctx, toPx }: LinearGraphHelpers) => {
|
||||
// Unity reference line
|
||||
ctx.strokeStyle = '#6b7280';
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
@@ -93,8 +93,9 @@ function MatrixSection({
|
||||
setLiveGains((prev) => {
|
||||
if (value === null) {
|
||||
if (!(key in prev)) return prev;
|
||||
const { [key]: _removed, ...rest } = prev;
|
||||
return rest;
|
||||
return Object.fromEntries(
|
||||
Object.entries(prev).filter(([k]) => k !== key)
|
||||
);
|
||||
}
|
||||
return { ...prev, [key]: value };
|
||||
});
|
||||
|
||||
@@ -235,7 +235,6 @@ function LinkChannelsModal({
|
||||
];
|
||||
|
||||
for (const group of groups) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await linkChannels(group.source, group.destinations);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,16 @@ export function stopPolling(id: number) {
|
||||
|
||||
registerPollStopper('DSP408', stopPolling);
|
||||
|
||||
// --- background state, private to this module --------------------------
|
||||
let appBackgrounded = false;
|
||||
export function setAppBackgrounded(v: boolean) {
|
||||
appBackgrounded = v;
|
||||
}
|
||||
|
||||
export function isPolling(id: number): boolean {
|
||||
return pollIntervals.has(id);
|
||||
}
|
||||
|
||||
// --- pause helper ----------------------------------------------------------
|
||||
|
||||
async function withPollingPaused<T>(
|
||||
@@ -141,6 +151,30 @@ export function forDSP408(dsp: DSP408, setDsps: SetDsps, notify: NotifyFn) {
|
||||
}
|
||||
}
|
||||
|
||||
async function disconnectForBackground() {
|
||||
// synchronous part first: the webview may be frozen right after this
|
||||
stopPolling(dsp.id);
|
||||
updateDSP(setDsps, dsp.id, (d) => ({
|
||||
...d,
|
||||
isConnecting: false,
|
||||
pollingPaused: true,
|
||||
}));
|
||||
|
||||
try {
|
||||
await invoke('disconnect_dsp408', { id: dsp.id });
|
||||
} catch {
|
||||
// socket may already be gone; Rust-side fallback covers the rest
|
||||
}
|
||||
|
||||
// quiet state refresh (no error toast while backgrounded)
|
||||
try {
|
||||
const state = await invoke<DSP408['state']>('get_dsp_state', { id: dsp.id });
|
||||
updateDSP(setDsps, dsp.id, (d) => ({ ...d, state }) as DSP408);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
const isLocked = (s: DSP408['state']) => s.flags.is_locked;
|
||||
|
||||
async function abortLocked() {
|
||||
@@ -155,6 +189,11 @@ export function forDSP408(dsp: DSP408, setDsps: SetDsps, notify: NotifyFn) {
|
||||
try {
|
||||
await invoke('connect_dsp408', { id: dsp.id });
|
||||
|
||||
if (appBackgrounded) { // NEW: backgrounded mid-connect
|
||||
await disconnectForBackground();
|
||||
return;
|
||||
}
|
||||
|
||||
let state = await updateDSPState();
|
||||
|
||||
if (isLocked(state)) {
|
||||
@@ -174,6 +213,11 @@ export function forDSP408(dsp: DSP408, setDsps: SetDsps, notify: NotifyFn) {
|
||||
}
|
||||
}
|
||||
|
||||
if (appBackgrounded) {
|
||||
await disconnectForBackground();
|
||||
return;
|
||||
}
|
||||
|
||||
updateDSP(setDsps, dsp.id, (d) => ({ ...d, isConnecting: false, pollingPaused: false }));
|
||||
notify('Connected', 'success', dsp.name);
|
||||
startPolling(dsp, setDsps);
|
||||
@@ -939,5 +983,7 @@ export function forDSP408(dsp: DSP408, setDsps: SetDsps, notify: NotifyFn) {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
disconnectForBackground,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
|
||||
import { useEffect, useId, useRef, useState } from 'react';
|
||||
import { useIsTouch } from './useIsTouch';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
VolumeBridge?: {
|
||||
setIntercept: (on: boolean) => void;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/** The control that currently owns the hardware volume buttons. */
|
||||
let activeId: string | null = null;
|
||||
|
||||
function setNativeIntercept(on: boolean) {
|
||||
(window as any).VolumeBridge?.setIntercept(on);
|
||||
window.VolumeBridge?.setIntercept(on);
|
||||
}
|
||||
|
||||
type Options = {
|
||||
@@ -25,6 +34,7 @@ export function useVolumeKeys({ rootRef, onStep, disabled }: Options) {
|
||||
|
||||
function select() {
|
||||
if (!isMobile || disabled) return;
|
||||
|
||||
activeId = id;
|
||||
setNativeIntercept(true);
|
||||
setSelected(true);
|
||||
@@ -32,6 +42,7 @@ export function useVolumeKeys({ rootRef, onStep, disabled }: Options) {
|
||||
|
||||
function deselect() {
|
||||
setSelected(false);
|
||||
|
||||
if (activeId === id) {
|
||||
activeId = null;
|
||||
setNativeIntercept(false);
|
||||
@@ -57,16 +68,23 @@ export function useVolumeKeys({ rootRef, onStep, disabled }: Options) {
|
||||
// Release when tapping outside
|
||||
useEffect(() => {
|
||||
if (!isMobile) return;
|
||||
|
||||
const onDown = (e: PointerEvent) => {
|
||||
if (rootRef.current?.contains(e.target as Node)) return;
|
||||
|
||||
setSelected(false);
|
||||
|
||||
if (activeId === id) {
|
||||
activeId = null;
|
||||
setNativeIntercept(false);
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('pointerdown', onDown, true);
|
||||
return () => document.removeEventListener('pointerdown', onDown, true);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('pointerdown', onDown, true);
|
||||
};
|
||||
}, [isMobile, id, rootRef]);
|
||||
|
||||
// Volume events from the native bridge
|
||||
@@ -76,17 +94,23 @@ export function useVolumeKeys({ rootRef, onStep, disabled }: Options) {
|
||||
const onUp = () => {
|
||||
if (activeId === id) onStepRef.current(1);
|
||||
};
|
||||
|
||||
const onDown = () => {
|
||||
if (activeId === id) onStepRef.current(-1);
|
||||
};
|
||||
|
||||
document.addEventListener('volumeupbutton', onUp);
|
||||
document.addEventListener('volumedownbutton', onDown);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('volumeupbutton', onUp);
|
||||
document.removeEventListener('volumedownbutton', onDown);
|
||||
};
|
||||
}, [isMobile, disabled, id]);
|
||||
|
||||
return { isSelected: isMobile && selected, select, deselect };
|
||||
}
|
||||
return {
|
||||
isSelected: isMobile && selected,
|
||||
select,
|
||||
deselect,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ function SettingsPage({
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
}, [onNotificationsDisabledChange]);
|
||||
|
||||
async function updateSetting<K extends keyof AppSettings>(
|
||||
key: K,
|
||||
|
||||
Reference in New Issue
Block a user