Files
miniSCP/scripts/gen-icons.ts
T
JokinandClaude Fable 5 3fb08fdc24 Simplify tray: static template icon, click focuses the app
The setImage-swapped progress frames lost the template treatment on macOS and
rendered black-on-dark once transfers started. Dial back per user decision:
the tray is now just the glyph (template image set once at construction, never
swapped) and clicking it activates the window — no menu, no progress effects.
Removes everything that only served the fancy version: progress frames +
generation, engine.aggregateProgress, the workspacesSync webview->bun channel
(schema, send proxy, panels effect, handlers) and the activate-tab action.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 21:55:42 +02:00

35 lines
1.5 KiB
TypeScript

// Regenerate every raster icon asset from the SVG sources (dev-time only).
// bun scripts/gen-icons.ts
// Produces: assets/icon.png (1024), assets/icon.iconset/* (macOS app icon),
// assets/tray/tray-44-template.png.
import { mkdir } from "node:fs/promises";
import path from "node:path";
import { Resvg } from "@resvg/resvg-js";
const root = path.join(import.meta.dir, "..");
const assets = path.join(root, "assets");
function renderPng(svg: string, sizePx: number): Uint8Array {
const resvg = new Resvg(svg, { fitTo: { mode: "width", value: sizePx } });
return resvg.render().asPng();
}
async function writePng(file: string, svg: string, sizePx: number): Promise<void> {
await mkdir(path.dirname(file), { recursive: true });
await Bun.write(file, renderPng(svg, sizePx));
}
// ---- app icon: iconset rendered per size (crisper than downscaling) ----
const logo = await Bun.file(path.join(assets, "logo.svg")).text();
await writePng(path.join(assets, "icon.png"), logo, 1024);
for (const size of [16, 32, 128, 256, 512]) {
await writePng(path.join(assets, "icon.iconset", `icon_${size}x${size}.png`), logo, size);
await writePng(path.join(assets, "icon.iconset", `icon_${size}x${size}@2x.png`), logo, size * 2);
}
// ---- tray base (22pt status item @2x) ----
const trayGlyph = await Bun.file(path.join(assets, "tray", "tray-glyph.svg")).text();
await writePng(path.join(assets, "tray", "tray-44-template.png"), trayGlyph, 44);
console.log("icons regenerated: app iconset + tray template");