// Rasterize the existing mobile SVGs: CoreSVG misreads their compact arc paths. import { existsSync, readFileSync, writeFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; import sharp from "sharp"; const source = readFileSync(new URL("../../client/src/theme/agent-marks.ts", import.meta.url), "utf8"); const marks = JSON.parse(source.slice(source.indexOf("{", source.indexOf("export const"))).trim().replace(/;$/, "")); const png = {}; for (const [agent, mark] of Object.entries(marks)) { for (const theme of ["light", "dark"]) { const foreground = mark.fg?.[theme] ?? "#ffffff"; const size = mark.full ? 96 : 60; const offset = (96 - size) / 2; const svg = mark.svg.replace(/]*\bfill=)/g, `${mark.bg?.[theme] ? `` : ""}${svg}`; png[agent + theme] = (await sharp(Buffer.from(composed)).png().toBuffer()).toString("base64"); } } const output = `// Generated by scripts/generate-agent-marks.mjs from the existing mobile assets. // Official marks from @lobehub/icons (MIT); do not edit these images by hand. import Foundation enum DesktopAgentAssets { static let png = (try? JSONDecoder().decode([String: String].self, from: Data(json.utf8))) ?? [:] private static let json = #\"\"\" ${JSON.stringify(png)} \"\"\"# } `; const target = fileURLToPath(new URL("../Sources/LinkShell/DesktopAgentAssets.swift", import.meta.url)); if (!existsSync(target) || readFileSync(target, "utf8") !== output) writeFileSync(target, output);