feat: new demo api

This commit is contained in:
2026-10-24 11:37:27 +02:00
parent ef338cc088
commit 8f1f221605
12 changed files with 124 additions and 30 deletions
+18 -8
View File
@@ -9,7 +9,8 @@
"version": "0.1.0",
"dependencies": {
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2",
"@tauri-apps/plugin-opener": "^2.7.2",
"@tauri-apps/plugin-store": "^2.5.0",
"react": "^19.2.8",
"react-dom": "^19.2.8"
},
@@ -1356,9 +1357,9 @@
]
},
"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==",
"version": "2.12.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-2.12.4.tgz",
"integrity": "sha512-pVmfis+4zT8H0Qhp3xPZx9Ju7kpzvA6rr/PSJPyuwfvucTQ8sVt61NYU9KMkK703UFlYadFmjKA4HhybOtN0gg==",
"license": "Apache-2.0 OR MIT",
"funding": {
"type": "opencollective",
@@ -1583,12 +1584,21 @@
}
},
"node_modules/@tauri-apps/plugin-opener": {
"version": "2.5.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-opener/-/plugin-opener-2.5.4.tgz",
"integrity": "sha512-1HnPkb+AmgO29HBazm4uPLKB+r7zzcTBW1d0fyYp1uP+jwtpoiNDGKMMzz58SFp49nOIrxdE3aUJtT57lfO9CQ==",
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-opener/-/plugin-opener-2.7.2.tgz",
"integrity": "sha512-LyybP1VSzTMQiaFYcsbAse47KpivlyXdLZMQzGLEnkgQacGESnpjAfFoQ6h5sqWgAdZDH9szYjPzHMpv0Sz+TQ==",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@tauri-apps/api": "^2.11.0"
"@tauri-apps/api": "^2.12.0"
}
},
"node_modules/@tauri-apps/plugin-store": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-store/-/plugin-store-2.5.0.tgz",
"integrity": "sha512-+ykjiQwMJCSk/U2enHA8peKBWgDKgrP7JfZnGwQpqzwA0nVtKTc0LCyxWr2whOrcQoQqtUdr9NVdDZpfKpT1Xw==",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@tauri-apps/api": "^2.12.0"
}
},
"node_modules/@types/babel__core": {
+2 -1
View File
@@ -13,7 +13,8 @@
},
"dependencies": {
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2",
"@tauri-apps/plugin-opener": "^2.7.2",
"@tauri-apps/plugin-store": "^2.5.0",
"react": "^19.2.8",
"react-dom": "^19.2.8"
},
+12
View File
@@ -0,0 +1,12 @@
changed 1 package, and audited 148 packages in 1s
32 packages are looking for funding
run `npm fund` for details
3 high severity vulnerabilities
To address all issues, run:
npm audit fix
Run `npm audit` for details.
+29
View File
@@ -3585,6 +3585,22 @@ dependencies = [
"zbus",
]
[[package]]
name = "tauri-plugin-store"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3c6fdaac41e60f2313a440fa1776f3a5fdd16800ff967915e9800985b680822"
dependencies = [
"dunce",
"serde",
"serde_json",
"tauri",
"tauri-plugin",
"thiserror 2.0.21",
"tokio",
"tracing",
]
[[package]]
name = "tauri-runtime"
version = "2.12.2"
@@ -3757,6 +3773,7 @@ dependencies = [
"tauri",
"tauri-build",
"tauri-plugin-opener",
"tauri-plugin-store",
]
[[package]]
@@ -3825,9 +3842,21 @@ dependencies = [
"mio",
"pin-project-lite",
"socket2",
"tokio-macros",
"windows-sys 0.61.2",
]
[[package]]
name = "tokio-macros"
version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.6",
]
[[package]]
name = "tokio-util"
version = "0.7.18"
+1
View File
@@ -23,3 +23,4 @@ tauri-plugin-opener = "2.7.2"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0.154"
dsp_thomann = { path = "../../dsp-thomann", features = ["serialization"] }
tauri-plugin-store = "2"
+5 -2
View File
@@ -2,9 +2,12 @@
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"windows": [
"main"
],
"permissions": [
"core:default",
"opener:default"
"opener:default",
"store:default"
]
}
+4 -7
View File
@@ -1,5 +1,5 @@
use crate::state::{AppState, DSPDevice};
use dsp_thomann::dsp408::types::DelayUnit;
use dsp_thomann::dsp408::types::{DSPMode, DelayUnit};
use dsp_thomann::dsp408::{types, DSP408};
use std::sync::{Arc, Mutex};
use std::{net::IpAddr, str::FromStr};
@@ -54,11 +54,11 @@ pub fn create_dsp408(
ip: String,
port: u16,
device_id: u8,
demo: bool,
demo: DSPMode,
) -> Result<u64, String> {
let ip = IpAddr::from_str(&ip).map_err(|e| e.to_string())?;
let dsp = if demo {
let dsp = if matches!(demo, DSPMode::Demo) {
DSP408::new_demo()
} else {
DSP408::new(ip, port, device_id).map_err(|e| e.to_string())?
@@ -244,10 +244,7 @@ pub async fn lock_device(
password: String,
) -> Result<bool, String> {
state.with_device_mut(id, |device| {
device
.dsp
.lock_device(&password)
.map_err(|e| e.to_string())
device.dsp.lock_device(&password).map_err(|e| e.to_string())
})
}
+1
View File
@@ -7,6 +7,7 @@ use tauri::Manager;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_store::Builder::new().build())
.plugin(tauri_plugin_opener::init())
.manage(AppState::new())
.invoke_handler(tauri::generate_handler![
+2 -1
View File
@@ -11,6 +11,7 @@ import HomePage from './pages/HomePage/HomePage';
import { addDSP, createDSPInstance } from './dsp/dspApi';
import { removeDSP } from './dsp/dspShared';
import { stopAllPolling } from './dsp/pollRegistry';
import { DSPMode } from './features/dsp408/types';
function App() {
const [dsps, setDsps] = useState<DSP[]>([]);
@@ -66,7 +67,7 @@ function App() {
) : page === 'add-dsp' ? (
<AddDSPForm
onCancel={() => setPage('home')}
onAdd={(params) => addDSP(setDsps, setSelected, setPage, notify, params)}
onAdd={(params) => addDSP(setDsps, setSelected, setPage, notify, {...params, demo: params.demo ? DSPMode.Demo : DSPMode.Normal} )}
/>
) : activeInstance ? (
<DSPPage instance={activeInstance} />
+2 -1
View File
@@ -2,6 +2,7 @@ import { DSP, DSPTypes, AppPage } from '../types';
import { SetDsps, NotifyFn } from './dspShared';
import { forDSP408, create as createDSP408 } from '../features/dsp408/dsp408';
import { DSP408Api } from '../features/dsp408/dsp408';
import { DSPMode } from '../features/dsp408/types';
// import { forDSP204 } from './dsp204';
export type DSPInstance = { dsp: Extract<DSP, { type: 'DSP408' }>; api: DSP408Api };
@@ -27,7 +28,7 @@ export async function addDSP(
ip: string;
port: number;
deviceId: number;
demo: boolean;
demo: DSPMode;
}
) {
try {
+38
View File
@@ -0,0 +1,38 @@
// src/dsp/dspStorage.ts
import { load, Store } from '@tauri-apps/plugin-store';
import { DSP, DSPTypes } from '../types';
import { DSPMode } from '../features/dsp408/types';
export type SavedDSP = {
id: number;
type: DSPTypes;
name: string;
ip: string;
port: number;
deviceId: number;
mode: DSPMode;
};
let storePromise: Promise<Store> | null = null;
const getStore = () => (storePromise ??= load('dsps.json', { autoSave: false }));
export const toSaved = (d: DSP): SavedDSP => ({
id: d.id,
type: d.type,
name: d.name,
ip: d.ip,
port: d.port,
deviceId: d.deviceId,
mode: d.mode,
});
export async function loadSavedDSPs(): Promise<SavedDSP[]> {
const store = await getStore();
return (await store.get<SavedDSP[]>('dsps')) ?? [];
}
export async function saveDSPs(dsps: DSP[]): Promise<void> {
const store = await getStore();
await store.set('dsps', dsps.map(toSaved));
await store.save();
}
+1 -1
View File
@@ -100,7 +100,7 @@ export async function create(params: {
ip: string;
port: number;
deviceId: number;
demo: boolean;
demo: DSPMode;
}): Promise<DSP408> {
const id = await invoke<number>('create_dsp408', {
ip: params.ip,