RosePlugs: add Nexus plugin metadata fetch/cache

This commit is contained in:
Ally Founder 2026-08-11 17:58:30 -04:00
parent 1ea54f95d1
commit 195f3472b2

View file

@ -0,0 +1,50 @@
export interface NexusPlugin {
id: string;
name: string;
description: string;
authors: string[];
category: string;
status: string;
accent: string;
tagline: string;
note: string;
howItWorks: string;
features: string[];
commands: string[];
limitations: string;
pageUrl: string;
installUrl: string;
sourceUrl: string;
issueUrl: string;
}
const NEXUS_URL = "https://rp.jarviscli.dev/plugins-data.json";
let cache: NexusPlugin[] | null = null;
let inflight: Promise<NexusPlugin[]> | null = null;
export async function fetchNexusPlugins(force = false): Promise<NexusPlugin[]> {
if (!force && cache) return cache;
if (!force && inflight) return inflight;
inflight = fetch(NEXUS_URL)
.then((res) => {
if (!res.ok) throw new Error(`Nexus fetch failed: ${res.status}`);
return res.json();
})
.then((data: NexusPlugin[]) => {
cache = data;
inflight = null;
return data;
})
.catch((e) => {
inflight = null;
throw e;
});
return inflight;
}
export function clearNexusCache(): void {
cache = null;
}