feat(reconstruction): evaluate end-to-end readiness

This commit is contained in:
morluto
2026-07-24 13:18:10 +00:00
parent 9d48ca788c
commit 38ff7418ef
21 changed files with 2578 additions and 0 deletions
@@ -0,0 +1,23 @@
const {
app,
BrowserWindow,
ipcMain,
shell,
utilityProcess,
} = require("electron");
const windows = new Set();
app.on("open-url", (_event, url) => {
for (const window of windows) window.webContents.send("deep-link", url);
});
app.whenReady().then(() => {
const window = new BrowserWindow({
webPreferences: { preload: require.resolve("./preload.js") },
});
windows.add(window);
window.loadFile("renderer.html");
utilityProcess.fork(require.resolve("./utility.js"));
ipcMain.handle("readiness:echo", (_event, value) => ({ value }));
window.webContents.on("render-process-gone", () => window.reload());
shell.openExternal("https://blocked.invalid").catch(() => undefined);
});
@@ -0,0 +1,5 @@
{
"name": "rea-readiness-electron",
"version": "1.0.0",
"main": "main.js"
}
@@ -0,0 +1,6 @@
const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("readiness", {
echo: (value) => ipcRenderer.invoke("readiness:echo", value),
onDeepLink: (listener) => ipcRenderer.on("deep-link", listener),
});
@@ -0,0 +1,8 @@
<!doctype html>
<html lang="en">
<body>
<button id="run">Run</button>
<output id="result"></output>
<script src="./renderer.js"></script>
</body>
</html>
@@ -0,0 +1,7 @@
document.querySelector("#run").addEventListener("click", async () => {
document.querySelector("#result").textContent =
await window.readiness.echo("renderer");
});
window.readiness.onDeepLink((_event, url) => {
document.querySelector("#result").textContent = url;
});
@@ -0,0 +1,5 @@
const { parentPort } = require("electron");
parentPort.on("message", (event) => {
parentPort.postMessage({ echoed: event.data });
});
@@ -0,0 +1,34 @@
import { spawn } from "node:child_process";
import { readFile, writeFile } from "node:fs/promises";
import { createServer } from "node:http";
import process from "node:process";
import readline from "node:readline";
const configurationPath =
process.env.REA_READINESS_CONFIG ?? "./readiness-config.json";
const configuration = JSON.parse(
await readFile(configurationPath, "utf8").catch(() => "{}"),
);
const prompt = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
process.stdout.write("\u001b[?1049h");
const answer = await new Promise((resolve) =>
prompt.question("readiness> ", resolve),
);
prompt.close();
const child = spawn(process.execPath, ["-e", "process.stdout.write('child')"]);
const server = createServer((request, response) => {
response.end(JSON.stringify({ path: request.url, answer }));
});
server.listen(Number(configuration.port ?? 0), "127.0.0.1");
process.on("SIGTERM", () => {
child.kill("SIGTERM");
server.close();
process.stdout.write("\u001b[?1049l");
});
await writeFile(
configurationPath,
JSON.stringify({ ...configuration, lastAnswer: answer }),
);
@@ -0,0 +1,6 @@
{
"name": "rea-readiness-javascript-cli",
"version": "1.0.0",
"type": "module",
"bin": "index.js"
}