#!/usr/bin/env node /** * Derives the shipping single-file build from the demo build. * * The two files are a published parity claim: they must be byte-identical * except for (a) the demo bootstrap script and (b) one caret CSS declaration * that only matters inside the demo iframe. This script enforces that by * generating the shipping file rather than maintaining it by hand. */ import { readFileSync, writeFileSync, mkdirSync } from 'node:fs'; const DEMO = 'public/demo-app/index.html'; const OUT = 'release/The_Eternal_Journal.html'; let html = readFileSync(DEMO, 'utf8'); // (a) caret CSS — demo only const caret = '\n caret-color:var(--tx);-webkit-text-fill-color:var(--tx);}'; if (!html.includes(caret)) throw new Error('caret CSS anchor not found'); html = html.replace(caret, '}'); // (b) demo bootstrap script block — demo only const start = html.indexOf('', start); if (start === -1 || end === -1) throw new Error('demo bootstrap block not found'); html = html.slice(0, start) + html.slice(end + '\n'.length); if (/demoBoot|seed\.json|window\.__EJ_ALLOW_SHORT_PASSPHRASE = true/.test(html)) { throw new Error('demo-only code leaked into the shipping build'); } mkdirSync('release', { recursive: true }); writeFileSync(OUT, html); console.log(`wrote ${OUT} (${html.length} bytes)`);