Begin page: lens rows were nested one array too deep; probe screenshots at 360 px for the era picker and lens steppers
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
13e8c82059
commit
9a6a1e8c73
5 changed files with 99 additions and 1 deletions
|
|
@ -225,7 +225,7 @@ async function beginView() {
|
|||
el("label", { for: "title" }, "2. Name the world"), title,
|
||||
el("label", { for: "name" }, "3. What you are called in it"), name,
|
||||
el("label", { for: "brief" }, "4. Anything the storyteller should know (optional)"), brief,
|
||||
lenses.length ? [el("label", {}, "5. What the world reaches for"), lensRows] : "",
|
||||
lenses.length ? [el("label", {}, "5. What the world reaches for"), ...lensRows] : "",
|
||||
go, msg,
|
||||
el("p", { class: "small" }, "A world seeded from lore takes a few minutes. You can leave this page; it carries on."));
|
||||
}
|
||||
|
|
|
|||
BIN
probes/page/18-begin-era-lenses-360.png
Normal file
BIN
probes/page/18-begin-era-lenses-360.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 307 KiB |
BIN
probes/page/19-begin-post-elysium-charter3-veil0-360.png
Normal file
BIN
probes/page/19-begin-post-elysium-charter3-veil0-360.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 312 KiB |
76
probes/page/begin-era.mjs
Normal file
76
probes/page/begin-era.mjs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
// Drives the Begin page at 360 px: serves the page's real files over a stub API shaped like the
|
||||
// real /api/vaults (the production era tables) and records the Begin request the page sends.
|
||||
// usage: node begin-era.mjs <page-dir> <out-dir> [chrome-path]
|
||||
import http from "node:http";
|
||||
import { readFileSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { spawn } from "node:child_process";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
const [pageDir, out, chrome = "C:/Program Files/Google/Chrome/Application/chrome.exe"] = process.argv.slice(2);
|
||||
mkdirSync(out, { recursive: true });
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
const lenses = [
|
||||
["patina", "Patina", "ordinary objects, customs, nicknames, local jokes"], ["charter", "Charter", "government, law, offices, selection, succession, redress"],
|
||||
["ledger", "Ledger", "resources, labor, trade, infrastructure, scarcity, class pressure"], ["hearth", "Hearth", "kinship, daily life, care, obligation, belonging"],
|
||||
["tangle", "Tangle", "factions, alliances, rivalries, leverage"], ["veil", "Veil", "secrets, rumors, misinformation, taboos, unevenly held knowledge"],
|
||||
["ember", "Ember", "disputes, hazards, instability, escalation, urgent pressure"], ["numen", "Numen", "religion, magic, ritual, awe, cosmology, the genuinely strange"],
|
||||
].map(([id, name, reaches_for]) => ({ id, name, reaches_for }));
|
||||
const vaults = [
|
||||
{ name: "aetheria", default_era: "pre-elysium", eras: [
|
||||
{ id: "pre-elysium", label: "Pre-Elysium", description: "Late Sol, the Existential Collapse (2750-3025): aging infrastructure and institutions fail, wireheading is an industry, uploaded and uplifted minds hold unequal standing, powers fight over who survives; no FTL, no Elysium, no aether." },
|
||||
{ id: "post-elysium", label: "Post-Elysium", description: "After the Rupture: Sol's civilization displaced into Elysium, a sealed hostile domain; aether, espers, pseudospace, necrotech and spirits exist; old political habits survive with sharper tools." } ] },
|
||||
{ name: "delvehold", default_era: "present", eras: [{ id: "present", label: "The Greathold now", description: "x" }] },
|
||||
];
|
||||
let begun = null;
|
||||
const server = http.createServer((req, res) => {
|
||||
const send = (code, type, body) => { res.writeHead(code, { "content-type": type }); res.end(body); };
|
||||
const json = (b, c = 200) => send(c, "application/json", JSON.stringify(b));
|
||||
const u = new URL(req.url, "http://x");
|
||||
if (u.pathname === "/api/me") return json({ signedIn: true, currentTimeline: null, providers: [] });
|
||||
if (u.pathname === "/api/timelines") return json({ timelines: [] });
|
||||
if (u.pathname === "/api/vaults") return json({ vaults, lenses });
|
||||
if (u.pathname === "/api/begin") { let b = ""; req.on("data", (d) => (b += d)); req.on("end", () => { begun = JSON.parse(b); json({ error: "stub: no kernel behind this probe", step: "open" }, 409); }); return; }
|
||||
const file = { "/": "index.html", "/index.html": "index.html", "/page.css": "page.css", "/page.js": "page.js" }[u.pathname];
|
||||
if (!file) return json({}, 404);
|
||||
send(200, file.endsWith("css") ? "text/css" : file.endsWith("js") ? "text/javascript" : "text/html", readFileSync(join(pageDir, file)));
|
||||
});
|
||||
await new Promise((r) => server.listen(0, "127.0.0.1", r));
|
||||
const base = `http://127.0.0.1:${server.address().port}/`;
|
||||
const port = 9300 + Math.floor(Math.random() * 500);
|
||||
const proc = spawn(chrome, ["--headless=new", `--remote-debugging-port=${port}`, `--user-data-dir=${mkdtempSync(join(tmpdir(), "era-"))}`, "--no-first-run", "about:blank"], { stdio: "ignore" });
|
||||
let targets;
|
||||
for (let i = 0; i < 50; i++) { try { targets = await (await fetch(`http://127.0.0.1:${port}/json`)).json(); break; } catch { await sleep(200); } }
|
||||
const ws = new WebSocket(targets.find((t) => t.type === "page").webSocketDebuggerUrl);
|
||||
await new Promise((r) => (ws.onopen = r));
|
||||
let id = 0; const waiting = new Map();
|
||||
ws.onmessage = (m) => { const d = JSON.parse(m.data); if (d.id && waiting.has(d.id)) waiting.get(d.id)(d); };
|
||||
const cdp = (method, params = {}) => new Promise((r) => { const n = ++id; waiting.set(n, r); ws.send(JSON.stringify({ id: n, method, params })); });
|
||||
const evalJs = async (expression) => (await cdp("Runtime.evaluate", { expression, awaitPromise: true, returnByValue: true })).result?.result?.value;
|
||||
const shot = async (name) => {
|
||||
const h = await evalJs("document.documentElement.scrollHeight");
|
||||
await cdp("Emulation.setDeviceMetricsOverride", { width: 360, height: h, deviceScaleFactor: 2, mobile: true });
|
||||
const r = await cdp("Page.captureScreenshot", { format: "png" });
|
||||
writeFileSync(join(out, name), Buffer.from(r.result.data, "base64"));
|
||||
};
|
||||
await cdp("Page.enable");
|
||||
await cdp("Emulation.setDeviceMetricsOverride", { width: 360, height: 800, deviceScaleFactor: 2, mobile: true });
|
||||
await cdp("Page.navigate", { url: base });
|
||||
await sleep(800);
|
||||
await evalJs("document.querySelector('.btn.wide').click()"); await sleep(600);
|
||||
await shot("18-begin-era-lenses-360.png");
|
||||
const overflow = await evalJs("document.documentElement.scrollWidth > document.documentElement.clientWidth");
|
||||
// pick Post-Elysium, then back to default; set Charter 3, Veil 0
|
||||
await evalJs("document.querySelector('input[name=era][value=post-elysium]').click()");
|
||||
await evalJs(`(() => { const rows=[...document.querySelectorAll('.lens')]; const f=(n)=>rows.find(r=>r.textContent.startsWith(n)); const plus=f('Charter').querySelectorAll('.step')[1]; plus.click(); plus.click(); f('Veil').querySelectorAll('.step')[0].click(); })()`);
|
||||
await evalJs("document.querySelector('#title').value='Ashfall'; document.querySelector('#name').value='Deru';");
|
||||
await sleep(200);
|
||||
await shot("19-begin-post-elysium-charter3-veil0-360.png");
|
||||
// switch to a one-era vault: the picker disappears
|
||||
await evalJs("document.querySelector('input[name=vault][value=delvehold]').click()"); await sleep(200);
|
||||
const erasForDelvehold = await evalJs("document.querySelectorAll('input[name=era]').length");
|
||||
await evalJs("document.querySelector('input[name=vault][value=aetheria]').click()"); await sleep(200);
|
||||
await evalJs("document.querySelector('input[name=era][value=post-elysium]').click()");
|
||||
await evalJs("[...document.querySelectorAll('button')].find(b=>b.textContent==='Begin').click()"); await sleep(600);
|
||||
writeFileSync(join(out, "begin-request.json"), JSON.stringify({ horizontalOverflowAt360: overflow, eraRadiosForOneEraVault: erasForDelvehold, requestSent: begun }, null, 2));
|
||||
console.log(JSON.stringify({ overflow, erasForDelvehold, begun }));
|
||||
ws.close(); proc.kill(); server.close();
|
||||
22
probes/page/begin-request.json
Normal file
22
probes/page/begin-request.json
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"horizontalOverflowAt360": false,
|
||||
"eraRadiosForOneEraVault": 0,
|
||||
"requestSent": {
|
||||
"key": "12b052f6-ac87-4c0a-95a7-b4b873cfe644",
|
||||
"title": "Ashfall",
|
||||
"name": "Deru",
|
||||
"brief": null,
|
||||
"vault": "aetheria",
|
||||
"era": "post-elysium",
|
||||
"lenses": {
|
||||
"patina": 1,
|
||||
"charter": 3,
|
||||
"ledger": 1,
|
||||
"hearth": 1,
|
||||
"tangle": 1,
|
||||
"veil": 0,
|
||||
"ember": 1,
|
||||
"numen": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue