Update the browser, editor, settings, and installer

This commit is contained in:
Knotty Wyvern
2026-10-12 14:46:21 -07:00
parent 909894b9c8
commit f6eaa52949
163 changed files with 146260 additions and 534 deletions
+39
View File
@@ -0,0 +1,39 @@
import { spawn } from 'node:child_process';
import { mkdtemp, readFile, cp } from 'node:fs/promises';
import http from 'node:http';
import os from 'node:os';
import path from 'node:path';
import electron from 'electron';
const directory = await mkdtemp(path.join(os.tmpdir(), 'runestone-plugin-browser-'));
const server = http.createServer((req, res) => {
if (req.url === '/picture.png') {
res.writeHead(200, { 'Content-Type': 'image/png' });
return res.end(Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+aD1sAAAAASUVORK5CYII=', 'base64'));
}
if (req.url === '/slow') return;
if (req.url === '/icon.svg') {
res.writeHead(200, { 'Content-Type': 'image/svg+xml' });
return res.end('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><rect width="16" height="16" fill="red"/></svg>');
}
if (req.url === '/favicon.ico') { res.writeHead(404); return res.end(); }
if (req.url === '/no-icon') return res.end('<!doctype html><title>No icon</title>');
if (req.url === '/with-icon') return res.end('<!doctype html><title>Icon fixture</title><link rel="icon" href="/icon.svg">');
res.writeHead(200, { 'Content-Type': req.url.endsWith('.js') ? 'text/javascript' : 'text/html', 'Cache-Control': 'no-store' });
res.end(req.url.endsWith('.js') ? 'window.adExecuted=true;' : '<!doctype html><title>Browser fixture</title><input style="position:absolute;left:20px;top:20px;width:200px;height:30px"><p class="advertisement">Ad</p><p style="margin-top:80px">Runestone needle. Runestone needle. Runestone needle.</p><script src="/blocked-ad.js"></script>');
});
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
async function phase(name, plan) {
const child = spawn(electron, ['test/engine-smoke.mjs'], { stdio: 'inherit', windowsHide: true,
env: { ...process.env, RS_TEST_ROOT: directory, RS_TEST_URL: `http://127.0.0.1:${server.address().port}/`, RS_TEST_PHASE: name, RS_TEST_PLAN: JSON.stringify(plan || {}),
...(process.argv.includes('--packaged') ? { RUNESTONE_TEST_PACKAGE: path.resolve(`dist/RuneStone-Browser-${process.platform}-${process.arch}/resources/app.asar`) } : {}) } });
const timer = setTimeout(() => child.kill(), 60_000);
const code = await new Promise((resolve, reject) => { child.once('exit', resolve); child.once('error', reject); }); clearTimeout(timer);
const result = JSON.parse(await readFile(`output/engine-${name}.json`, 'utf8'));
if (code !== 0 || result.exitCode !== 0) throw new Error(`Engine ${name} checks failed.`);
}
try {
await phase('initial');
const plan = JSON.parse(await readFile(path.join(directory, 'clone-plan.json'), 'utf8'));
await cp(path.join(directory, 'Partitions', `runestone-${plan.sourceId}`), path.join(directory, 'Partitions', `runestone-${plan.id}`), { recursive: true });
await phase('restore', plan);
} finally { server.closeAllConnections(); await new Promise(resolve => server.close(resolve)); }