Bundle a managed, loopback-only Navidrome sidecar with verified release preparation, native source setup, lifecycle controls, licensing, and a polished charcoal/onyx visual system
Hop-State: A_06FNDXP543RHZ4436GTD01G Hop-Proposal: R_06FNDXNBVJNF9Q2KMKT0ASR Hop-Task: T_06FNDRZ9CM02JWJ98SRNFNR Hop-Attempt: AT_06FNDRZ9CNGSWJSFVV54DR8
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getManagedServerStatus, isDesktopRuntime } from "./managedServer";
|
||||
|
||||
describe("managed server bridge", () => {
|
||||
it("reports the browser preview as a non-desktop runtime", () => {
|
||||
expect(isDesktopRuntime()).toBe(false);
|
||||
});
|
||||
|
||||
it("returns a stopped preview status without invoking Tauri", async () => {
|
||||
await expect(getManagedServerStatus()).resolves.toMatchObject({
|
||||
running: false,
|
||||
url: "http://127.0.0.1:4533",
|
||||
version: "0.61.2",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { open } from "@tauri-apps/plugin-dialog";
|
||||
|
||||
export interface ManagedServerStatus {
|
||||
running: boolean;
|
||||
url: string;
|
||||
musicFolder?: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
export function isDesktopRuntime(): boolean {
|
||||
return typeof window !== "undefined" && "__TAURI_INTERNALS__" in window;
|
||||
}
|
||||
|
||||
export async function chooseMusicFolder(): Promise<string | null> {
|
||||
if (!isDesktopRuntime()) return null;
|
||||
const selection = await open({
|
||||
directory: true,
|
||||
multiple: false,
|
||||
title: "Choose your music folder",
|
||||
});
|
||||
return typeof selection === "string" ? selection : null;
|
||||
}
|
||||
|
||||
export async function getManagedServerStatus(): Promise<ManagedServerStatus> {
|
||||
if (!isDesktopRuntime()) {
|
||||
return { running: false, url: "http://127.0.0.1:4533", version: "0.61.2" };
|
||||
}
|
||||
return invoke<ManagedServerStatus>("managed_server_status");
|
||||
}
|
||||
|
||||
export async function startManagedServer(musicFolder: string, password: string): Promise<ManagedServerStatus> {
|
||||
if (!isDesktopRuntime()) throw new Error("The managed library is available in the Resonant desktop app.");
|
||||
return invoke<ManagedServerStatus>("start_managed_server", { musicFolder, password });
|
||||
}
|
||||
|
||||
export async function stopManagedServer(): Promise<ManagedServerStatus> {
|
||||
if (!isDesktopRuntime()) throw new Error("The managed library is available in the Resonant desktop app.");
|
||||
return invoke<ManagedServerStatus>("stop_managed_server");
|
||||
}
|
||||
Reference in New Issue
Block a user