diff --git a/src/data/api/index.ts b/src/data/api/index.ts index f358cb3..6b7aa20 100644 --- a/src/data/api/index.ts +++ b/src/data/api/index.ts @@ -125,10 +125,38 @@ import { dev_log } from "$lib/utils"; export type ContribData = { repositories: Repository[] }; export type PatchesData = { patches: Patch[]; packages: string[] }; -export type ToolsData = { tools: Tool[] }; +export type ToolsData = { tools: { [repo: string]: Tool } }; export const contributors = new API("contributors", undefined, { repositories: [] }); -export const tools = new API("tools", undefined, { tools: [] } ) +export const tools = new API("tools", json => { + // The API returns data in a weird shape. Make it easier to work with. + let map: Map = new Map(); + for (const tool of json["tools"]) { + const repo: string = tool.repository; + + if (!map.has(repo)) { + map.set(repo, { + version: tool.version, + repository: repo, + // Just use the timestamp of the first one we find. + timestamp: tool.timestamp, + assets: [] + }); + } + + let value = map.get(repo); + value.assets.push({ + name: tool.name, + size: tool.size, + url: tool.browser_download_url, + content_type: tool.content_type + }); + + map.set(repo, value); + } + + return { tools: Object.fromEntries(map) }; +}); export const patches = new API("patches", patches => { let packages: string[] = []; diff --git a/src/data/types.ts b/src/data/types.ts index 08bd849..827bbe7 100644 --- a/src/data/types.ts +++ b/src/data/types.ts @@ -33,12 +33,17 @@ export interface PatchOption { choices: string[]; } +export interface Asset { + name: string; + size: string|null; + url: string; + content_type: string; +}; + export interface Tool { - repository: string - version: string - timestamp: string - name: string - size?: string - browser_download_url: string - content_type: string -} + repository: string; + version: string; + timestamp: string; + assets: Asset[]; +}; + diff --git a/src/routes/download/+page.svelte b/src/routes/download/+page.svelte index 77b3424..93a52d4 100644 --- a/src/routes/download/+page.svelte +++ b/src/routes/download/+page.svelte @@ -6,13 +6,14 @@ export let data: PageData; api_tools.init(data); - $: tools = data.tools; + + $: manager = $api_tools.tools["revanced/revanced-manager"];

ReVanced Manager

Patch your favourite apps, on-device.
- + Manager Screenshot