fix: typed networkManager.fetch

This commit is contained in:
JellyBrick
2025-08-02 16:49:15 +09:00
parent 5e4a1253d4
commit 62b40d4df5
4 changed files with 25 additions and 6 deletions

View File

@ -19,8 +19,14 @@ export const getMusicQueueRenderer = async (
const store = queue?.queue.store.store; const store = queue?.queue.store.store;
if (!store) return null; if (!store) return null;
return (await app.networkManager.fetch('/music/get_queue', { return await app.networkManager.fetch<
QueueRendererResponse,
{
queueContextParams: string;
videoIds: string[];
}
>('/music/get_queue', {
queueContextParams: store.getState().queue.queueContextParams, queueContextParams: store.getState().queue.queueContextParams,
videoIds, videoIds,
})) as QueueRendererResponse | null; });
}; };

View File

@ -111,9 +111,14 @@ export class YTMusic implements LyricProvider {
if (!app) return null; if (!app) return null;
return app.networkManager.fetch('/next?prettyPrint=false', { return app.networkManager.fetch<
NextData,
{
videoId: string;
}
>('/next?prettyPrint=false', {
videoId, videoId,
}) as Promise<NextData>; });
} }
private fetchBrowse(browseId: string) { private fetchBrowse(browseId: string) {

View File

@ -286,7 +286,15 @@ async function onApiLoaded() {
if (!app || !searchBox) return; if (!app || !searchBox) return;
const result = await app.networkManager.fetch('/search', { const result = await app.networkManager.fetch<
unknown,
{
query: string;
params?: string;
continuation?: string;
suggestStats?: unknown;
}
>('/search', {
query, query,
params, params,
continuation, continuation,

View File

@ -1,6 +1,6 @@
export interface YouTubeMusicAppElement extends HTMLElement { export interface YouTubeMusicAppElement extends HTMLElement {
navigate(page: string): void; navigate(page: string): void;
networkManager: { networkManager: {
fetch: (url: string, data: unknown) => Promise<unknown>; fetch: <ReturnType, Data>(url: string, data: Data) => Promise<ReturnType>;
}; };
} }