// tools/check_gui_fix.js — self-check for the TCP GUI button fix (V9 regression). // Run: node tools/check_gui_fix.js (exit 0 = OK) // Verifies: guard exists in source, compiled bundle, and all 6 shipped copies // are byte-identical to the compiled bundle; bundle is syntactically valid. const { readFileSync } = require('fs'); const { execFileSync } = require('child_process'); const path = require('path'); const root = path.join(__dirname, '..'); const SRC = path.join(root, 'app/static/js/app.jsx'); const PRECOMPILED = path.join(root, 'app/static/js/app.precompiled.js'); const GUARD_SRC = 'if (!loadOk && !window.__bridgeLoadedChannels[bch]) {'; const GUARD_COMPILED = 'if(!loadOk&&!window.__bridgeLoadedChannels[bch]){'; const COPIES = [ 'dist/daw_engine/_internal/app/static/js/app.precompiled.js', 'install/daw_engine/_internal/app/static/js/app.precompiled.js', 'src-tauri/resources/daw_engine/_internal/app/static/js/app.precompiled.js', 'src-tauri/target/debug/daw_engine/_internal/app/static/js/app.precompiled.js', 'src-tauri/target/release/daw_engine/_internal/app/static/js/app.precompiled.js' ]; function assert(cond, msg) { if (!cond) { console.error('FAIL: ' + msg); process.exit(1); } } const src = readFileSync(SRC, 'utf8'); assert(src.includes(GUARD_SRC), 'guard missing in app.jsx'); const compiled = readFileSync(PRECOMPILED, 'utf8'); assert(compiled.includes(GUARD_COMPILED), 'guard missing in app.precompiled.js'); assert(compiled.includes('__bridgePluginPaths[instrumentId]=knownPath') || compiled.includes('window.__bridgePluginPaths[instrumentId]=knownPath'), 'path cache write missing in precompiled'); assert(src.includes('__bridgeLoadedState'), 'V10 loaded-state guard missing in app.jsx'); assert(compiled.includes('__bridgeLoadedState'), 'V10 loaded-state guard missing in precompiled'); // Bundle must parse (Babel output is plain script). execFileSync(process.execPath, ['--check', PRECOMPILED], { stdio: 'pipe' }); for (const c of COPIES) { const p = path.join(root, c); assert(readFileSync(p, 'utf8') === compiled, 'copy out of sync: ' + c); } console.log('OK: GUI fix guard present in source + compiled + all ' + (COPIES.length + 1) + ' bundles; bundle parses.');