import { createHash } from 'node:crypto'; import { readFile, writeFile } from 'node:fs/promises'; // Preserve the complete Figma SVG export as an image; never redraw or recolor its paths. const brandFile = new URL('../public/static/brand/footer.svg', import.meta.url); const outputFile = new URL('../public/static/brand/placeholder.svg', import.meta.url); const manifestFile = new URL('../public/static/brand/placeholder.manifest.json', import.meta.url); const brand = await readFile(brandFile); const sha256 = (bytes: Buffer): string => createHash('sha256').update(bytes).digest('hex'); const width = 240; const logoOpacity = 0.2; const height = width * 44 / 124; const x = (480 - width) / 2; const y = (480 - height) / 2; const svg = Buffer.from(` 花魁短剧内容占位 `); const manifest = Buffer.from(JSON.stringify({ file: 'public/static/brand/placeholder.svg', width: 480, height: 480, sha256: sha256(svg), source: 'Composition using the unmodified Figma brand export and the design panel background token.', background: { color: '#26272f', source: 'Figma global panel token' }, composition: { type: 'svg-container', embeddedImage: { file: 'public/static/brand/footer.svg', source: 'https://www.figma.com/design/1vUq4wf5xOs8ZOlmt26Q3O/?node-id=1-706', nodeId: '1:706', sha256: sha256(brand), encoding: 'base64', unmodified: true, x, y: Number(y.toFixed(6)), width, height: Number(height.toFixed(6)), opacity: logoOpacity, }, }, }, null, 2) + '\n'); if (process.argv.includes('--check')) { const existing = await Promise.all([readFile(outputFile), readFile(manifestFile)]); if (!existing[0].equals(svg) || !existing[1].equals(manifest)) { throw new Error('Brand placeholder is out of date. Run tsx scripts/compose-placeholder.ts.'); } console.log('Brand placeholder matches the complete unmodified Figma footer.svg export.'); } else { await Promise.all([writeFile(outputFile, svg), writeFile(manifestFile, manifest)]); console.log('Composed 480×480 brand placeholder from the complete unmodified Figma footer.svg export.'); }