Files
multiverse/jumpa-vc/scripts/fix_syntax.ts
T

62 lines
3.0 KiB
TypeScript

import fs from 'fs';
const filePath = 'C:/X/workspace/jumpa.id/vc/lib/xcu-quantum-decoder.ts';
let content = fs.readFileSync(filePath, 'utf-8');
// Fix the syntax error in xcu-quantum-decoder.ts
const target = ` } catch (e) {
console.error("[QUANTUM WEBCODECS] Gagal konfigurasi decoder:", e);
}
}
// Notifikasi React untuk merender tile
if (this.onParticipantJoined) {
this.onParticipantJoined(senderId);
}
}`;
const replacement = ` } catch (e) {
console.error("[QUANTUM WEBCODECS] Gagal konfigurasi decoder:", e);
}
// Notifikasi React untuk merender tile
if (this.onParticipantJoined) {
this.onParticipantJoined(senderId);
}
}`;
content = content.replace(target, replacement);
// Fallback logic if the exact target text was not found
if (content.includes('}\n\t}\n\n\n\t\t// Notifikasi React untuk merender tile')) {
content = content.replace('}\n\t}\n\n\n\t\t// Notifikasi React untuk merender tile', '}\n\n\t\t// Notifikasi React untuk merender tile');
}
fs.writeFileSync(filePath, content, 'utf-8');
const roomPath = 'C:/X/workspace/jumpa.id/vc/components/xcuRoom.tsx';
let roomContent = fs.readFileSync(roomPath, 'utf-8');
// The toggle function wasn't used because the button didn't render correctly. I'll make sure it is added right before the "More" button.
const moreButtonStr = `<div className="relative">
<button onClick={() => setIsMoreMenuOpen(!isMoreMenuOpen)} className="flex flex-col items-center justify-center w-14 h-14 rounded-lg hover:bg-slate-800 transition-colors text-slate-300">`;
const quantumButton = `<button onClick={handleToggleEngine} className={\`flex flex-col items-center justify-center w-14 h-14 rounded-lg transition-all duration-300 \${videoEngineMode === 'webcodecs' ? 'bg-cyan-900/40 text-cyan-400 border border-cyan-500/50 shadow-[0_0_15px_rgba(34,211,238,0.4)]' : 'hover:bg-slate-800 text-slate-400'}\`}>
<div className="relative">
<svg className={\`w-6 h-6 mb-1 \${videoEngineMode === 'webcodecs' ? 'animate-pulse' : ''}\`} fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"></path>
</svg>
{videoEngineMode === 'webcodecs' && <div className="absolute inset-0 bg-cyan-400 blur-md rounded-full opacity-40 animate-ping"></div>}
</div>
<span className="text-[9px] leading-tight text-center font-bold">{videoEngineMode === 'webcodecs' ? 'XCU WebCodecs' : 'Canvas Mode'}</span>
</button>
`;
if (!roomContent.includes('XCU WebCodecs')) {
roomContent = roomContent.replace(moreButtonStr, quantumButton + moreButtonStr);
fs.writeFileSync(roomPath, roomContent, 'utf-8');
}
console.log("Fix script complete");