import { listProjects } from "../scrapbox-userscript-std/rest.ts"; export async function* makeSource(): AsyncGenerator<{ name: string, displayName: string }[]> { const watchList = JSON.parse(localStorage.getItem("projectsLastAccessed") ?? "{}"); const chunk = 50; const ids = [...Object.keys(watchList)]; const yielded = new Set(); for (let i = 0; i <= Math.floor(ids.length / chunk); i++) { const res = await listProjects(ids.slice(i * chunk, (i + 1) * chunk)); if (!res.ok) continue; yield res.value.projects.flatMap((project) => { if (yielded.has(project.name)) return []; yielded.add(project.name); return [project]; }); } }