#!/usr/bin/env node /** * Trace nav PNG lockups to SVG via potrace (high-fidelity paths from approved raster). * Usage: node scripts/brand/trace-nav-svg.mjs */ import { promises as fs } from 'node:fs' import path from 'node:path' import { fileURLToPath } from 'node:url' import potrace from 'potrace' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const brandDir = path.join(__dirname, '../../public/brand') const traces = [ { input: 'logo-horizontal-nav.png', output: 'logo-horizontal-nav.svg', title: 'Miracles in Motion Foundation', potrace: { color: 'auto', background: 'transparent', turdSize: 2, optTolerance: 0.2, threshold: 180, }, }, { input: 'logo-symbol-nav.png', output: 'logo-symbol-nav.svg', title: 'Miracles in Motion Foundation symbol', potrace: { color: 'auto', background: 'transparent', turdSize: 2, optTolerance: 0.15, threshold: 200, }, }, ] function tracePng(inputPath, options) { return new Promise((resolve, reject) => { potrace.trace(inputPath, options, (err, svg) => { if (err) reject(err) else resolve(svg) }) }) } function normalizeSvg(svg, title) { let out = svg.replace(/<\?xml[^>]*>\s*/i, '') if (!out.includes('aria-hidden')) { out = out.replace(/