Files
miniSCP/scripts/gen-icons.ts
JokinandClaude Fable 5 c7271fb7cf Windows compatibility pass (beta target)
External editor via cmd/start + exe picker; Permissions hidden for
Windows-local (chmod only flips read-only there); Explorer/Recycle Bin
wording; Ctrl vs Cmd shortcut labels; separator-aware path joins +
drive-root detection; drives list in the panel source picker; icon.ico
+ colored tray icon; icacls ACL on connections.json; README Windows
(beta) section with upstream known issues and a smoke-test checklist.
Runtime paths pending first boot on a real Windows machine.

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

42 lines
1.9 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/icon.ico (Windows), assets/tray/tray-44-template.png (macOS tray),
// assets/tray/tray-32-color.png (Windows tray).
import { mkdir } from "node:fs/promises";
import path from "node:path";
import { Resvg } from "@resvg/resvg-js";
import pngToIco from "png-to-ico";
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);
}
// ---- Windows app icon (.ico: 16/32/48/256, used by installer + taskbar) ----
const icoPngs = [16, 32, 48, 256].map((size) => Buffer.from(renderPng(logo, size)));
await Bun.write(path.join(assets, "icon.ico"), await pngToIco(icoPngs));
// ---- tray: macOS 22pt template @2x; Windows small colored icon ----
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);
await writePng(path.join(assets, "tray", "tray-32-color.png"), logo, 32);
console.log("icons regenerated: app iconset + icon.ico + tray images");