Interfaccia web, parte 1: ospite, sicurezza, API, modalità dimostrativa, libreria, visualizzatore e account
Febe.Web: AddFebeWeb/UseFebe/FebeWebHost per le due vesti, interfaccia incorporata con IFileProvider proprio, indirizzi italiani, API JSON con contesto generato, eventi SSE, controlli di Host/Origin, gettone del desktop e password con blocco (§13.1), INativeShell e capacità per veste. Modalità --demo con 38 account e circa 18.000 elementi finti e scene del motore. Pagine Libreria, Visualizzatore, Account, Aggiungi account e Scheda account (contenuti, impostazioni con piano, cronologia); schermate in docs/schermate con le differenze dai mockup; prove delle API, della sicurezza, dell'esportazione CSV e dei dati dimostrativi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
76 files changed
+12503
-17
No files matched your search
@@ -0,0 +1,6 @@
|
||||
// Chooses three followed profiles in the «Aggiungi account» dialog (mockup 04).
|
||||
await new Promise((r) => setTimeout(r, 800));
|
||||
const boxes = [...document.querySelectorAll('.aggiungi .elenco input[type=checkbox]:not(:disabled)')];
|
||||
for (const i of [0, 2, 5]) if (boxes[i]) boxes[i].click();
|
||||
await new Promise((r) => setTimeout(r, 400));
|
||||
return document.querySelector('.aggiungi footer .btn.primo')?.textContent;
|
||||
@@ -0,0 +1,7 @@
|
||||
// Moves the pointer over the widest tile near the top of the mosaic (hover state of mockup 01).
|
||||
const tiles = [...document.querySelectorAll('.tess[data-id]')];
|
||||
const wide = tiles
|
||||
.filter((t) => t.getBoundingClientRect().top < 500)
|
||||
.sort((a, b) => b.getBoundingClientRect().width - a.getBoundingClientRect().width)[0];
|
||||
const r = wide.getBoundingClientRect();
|
||||
return { hover: [Math.round(r.left + r.width / 2), Math.round(r.top + r.height / 2)], label: wide.getAttribute('aria-label') };
|
||||
@@ -0,0 +1,9 @@
|
||||
// Opens a post with more files in the viewer and shows its second file (mockup 02).
|
||||
const tiles = [...document.querySelectorAll('.tess[data-id]')];
|
||||
const multi = tiles.find((t) => t.querySelector('use[href="#i-layers"]') && !t.querySelector('use[href="#i-circle-dashed"]') && !t.querySelector('use[href="#i-play"]')) || tiles[0];
|
||||
multi.click();
|
||||
await new Promise((r) => setTimeout(r, 1500));
|
||||
const second = document.querySelectorAll('.vis .serie button')[1];
|
||||
if (second) second.click();
|
||||
await new Promise((r) => setTimeout(r, 1200));
|
||||
return document.querySelector('.vis .dove')?.textContent;
|
||||
@@ -0,0 +1,119 @@
|
||||
// node tools/schermate/schermata.mjs <indirizzo> <file.png> [larghezza] [altezza] [attesa-ms] [passo.js]
|
||||
//
|
||||
// Screenshot of Febe's own interface (spec §10.7) through the DevTools protocol of a Chromium without window:
|
||||
// exact viewport at scale 1.25 (like the mockups), console errors printed, an optional step (a JS file evaluated in
|
||||
// the page and awaited; when it returns { hover: [x, y] } the pointer is moved there, so :hover styles show).
|
||||
//
|
||||
// Only for Febe's own interface: the address must be on this computer (127.0.0.1 or localhost). Instagram is never
|
||||
// opened this way (spec §2, rule 4). Needs Node 22 or later (global WebSocket) and a Chromium: set FEBE_CHROMIUM, or
|
||||
// the Playwright build under /opt/pw-browsers is used.
|
||||
import { spawn } from 'node:child_process';
|
||||
import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const [address, out, width = '1440', height = '900', wait = '3000', step] = process.argv.slice(2);
|
||||
if (!address || !out) {
|
||||
console.error('Uso: node tools/schermate/schermata.mjs <indirizzo> <file.png> [larghezza] [altezza] [attesa-ms] [passo.js]');
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const target = new URL(address);
|
||||
if (!['127.0.0.1', 'localhost', '[::1]'].includes(target.hostname)) {
|
||||
console.error('Solo l\'interfaccia di Febe su questo computer (127.0.0.1 o localhost).');
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
function findChromium() {
|
||||
if (process.env.FEBE_CHROMIUM) return process.env.FEBE_CHROMIUM;
|
||||
const root = '/opt/pw-browsers';
|
||||
if (existsSync(root)) {
|
||||
for (const name of readdirSync(root).filter((n) => /^chromium-\d+$/.test(n)).sort().reverse()) {
|
||||
const candidate = join(root, name, 'chrome-linux', 'chrome');
|
||||
if (existsSync(candidate)) return candidate;
|
||||
}
|
||||
}
|
||||
console.error('Chromium non trovato: indica il percorso in FEBE_CHROMIUM.');
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const profile = mkdtempSync(join(tmpdir(), 'febe-schermata-'));
|
||||
const port = 9300 + Math.floor(Math.random() * 500);
|
||||
const chrome = spawn(findChromium(), [
|
||||
'--headless', '--no-sandbox', '--disable-gpu', '--hide-scrollbars', '--disable-background-networking',
|
||||
'--disable-component-update', '--no-first-run', '--no-default-browser-check', '--disable-extensions',
|
||||
`--user-data-dir=${profile}`, `--remote-debugging-port=${port}`, '--remote-debugging-address=127.0.0.1', 'about:blank',
|
||||
], { stdio: 'ignore' });
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
function finish(code) {
|
||||
chrome.kill('SIGKILL');
|
||||
setTimeout(() => {
|
||||
try {
|
||||
rmSync(profile, { recursive: true, force: true });
|
||||
} catch {
|
||||
// the profile stays in the temporary folder
|
||||
}
|
||||
process.exit(code);
|
||||
}, 300);
|
||||
}
|
||||
|
||||
let ws;
|
||||
for (let i = 0; i < 50 && !ws; i++) {
|
||||
try {
|
||||
const list = await (await fetch(`http://127.0.0.1:${port}/json/list`)).json();
|
||||
const page = list.find((t) => t.type === 'page');
|
||||
if (page) ws = new WebSocket(page.webSocketDebuggerUrl);
|
||||
} catch {
|
||||
// Chromium is still starting
|
||||
}
|
||||
if (!ws) await sleep(200);
|
||||
}
|
||||
if (!ws) {
|
||||
console.error('Chromium non risponde.');
|
||||
finish(1);
|
||||
} else {
|
||||
await new Promise((r) => ws.addEventListener('open', r));
|
||||
let id = 0;
|
||||
const pending = new Map();
|
||||
ws.addEventListener('message', (e) => {
|
||||
const msg = JSON.parse(e.data);
|
||||
if (msg.id && pending.has(msg.id)) {
|
||||
pending.get(msg.id)(msg);
|
||||
pending.delete(msg.id);
|
||||
} else if (msg.method === 'Runtime.consoleAPICalled' && ['error', 'warning'].includes(msg.params.type)) {
|
||||
console.log(`console.${msg.params.type}:`, msg.params.args.map((a) => a.value ?? a.description).join(' '));
|
||||
} else if (msg.method === 'Runtime.exceptionThrown') {
|
||||
console.log('eccezione:', msg.params.exceptionDetails.exception?.description || msg.params.exceptionDetails.text);
|
||||
} else if (msg.method === 'Log.entryAdded' && msg.params.entry.level === 'error') {
|
||||
console.log('errore:', msg.params.entry.text, msg.params.entry.url || '');
|
||||
}
|
||||
});
|
||||
const send = (method, params = {}) => new Promise((resolve) => {
|
||||
const n = ++id;
|
||||
pending.set(n, resolve);
|
||||
ws.send(JSON.stringify({ id: n, method, params }));
|
||||
});
|
||||
await send('Runtime.enable');
|
||||
await send('Log.enable');
|
||||
await send('Page.enable');
|
||||
await send('Emulation.setDeviceMetricsOverride', { width: Number(width), height: Number(height), deviceScaleFactor: 1.25, mobile: false });
|
||||
await send('Page.navigate', { url: target.href });
|
||||
await sleep(Number(wait));
|
||||
if (step) {
|
||||
const code = readFileSync(step, 'utf8');
|
||||
const r = await send('Runtime.evaluate', { expression: `(async () => { ${code} })()`, awaitPromise: true, returnByValue: true });
|
||||
const value = r.result?.result?.value;
|
||||
if (r.result?.exceptionDetails) console.log('errore nel passo:', r.result.exceptionDetails.exception?.description);
|
||||
else if (value !== undefined) console.log('passo:', JSON.stringify(value));
|
||||
if (value && typeof value === 'object' && Array.isArray(value.hover)) {
|
||||
await send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: value.hover[0], y: value.hover[1] });
|
||||
}
|
||||
await sleep(800);
|
||||
}
|
||||
const shot = await send('Page.captureScreenshot', { format: 'png' });
|
||||
writeFileSync(out, Buffer.from(shot.result.data, 'base64'));
|
||||
console.log('salvata', out);
|
||||
ws.close();
|
||||
finish(0);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
# Retakes the screenshots of docs/schermate from a running demo (spec §10.7):
|
||||
# dotnet run --project src/Febe.Server -- --demo --porta 8490 (in another terminal)
|
||||
# bash tools/schermate/tutte.sh [porta] [cartella]
|
||||
# One screenshot at a time: Chromium and the demo share the computer.
|
||||
set -u
|
||||
here="$(cd "$(dirname "$0")" && pwd)"
|
||||
port="${1:-8480}"
|
||||
out="${2:-$here/../../docs/schermate}"
|
||||
b="http://127.0.0.1:$port"
|
||||
mkdir -p "$out"
|
||||
shot() { echo "== $2"; timeout 90 node "$here/schermata.mjs" "$1" "$out/$2" "${3:-1440}" "${4:-900}" "${5:-3000}" ${6:-}; }
|
||||
shot "$b/libreria?tema=chiaro" 01-libreria.png 1440 900 3000 "$here/passi/puntatore.js"
|
||||
shot "$b/libreria?tema=chiaro" 02-visualizzatore.png 1440 900 3000 "$here/passi/visualizzatore.js"
|
||||
shot "$b/account?tema=chiaro" 03-account.png
|
||||
shot "$b/account?tema=chiaro" 03-account-telefono.png 390 844
|
||||
shot "$b/account?dialogo=aggiungi&tema=chiaro" 04-aggiungi-account.png 1440 900 3000 "$here/passi/aggiungi.js"
|
||||
shot "$b/account/3/impostazioni?tema=chiaro" 05-account-impostazioni.png
|
||||
shot "$b/libreria?scena=fermo&tema=scuro" 11-libreria-fermo-tema-scuro.png
|
||||
shot "$b/account/2?tema=scuro&tipo=storie" 12-account-storie-tema-scuro.png
|
||||
shot "$b/libreria?tema=chiaro" 14-finestra-stretta.png 860 900
|
||||
shot "$b/libreria?tema=chiaro" 14-telefono.png 390 844
|
||||
shot "$b/account/2/cronologia?tema=chiaro" account-cronologia.png
|
||||
Reference in new issue
Block a user