Files
luxe/scripts/press-shots.mjs
Evan Whittaker d2129a886f Luxe 0.1.3: your sessions on your phone, joinable sessions, and nested AGENTS.md
- luxe remote puts the sessions on your computer in reach of your own phone or tablet over
  Tailscale: write, steer, answer prompts, send photos, browse files, diffs and GitHub, with a
  paired device and your own Tailscale login.
- luxe join lets another program on the same machine join a running session over the RPC protocol.
- An AGENTS.md in a subfolder reaches the model the first time it works there.
- Long sessions stay fast: no stall before each model call, lighter memory, cheaper drawing.
- A session is open in one Luxe at a time, web_search shares results across its phrasings, and a
  grep glob starting with ! excludes.

The CHANGELOG has the full list.
2026-10-20 02:40:13 -05:00

67 lines
2.6 KiB
JavaScript

#!/usr/bin/env node
// Render the press kit's screenshots to web/public/press/<name>.png.
//
// Each one is a still the site already draws (`web/src/pages/press-shots.astro`), photographed at
// twice its size so it stays sharp in an article or on a slide. Separate from `site-assets.sh`
// for the reason `social-card.sh` is: that one turns Rust into assets and CI checks it, and this
// needs Node, a build and a browser.
//
// Usage: node scripts/press-shots.mjs (from the repository root, after `npm install` in web/)
import { spawn, spawnSync } from "node:child_process";
import { mkdirSync } from "node:fs";
import { createRequire } from "node:module";
import { dirname, join } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
const web = join(dirname(fileURLToPath(import.meta.url)), "..", "web");
const out = join(web, "public", "press");
const port = process.env.PORT ?? "4332";
const origin = `http://localhost:${port}`;
const require = createRequire(join(web, "package.json"));
const playwright = await import(pathToFileURL(require.resolve("playwright")).href);
const { chromium } = playwright.chromium ? playwright : playwright.default;
function build() {
const built = spawnSync("npm", ["run", "build"], { cwd: web, stdio: "inherit" });
if (built.status !== 0) throw new Error(`the site build failed with status ${built.status}`);
}
async function waitForPreview() {
for (let attempt = 0; attempt < 30; attempt++) {
await new Promise((done) => setTimeout(done, 1000));
const reply = await fetch(`${origin}/press-shots/`).catch(() => null);
if (reply?.ok) return;
}
throw new Error(`the preview never came up on ${origin}`);
}
// A tall window, so a still is sized by its own width cap rather than by the screen's height
async function photograph() {
const browser = await chromium.launch();
const page = await browser.newPage({
viewport: { width: 1980, height: 2400 },
deviceScaleFactor: 2,
reducedMotion: "reduce",
});
await page.goto(`${origin}/press-shots/`, { waitUntil: "networkidle" });
await page.evaluate(() => document.fonts.ready);
mkdirSync(out, { recursive: true });
for (const shot of await page.$$("[data-shot]")) {
const name = await shot.getAttribute("data-shot");
await (await shot.$(".still__plate")).screenshot({ path: join(out, `${name}.png`) });
console.log(`wrote web/public/press/${name}.png`);
}
await browser.close();
}
build();
const preview = spawn("npx", ["astro", "preview", "--port", port], { cwd: web, stdio: "ignore" });
try {
await waitForPreview();
await photograph();
} finally {
preview.kill();
}