Files
s41r4j-pixie/scripts/shots/make.mjs
T
s41r4jandClaude Opus 5.5 49ce7a9da6
CI / check (push) Canceled after 0s
CI / check-windows (push) Canceled after 0s
CI / check-linux (push) Canceled after 0s
Website / build (push) Canceled after 0s
Website / deploy (push) Canceled after 0s
Build / macOS (universal .dmg) (push) Canceled after 0s
Build / Windows (x64 .exe) (push) Canceled after 0s
Build / Linux (x64 .AppImage + .deb) (push) Canceled after 0s
Build / Publish release (push) Canceled after 0s
Pixie 0.8.2: marks timed to the voice, an update window, steadier 3D, self-signed releases
- Marks land on the right control (points vs pixels, OCR-tolerant names, browser pages listed)
  and appear as their words are spoken.
- A Sparkle-style update window: what's new, Install and Relaunch / Install on Quit / Skip This
  Version; the update box fills while downloading.
- 3D closes on a click outside, really closes, caps frames, lowers quality when slow, pauses
  when idle and rebuilds after a graphics reset.
- Releases are signed with Pixie's own certificate so macOS keeps permissions across updates.
- Dictation falls back to the clipboard; the helper gives up on slow apps; locks survive a panic.
- README and site pictures drawn by Pixie's overlay; new logo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 19:52:10 +05:30

69 lines
3.5 KiB
JavaScript

// The website and README pictures: a stand-in desktop (scenes.html) with Pixie's real overlay
// drawn over it (the app's browser preview), at 2x.
//
// npm run dev -w apps/desktop (the preview, on port 1420)
// node scripts/shots/make.mjs <chrome-headless-shell> [scene…]
//
// Writes site/shots/<name>.png for buddy, ask and do.
import { spawn } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
const here = path.dirname(fileURLToPath(import.meta.url));
const root = path.resolve(here, "../..");
const [bin, ...wanted] = process.argv.slice(2);
if (!bin) throw new Error("usage: node scripts/shots/make.mjs <chrome-headless-shell> [scene…]");
const scenes = wanted.length ? wanted : ["buddy", "ask", "do"];
const W = 1280, H = 800, SCALE = 2;
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const port = 9400 + Math.floor(Math.random() * 400);
const chrome = spawn(bin, ["--headless", `--remote-debugging-port=${port}`, "--allow-file-access-from-files", "--hide-scrollbars", `--window-size=${W},${H}`, "about:blank"], { stdio: "ignore" });
let target;
for (let i = 0; i < 60 && !target; i++) {
await sleep(150);
try { target = (await (await fetch(`http://127.0.0.1:${port}/json`)).json()).find((t) => t.type === "page"); } catch {}
}
const ws = new WebSocket(target.webSocketDebuggerUrl);
let id = 0;
const waiting = new Map();
const send = (method, params = {}) => new Promise((r) => { waiting.set(++id, r); ws.send(JSON.stringify({ id, method, params })); });
ws.onmessage = (m) => {
const d = JSON.parse(m.data);
if (d.id && waiting.has(d.id)) waiting.get(d.id)(d.result);
if (d.method === "Runtime.exceptionThrown") console.log("page error:", d.params.exceptionDetails.exception?.description);
};
await new Promise((r) => (ws.onopen = r));
await send("Runtime.enable");
await send("Page.enable");
await send("Emulation.setDeviceMetricsOverride", { width: W, height: H, deviceScaleFactor: SCALE, mobile: false });
const evaluate = async (expression) => (await send("Runtime.evaluate", { expression, awaitPromise: true, returnByValue: true })).result?.value;
const shoot = async () => Buffer.from((await send("Page.captureScreenshot", { format: "png" })).data, "base64");
for (const scene of scenes) {
// 1. The desktop, and where its marks go.
const url = pathToFileURL(path.join(here, "scenes.html")).href + `?scene=${scene}`;
await send("Page.navigate", { url });
await sleep(1200);
const marks = await evaluate("new Promise(r => { const t = () => window.SCENE ? r(window.SCENE) : setTimeout(t, 50); t(); })");
const desk = await shoot();
// 2. The real overlay over it.
await send("Page.navigate", { url: "http://localhost:1420/?preview=overlay&scripted=1" });
await sleep(1500);
await evaluate(`document.body.style.setProperty("background", "url(data:image/png;base64,${desk.toString("base64")}) 0 0 / ${W}px ${H}px no-repeat", "important")`);
// The buddy starts beside the pointer, low on the screen.
await evaluate(`window.__previewEmit("buddy.cursor", { x: ${W * 0.62}, y: ${H * 0.74} }, 0)`);
let t = 300;
for (const [kind, payload, after] of marks) {
t += after;
await evaluate(`window.__previewEmit(${JSON.stringify(kind)}, ${JSON.stringify(payload)}, ${t})`);
}
await sleep(t + 2600);
const out = path.join(root, "site/shots", `${scene}.png`);
fs.writeFileSync(out, await shoot());
console.log("wrote", path.relative(root, out));
}
chrome.kill();
process.exit(0);