Text to vertical video in 100+ styles: AI codes each scene (HTML/SVG/WebGL), renders a 9:16 MP4 with music and English/Vietnamese voice. MCP, CLI and REST for AI agents.
// Khung xem trước đồ hoạ của Studio: chạy trong <iframe sandbox="allow-scripts"> (origin rỗng: không đọc được cookie,
// API, trang cha). Nhận cảnh từ trang cha qua postMessage: {type:'scene', css, html, G} (HTML/CSS do edit/graphics.mjs
// dựng phía server, chữ đã escape — giống hệt lớp HyperFrames) rồi {type:'t', t} để vẽ đúng khung (gfxRender thuần theo t).
(() => {
let G = []; let last = 0;
const root = document.getElementById('root');
const css = document.getElementById('gcss');
window.addEventListener('message', (e) => {
if (e.source !== window.parent) return; // chỉ nhận từ trang chứa khung
const m = e.data;
if (!m || typeof m !== 'object') return;
if (m.type === 'scene' && typeof m.html === 'string' && typeof m.css === 'string' && Array.isArray(m.G)) {
css.textContent = m.css;
root.innerHTML = m.html; // trong sandbox; HTML từ server (đã escape) — không có dữ liệu chạy được ra ngoài khung
G = m.G;
try { window.gfxRender(last, G); } catch { /* cảnh chưa khớp */ }
} else if (m.type === 't' && Number.isFinite(m.t)) {
last = m.t;
try { window.gfxRender(m.t, G); } catch { /* bỏ qua */ }
}
});
window.parent.postMessage({ type: 'gfx-ready' }, '*');
})();