chore(format): run prettier over src/ and scripts/
Formatting was configured but never enforced: `bun run format:check` reported 199 unformatted files and ran in no workflow and in no git hook, so .prettierrc (printWidth 100, trailing commas) described an intention rather than the tree. This is the one-time sweep that makes the check gateable. Whitespace and token-reflow only -- no behavioural change: `bun run check` reports 0 errors and all 1053 frontend tests pass before and after. Kept out of every other commit on purpose. A 199-file diff mixed with real changes is unreviewable, and the next commit turns format:check into a hard CI gate so this cannot silently accumulate again.
This commit is contained in:
@@ -112,9 +112,7 @@ describe("autoplay API", () => {
|
||||
|
||||
await setAutoplaySettings(settings);
|
||||
|
||||
const call = invokeSpy.mock.calls.find(
|
||||
(c) => c[0] === "player_set_autoplay_settings"
|
||||
);
|
||||
const call = invokeSpy.mock.calls.find((c) => c[0] === "player_set_autoplay_settings");
|
||||
expect(call).toBeDefined();
|
||||
expect(call![1]).toEqual({ userId: "user-1", settings });
|
||||
});
|
||||
@@ -155,9 +153,7 @@ describe("autoplay API", () => {
|
||||
const { invoke } = await import("@tauri-apps/api/core");
|
||||
const invokeSpy = vi.mocked(invoke);
|
||||
|
||||
const call = invokeSpy.mock.calls.find(
|
||||
(c) => c[0] === "player_play_next_episode"
|
||||
);
|
||||
const call = invokeSpy.mock.calls.find((c) => c[0] === "player_play_next_episode");
|
||||
expect(call).toBeDefined();
|
||||
expect(call![1]).toEqual({ item: mockItem });
|
||||
});
|
||||
|
||||
@@ -14,9 +14,7 @@ export async function getAutoplaySettings(): Promise<AutoplaySettings> {
|
||||
return commands.playerGetAutoplaySettings();
|
||||
}
|
||||
|
||||
export async function setAutoplaySettings(
|
||||
settings: AutoplaySettings
|
||||
): Promise<AutoplaySettings> {
|
||||
export async function setAutoplaySettings(settings: AutoplaySettings): Promise<AutoplaySettings> {
|
||||
return commands.playerSetAutoplaySettings(auth.getUserId() ?? "", settings);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
options: expect.objectContaining({
|
||||
sortBy: sortField,
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -99,7 +99,7 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
options: expect.objectContaining({
|
||||
sortOrder: "Descending",
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -148,7 +148,7 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
options: expect.objectContaining({
|
||||
includeItemTypes: ["Audio", "MusicAlbum"],
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -168,7 +168,7 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
options: expect.objectContaining({
|
||||
genres: ["Rock", "Jazz"],
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -195,7 +195,7 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
"repository_search",
|
||||
expect.objectContaining({
|
||||
query: "query",
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -217,7 +217,7 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
startIndex: 100,
|
||||
limit: 50,
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -238,7 +238,7 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
"repository_search",
|
||||
expect.objectContaining({
|
||||
query: "query",
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result.items.length).toBe(2);
|
||||
@@ -260,7 +260,7 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
options: expect.objectContaining({
|
||||
includeItemTypes: ["Audio"],
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -302,7 +302,7 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
expect.objectContaining({
|
||||
itemId: "item123",
|
||||
imageType: "Primary",
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -327,23 +327,18 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
const url = await client.getVideoStreamUrl("item123");
|
||||
|
||||
expect(url).toBe(backendUrl);
|
||||
expect(invoke).toHaveBeenCalledWith(
|
||||
"repository_get_video_stream_url",
|
||||
expect.any(Object)
|
||||
);
|
||||
expect(invoke).toHaveBeenCalledWith("repository_get_video_stream_url", expect.any(Object));
|
||||
});
|
||||
|
||||
it("should get subtitle URLs from backend", async () => {
|
||||
const backendUrl = "https://server.com/Videos/item123/Subtitles/0/subtitles.vtt?api_key=token";
|
||||
const backendUrl =
|
||||
"https://server.com/Videos/item123/Subtitles/0/subtitles.vtt?api_key=token";
|
||||
(invoke as any).mockResolvedValueOnce(backendUrl);
|
||||
|
||||
const url = await client.getSubtitleUrl("item123", "source456", 0);
|
||||
|
||||
expect(url).toBe(backendUrl);
|
||||
expect(invoke).toHaveBeenCalledWith(
|
||||
"repository_get_subtitle_url",
|
||||
expect.any(Object)
|
||||
);
|
||||
expect(invoke).toHaveBeenCalledWith("repository_get_subtitle_url", expect.any(Object));
|
||||
});
|
||||
|
||||
it("should get video download URLs from backend", async () => {
|
||||
@@ -353,10 +348,7 @@ describe("Backend Integration - Refactored Business Logic", () => {
|
||||
const url = await client.getVideoDownloadUrl("item123", "medium");
|
||||
|
||||
expect(url).toBe(backendUrl);
|
||||
expect(invoke).toHaveBeenCalledWith(
|
||||
"repository_get_video_download_url",
|
||||
expect.any(Object)
|
||||
);
|
||||
expect(invoke).toHaveBeenCalledWith("repository_get_video_download_url", expect.any(Object));
|
||||
});
|
||||
|
||||
it("should never expose access token in frontend code", async () => {
|
||||
|
||||
@@ -96,7 +96,8 @@ describe("RepositoryClient", () => {
|
||||
});
|
||||
|
||||
it("should pass multiple image options to backend", async () => {
|
||||
const mockUrl = "https://server.com/Items/item123/Images/Backdrop?maxWidth=1920&maxHeight=1080&quality=90&api_key=token";
|
||||
const mockUrl =
|
||||
"https://server.com/Items/item123/Images/Backdrop?maxWidth=1920&maxHeight=1080&quality=90&api_key=token";
|
||||
(invoke as any).mockResolvedValueOnce(mockUrl);
|
||||
|
||||
const options = {
|
||||
@@ -133,9 +134,7 @@ describe("RepositoryClient", () => {
|
||||
it("should throw error if not initialized before getImageUrl", async () => {
|
||||
const newClient = new RepositoryClient();
|
||||
|
||||
await expect(newClient.getImageUrl("item123")).rejects.toThrow(
|
||||
"Repository not initialized"
|
||||
);
|
||||
await expect(newClient.getImageUrl("item123")).rejects.toThrow("Repository not initialized");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -243,7 +242,7 @@ describe("RepositoryClient", () => {
|
||||
"repository_get_video_download_url",
|
||||
expect.objectContaining({
|
||||
quality,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -314,9 +313,7 @@ describe("RepositoryClient", () => {
|
||||
|
||||
it("should search with backend search command", async () => {
|
||||
const mockResult = {
|
||||
items: [
|
||||
{ id: "item1", name: "Search Result 1", type: "Audio" },
|
||||
],
|
||||
items: [{ id: "item1", name: "Search Result 1", type: "Audio" }],
|
||||
totalRecordCount: 1,
|
||||
};
|
||||
(invoke as any).mockResolvedValueOnce(mockResult);
|
||||
@@ -353,7 +350,10 @@ describe("RepositoryClient", () => {
|
||||
});
|
||||
|
||||
it("should get downloaded items with camelCase params", async () => {
|
||||
const mockResult = { items: [{ id: "t1", name: "Track", type: "Audio" }], totalRecordCount: 1 };
|
||||
const mockResult = {
|
||||
items: [{ id: "t1", name: "Track", type: "Audio" }],
|
||||
totalRecordCount: 1,
|
||||
};
|
||||
(invoke as any).mockResolvedValueOnce(mockResult);
|
||||
|
||||
const result = await client.getDownloadedItems("album1", { limit: 50 });
|
||||
@@ -367,7 +367,12 @@ describe("RepositoryClient", () => {
|
||||
});
|
||||
|
||||
it("should get download disk usage from backend", async () => {
|
||||
const mockUsage = { sizes: { t1: 1000 }, partialContainers: {}, deviceTotalBytes: 1000, itemCount: 1 };
|
||||
const mockUsage = {
|
||||
sizes: { t1: 1000 },
|
||||
partialContainers: {},
|
||||
deviceTotalBytes: 1000,
|
||||
itemCount: 1,
|
||||
};
|
||||
(invoke as any).mockResolvedValueOnce(mockUsage);
|
||||
|
||||
const usage = await client.getDownloadDiskUsage();
|
||||
@@ -589,7 +594,9 @@ describe("RepositoryClient", () => {
|
||||
|
||||
it("should throw error if not initialized before playlist operations", async () => {
|
||||
const newClient = new RepositoryClient();
|
||||
await expect(newClient.getPlaylistItems("pl-1")).rejects.toThrow("Repository not initialized");
|
||||
await expect(newClient.getPlaylistItems("pl-1")).rejects.toThrow(
|
||||
"Repository not initialized",
|
||||
);
|
||||
await expect(newClient.createPlaylist("test")).rejects.toThrow("Repository not initialized");
|
||||
await expect(newClient.deletePlaylist("pl-1")).rejects.toThrow("Repository not initialized");
|
||||
});
|
||||
@@ -599,9 +606,9 @@ describe("RepositoryClient", () => {
|
||||
it("should throw error if invoke fails", async () => {
|
||||
(invoke as any).mockRejectedValueOnce(new Error("Network error"));
|
||||
|
||||
await expect(client.create("https://server.com", "user1", "token", "server1")).rejects.toThrow(
|
||||
"Network error"
|
||||
);
|
||||
await expect(
|
||||
client.create("https://server.com", "user1", "token", "server1"),
|
||||
).rejects.toThrow("Network error");
|
||||
});
|
||||
|
||||
it("should handle missing optional parameters", async () => {
|
||||
@@ -616,7 +623,7 @@ describe("RepositoryClient", () => {
|
||||
"repository_get_image_url",
|
||||
expect.objectContaining({
|
||||
options: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ export class RepositoryClient {
|
||||
serverUrl: string,
|
||||
userId: string,
|
||||
accessToken: string,
|
||||
serverId: string
|
||||
serverId: string,
|
||||
): Promise<string> {
|
||||
log.debug("Creating Rust repository...");
|
||||
this.handle = await commands.repositoryCreate(serverUrl, userId, accessToken, serverId);
|
||||
@@ -137,7 +137,11 @@ export class RepositoryClient {
|
||||
}
|
||||
|
||||
async getNextUpEpisodes(seriesId?: string, limit?: number): Promise<MediaItem[]> {
|
||||
return commands.repositoryGetNextUpEpisodes(this.ensureHandle(), seriesId ?? null, limit ?? null);
|
||||
return commands.repositoryGetNextUpEpisodes(
|
||||
this.ensureHandle(),
|
||||
seriesId ?? null,
|
||||
limit ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +185,11 @@ export class RepositoryClient {
|
||||
|
||||
/** Albums the user has played but not listened to recently ("rediscover"). */
|
||||
async getRediscoverAlbums(parentId?: string, limit?: number): Promise<MediaItem[]> {
|
||||
return commands.repositoryGetRediscoverAlbums(this.ensureHandle(), parentId ?? null, limit ?? null);
|
||||
return commands.repositoryGetRediscoverAlbums(
|
||||
this.ensureHandle(),
|
||||
parentId ?? null,
|
||||
limit ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
async getGenres(parentId?: string): Promise<Genre[]> {
|
||||
@@ -229,13 +237,13 @@ export class RepositoryClient {
|
||||
async getVideoStreamUrl(
|
||||
itemId: string,
|
||||
mediaSourceId?: string,
|
||||
audioStreamIndex?: number
|
||||
audioStreamIndex?: number,
|
||||
): Promise<string> {
|
||||
return commands.repositoryGetVideoStreamUrl(
|
||||
this.ensureHandle(),
|
||||
itemId,
|
||||
mediaSourceId ?? null,
|
||||
audioStreamIndex ?? null
|
||||
audioStreamIndex ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -248,14 +256,14 @@ export class RepositoryClient {
|
||||
itemId: string,
|
||||
mediaSourceId?: string,
|
||||
startTimeSeconds?: number,
|
||||
audioStreamIndex?: number
|
||||
audioStreamIndex?: number,
|
||||
): Promise<string> {
|
||||
return commands.repositoryGetAudioOnlyStreamUrlForVideo(
|
||||
this.ensureHandle(),
|
||||
itemId,
|
||||
mediaSourceId ?? null,
|
||||
startTimeSeconds ?? null,
|
||||
audioStreamIndex ?? null
|
||||
audioStreamIndex ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -282,7 +290,11 @@ export class RepositoryClient {
|
||||
* Get image URL from backend
|
||||
* The Rust backend constructs and returns the URL with proper credentials handling
|
||||
*/
|
||||
async getImageUrl(itemId: string, imageType: ImageType = "Primary", options?: ImageOptions): Promise<string> {
|
||||
async getImageUrl(
|
||||
itemId: string,
|
||||
imageType: ImageType = "Primary",
|
||||
options?: ImageOptions,
|
||||
): Promise<string> {
|
||||
return commands.repositoryGetImageUrl(this.ensureHandle(), itemId, imageType, options ?? null);
|
||||
}
|
||||
|
||||
@@ -294,9 +306,15 @@ export class RepositoryClient {
|
||||
itemId: string,
|
||||
mediaSourceId: string,
|
||||
streamIndex: number,
|
||||
format: string = "vtt"
|
||||
format: string = "vtt",
|
||||
): Promise<string> {
|
||||
return commands.repositoryGetSubtitleUrl(this.ensureHandle(), itemId, mediaSourceId, streamIndex, format);
|
||||
return commands.repositoryGetSubtitleUrl(
|
||||
this.ensureHandle(),
|
||||
itemId,
|
||||
mediaSourceId,
|
||||
streamIndex,
|
||||
format,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,9 +325,14 @@ export class RepositoryClient {
|
||||
async getVideoDownloadUrl(
|
||||
itemId: string,
|
||||
quality: QualityPreset = "original",
|
||||
mediaSourceId?: string
|
||||
mediaSourceId?: string,
|
||||
): Promise<string> {
|
||||
return commands.repositoryGetVideoDownloadUrl(this.ensureHandle(), itemId, quality, mediaSourceId ?? null);
|
||||
return commands.repositoryGetVideoDownloadUrl(
|
||||
this.ensureHandle(),
|
||||
itemId,
|
||||
quality,
|
||||
mediaSourceId ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
// ===== Favorite Methods (via Rust) =====
|
||||
|
||||
@@ -81,11 +81,4 @@ export type PersonType =
|
||||
| "Lyricist";
|
||||
|
||||
export type SessionCommand =
|
||||
| "PlayPause"
|
||||
| "Stop"
|
||||
| "Pause"
|
||||
| "Unpause"
|
||||
| "NextTrack"
|
||||
| "PreviousTrack"
|
||||
| "Mute"
|
||||
| "Unmute";
|
||||
"PlayPause" | "Stop" | "Pause" | "Unpause" | "NextTrack" | "PreviousTrack" | "Mute" | "Unmute";
|
||||
|
||||
Reference in New Issue
Block a user