GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
scripts/web-probe/capture-app.mjs (1.1K)
1 // capture-app.mjs <site-dir> <app> <out.rgba> [settle-ms] [entry]: open
2 // demo.html with ?app=<app> (and &entry=<entry>, the app's start function in
3 // place of `start`) through browser.mjs, let the app run for settle-ms
4 // (default 3000), and write the frame `capture()` reads back from the GPU to
5 // <out.rgba> (premultiplied RGBA8, 1280x800).
6 import fs from 'fs';
7 import { open } from './browser.mjs';
8
9 const [root, app, out, settle, entry] = process.argv.slice(2);
10 if (!root || !app || !out) { console.error('usage: capture-app.mjs <site-dir> <app> <out.rgba> [settle-ms]'); process.exit(2); }
11 const { page, logs, close } = await open(root, 'demo.html', 1280, 800, `?app=${app}` + (entry ? `&entry=${entry}` : ''));
12 let ok = true;
13 try {
14 await page.waitForFunction(() => window.demoReady === true, null, { timeout: 120000 });
15 await page.waitForTimeout(Number(settle || 3000));
16 const b64 = await page.evaluate(() => window.capture());
17 fs.writeFileSync(out, Buffer.from(b64, 'base64'));
18 } catch (e) { ok = false; logs.push('[capture] ' + String(e)); }
19 for (const l of logs) console.log(l);
20 await close();
21 process.exit(ok ? 0 : 1);