import { readFileSync } from 'node:fs'; import { parseTp5, buildTp5, toSimple } from '../src/codec/tp5.mjs'; const orig = readFileSync(new URL('../samples/EXPRESS.tp5', import.meta.url), 'latin1'); const doc = parseTp5(orig); const out = buildTp5(doc); console.log('companies:', doc.companies.map(c => `${c.name}(${c.destinations.length})`).join(', ')); console.log(out === orig ? '✅ .tp5 round-trip byte-identical' : '❌ .tp5 round-trip differs'); if (out !== orig) { const a = orig.split('\r\n'), b = out.split('\r\n'); console.log(` lines ${a.length} vs ${b.length}`); for (let i = 0, n = 0; i < Math.max(a.length, b.length) && n < 6; i++) if (a[i] !== b[i]) { console.log(` L${i+1}\n orig: ${String(a[i]).slice(0,110)}\n new : ${String(b[i]).slice(0,110)}`); n++; } } const s = toSimple(doc); console.log(`\nsimple view: company=${s.company} screen=${s.screen.width}x${s.screen.height}`); for (const d of s.destinations.slice(0, 5)) console.log(` ${d.name.padEnd(18)} -> ${d.frames.map(f => `"${f.text}" [${f.useTrueType ? f.ttfName + ' ' + f.ptSize : f.font}] fx=${f.effect}`).join(' + ')}`); const ch = s.destinations.find(d => d.frames.length > 1); if (ch) console.log(` ${ch.name.padEnd(18)} -> ${ch.frames.map(f => `"${f.text}"`).join(' + ')} (${ch.frames.length} frames)`);