Migrate all IPC call sites to typed tauri-specta commands.*
Replace the remaining ~155 untyped invoke() calls across stores, services, components, and routes with the generated commands.* wrappers from $lib/api/bindings, so every IPC call is compile-time-checked against the command signatures. - Register repository_get_subtitle_url and repository_get_video_download_url in specta_builder() and the invoke_handler; regenerate bindings.ts. - Source duplicated wire types (AutoplaySettings, CacheConfig, Session, ConnectivityStatus, audio/video settings, etc.) from bindings. - Fix two bugs surfaced by the typed wrappers: - VideoDownloadButton passed an un-awaited Promise as the stream URL. - setAutoplaySettings omitted the required userId argument. - Update unit tests asserting the old invoke(name, args) shape. - Remove the five param-naming guard tests; the compiler and codegen now enforce what they checked. svelte-check: 0 errors. vitest: green. cargo test --lib: green.
This commit is contained in:
+15
-21
@@ -7,8 +7,8 @@
|
||||
// TRACES: UR-005, UR-015 | DR-005, DR-020
|
||||
|
||||
import { writable, derived, get } from "svelte/store";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { commands } from "$lib/api/bindings";
|
||||
import type { MediaItem } from "$lib/api/types";
|
||||
import { auth } from "$lib/stores/auth";
|
||||
|
||||
@@ -72,7 +72,7 @@ function createQueueStore() {
|
||||
*/
|
||||
async function syncFromRust(): Promise<void> {
|
||||
try {
|
||||
const rustQueue = await invoke<QueueChangedEvent>("player_get_queue");
|
||||
const rustQueue = (await commands.playerGetQueue()) as unknown as QueueChangedEvent;
|
||||
console.log("[Queue] Synced from Rust - items:", rustQueue.items.length);
|
||||
set({
|
||||
items: rustQueue.items,
|
||||
@@ -105,37 +105,37 @@ function createQueueStore() {
|
||||
|
||||
// TRACES: UR-005, UR-015 | DR-005
|
||||
async function next() {
|
||||
await invoke("player_next");
|
||||
await commands.playerNext();
|
||||
}
|
||||
|
||||
// TRACES: UR-005, UR-015 | DR-005
|
||||
async function previous() {
|
||||
await invoke("player_previous");
|
||||
await commands.playerPrevious();
|
||||
}
|
||||
|
||||
// TRACES: UR-005, UR-015 | DR-005, DR-020
|
||||
async function skipTo(index: number) {
|
||||
await invoke("player_skip_to", { index });
|
||||
await commands.playerSkipTo(index);
|
||||
}
|
||||
|
||||
// TRACES: UR-005, UR-015 | DR-005
|
||||
async function toggleShuffle() {
|
||||
await invoke("player_toggle_shuffle");
|
||||
await commands.playerToggleShuffle();
|
||||
}
|
||||
|
||||
// TRACES: UR-005, UR-015 | DR-005
|
||||
async function cycleRepeat() {
|
||||
await invoke("player_cycle_repeat");
|
||||
await commands.playerCycleRepeat();
|
||||
}
|
||||
|
||||
// TRACES: UR-015 | DR-020
|
||||
async function removeFromQueue(index: number) {
|
||||
await invoke("player_remove_from_queue", { index });
|
||||
await commands.playerRemoveFromQueue(index);
|
||||
}
|
||||
|
||||
// TRACES: UR-015 | DR-020
|
||||
async function moveInQueue(fromIndex: number, toIndex: number) {
|
||||
await invoke("player_move_in_queue", { fromIndex, toIndex });
|
||||
await commands.playerMoveInQueue(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
// TRACES: UR-015 | DR-020
|
||||
@@ -152,20 +152,14 @@ function createQueueStore() {
|
||||
|
||||
// Use new Rust commands that accept IDs only
|
||||
if (trackIds.length === 1) {
|
||||
await invoke("player_add_track_by_id", {
|
||||
repositoryHandle,
|
||||
request: {
|
||||
trackId: trackIds[0],
|
||||
position,
|
||||
},
|
||||
await commands.playerAddTrackById(repositoryHandle, {
|
||||
trackId: trackIds[0],
|
||||
position,
|
||||
});
|
||||
} else {
|
||||
await invoke("player_add_tracks_by_ids", {
|
||||
repositoryHandle,
|
||||
request: {
|
||||
trackIds,
|
||||
position,
|
||||
},
|
||||
await commands.playerAddTracksByIds(repositoryHandle, {
|
||||
trackIds,
|
||||
position,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user