feat(01-02): export and serve validated local media pairs
This commit is contained in:
1 parent
488c904807
commit
49f874e64c
6 files changed
+465
-3
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>GamePort · Fidelity review</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script type="module" src="viewer.mjs"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header><p class="eyebrow">NEUTRON GAMEPORT / LOCAL EVIDENCE</p><h1>Paired recording review</h1>
|
||||
<p id="scope">Loading local review…</p><p class="notice">Acceptance OPEN · export and fixture playback do not establish original or native gameplay parity.</p></header>
|
||||
<main>
|
||||
<section aria-label="Paired recordings" class="pair">
|
||||
<article id="original-panel"><h2>Original reference</h2><p class="classification"></p>
|
||||
<video id="original" controls preload="metadata" playsinline muted></video>
|
||||
<p class="missing"></p><output class="clock"></output><div class="links"></div></article>
|
||||
<article id="port-panel"><h2>Port recording</h2><p class="classification"></p>
|
||||
<video id="port" controls preload="metadata" playsinline muted></video>
|
||||
<p class="missing"></p><output class="clock"></output><div class="links"></div></article>
|
||||
</section>
|
||||
<section class="review-controls" aria-label="Review controls">
|
||||
<label>Observed event <select id="events"><option value="">Choose an event</option></select></label>
|
||||
<button id="play" type="button">Play pair at 1×</button><button id="pause" type="button">Pause pair</button>
|
||||
<label>Soundtrack <select id="audio"><option value="none">Muted</option><option value="original">Original</option><option value="port">Port</option></select></label>
|
||||
<label>Review volume <input id="gain" type="range" min="0" max="1" step="0.05" value="1"></label>
|
||||
<output id="gain-label">Unadjusted · 1.00</output>
|
||||
<p id="state" role="status" aria-live="polite"></p><p id="drift"></p>
|
||||
</section>
|
||||
<section aria-label="Optional review aids"><h2>Review aids</h2>
|
||||
<label><input id="annotations" type="checkbox"> Show event annotations</label>
|
||||
<label><input id="difference" type="checkbox"> Show lossless still difference</label>
|
||||
<p id="difference-state">Differences require matched lossless frame identity, viewport and crop metadata.</p>
|
||||
<div id="annotation-layer" hidden></div><canvas id="difference-layer" hidden aria-label="Optional lossless still difference"></canvas>
|
||||
<p>Raw recordings above remain unobstructed. Differences are review aids; lossy video is not a numerical fidelity measure.</p>
|
||||
</section>
|
||||
<section id="capabilities" aria-label="Capability evidence"></section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,26 @@
|
||||
:root { color-scheme: dark; font: 16px/1.5 system-ui, sans-serif; background: #111820; color: #e4ecf2; }
|
||||
body { margin: 0 auto; max-width: 1600px; padding: 1.5rem; }
|
||||
header { border-bottom: 1px solid #455669; margin-bottom: 1.5rem; }
|
||||
h1 { font-size: clamp(1.7rem, 3vw, 2.6rem); margin: .3rem 0; }
|
||||
h2 { font-size: 1.25rem; }
|
||||
.eyebrow { letter-spacing: .1em; color: #9acac1; font-size: .8rem; }
|
||||
.notice, .missing { color: #f5cf92; }
|
||||
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
|
||||
article, section.review-controls { background: #1a2530; border: 1px solid #455669; border-radius: .5rem; padding: 1rem; }
|
||||
video { display: block; width: 100%; max-height: 65vh; background: #070a0f; }
|
||||
section { margin-bottom: 1.5rem; }
|
||||
label { display: inline-flex; align-items: center; gap: .5rem; margin: .5rem .75rem .5rem 0; }
|
||||
button, select, input { font: inherit; }
|
||||
button, select { color: inherit; background: #253e4d; border: 1px solid #809fae; border-radius: .3rem; padding: .5rem; }
|
||||
button { cursor: pointer; margin: .3rem; }
|
||||
button:disabled { opacity: .5; cursor: default; }
|
||||
:focus-visible { outline: 3px solid #efc573; outline-offset: 3px; }
|
||||
a { color: #9ad9e9; overflow-wrap: anywhere; }
|
||||
.links { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: .5rem; }
|
||||
.classification { min-height: 3em; overflow-wrap: anywhere; }
|
||||
output { font-variant-numeric: tabular-nums; }
|
||||
canvas { max-width: 100%; background: #000; }
|
||||
details { margin: .5rem 0; }
|
||||
summary { cursor: pointer; }
|
||||
[hidden] { display: none !important; }
|
||||
@media (max-width: 760px) { body { padding: .7rem; } .pair { grid-template-columns: 1fr; } label { display: flex; } }
|
||||
@@ -0,0 +1,112 @@
|
||||
// Native media, independent clocks. No follower seek or rate-based correction.
|
||||
export function safeLocalURL(value) {
|
||||
if (typeof value !== 'string' || value.length > 4096 || !value) throw Error('Missing local link');
|
||||
const decoded = decodeURIComponent(value);
|
||||
if (/[\\:?#<>"\u0000-\u0020]/.test(decoded) || decoded.startsWith('/') ||
|
||||
decoded.split('/').some(p => !p || p === '.' || p === '..')) throw Error('Unsafe local link');
|
||||
return value;
|
||||
}
|
||||
|
||||
export function createPairController({original, port, onChange = () => {}}) {
|
||||
const media = {original, port};
|
||||
let problem = '', selected = null;
|
||||
const snapshot = () => ({problem, selected});
|
||||
const notify = () => onChange(snapshot());
|
||||
const pause = () => { for (const m of Object.values(media)) if (m) m.pause(); notify(); };
|
||||
const fail = message => { problem = message; pause(); };
|
||||
for (const [side, m] of Object.entries(media)) {
|
||||
if (!m) continue;
|
||||
m.muted = true;
|
||||
m.playbackRate = 1;
|
||||
m.addEventListener('waiting', () => fail(side + ' buffering'));
|
||||
m.addEventListener('error', () => fail(side + ' decoding/media error'));
|
||||
}
|
||||
async function selectEvent(event) {
|
||||
pause();
|
||||
for (const side of ['original', 'port']) {
|
||||
const m = media[side], marker = event?.[side];
|
||||
if (!m || !marker || !Number.isFinite(marker.media_seconds) || marker.media_seconds < 0 ||
|
||||
marker.media_seconds > m.duration) throw Error('Missing or out-of-range corresponding event');
|
||||
}
|
||||
for (const side of ['original', 'port']) {
|
||||
media[side].playbackRate = 1;
|
||||
media[side].currentTime = event[side].media_seconds;
|
||||
}
|
||||
selected = event; problem = ''; notify();
|
||||
}
|
||||
async function play() {
|
||||
if (!original || !port) { fail('Missing recording'); return false; }
|
||||
try {
|
||||
for (const m of Object.values(media)) m.playbackRate = 1;
|
||||
const results = await Promise.allSettled(Object.values(media).map(m => m.play()));
|
||||
const rejected = results.find(r => r.status === 'rejected');
|
||||
if (rejected) throw rejected.reason;
|
||||
problem = ''; notify(); return true;
|
||||
} catch (error) { fail('Play rejected: ' + error.message); return false; }
|
||||
}
|
||||
return {selectEvent, play, pause, snapshot};
|
||||
}
|
||||
|
||||
function element(doc, tag, text) { const node = doc.createElement(tag); node.textContent = text; return node; }
|
||||
|
||||
export function renderCapabilities(container, ledger) {
|
||||
const doc = container.ownerDocument;
|
||||
container.replaceChildren(element(doc, 'h2', 'Capability evidence'));
|
||||
const rows = ledger?.capabilities ?? [];
|
||||
if (!rows.length) { container.append(element(doc, 'p', 'No capability ledger supplied. Acceptance remains open.')); return; }
|
||||
for (const row of rows) {
|
||||
const article = doc.createElement('article');
|
||||
article.append(element(doc, 'h3', row.group + ' · ' + row.id), element(doc, 'p', row.summary),
|
||||
element(doc, 'p', 'Requirements: ' + row.requirement_ids.join(', ')),
|
||||
element(doc, 'p', 'Verified scope: ' + JSON.stringify(row.verified_scope)),
|
||||
element(doc, 'p', 'Differences: ' + JSON.stringify(row.differences)),
|
||||
element(doc, 'p', 'Acceptance: ' + JSON.stringify(row.acceptance)),
|
||||
element(doc, 'p', 'Current evidence: ' + JSON.stringify(row.current)),
|
||||
element(doc, 'p', 'Scenarios: ' + row.scenario_ids.join(', ')),
|
||||
element(doc, 'p', 'Source references: ' + JSON.stringify(row.source_links)));
|
||||
const history = doc.createElement('details');
|
||||
history.append(element(doc, 'summary', 'History / superseded evidence'), element(doc, 'p', JSON.stringify(row.history)));
|
||||
article.append(history); container.append(article);
|
||||
}
|
||||
}
|
||||
|
||||
async function mount() {
|
||||
const doc = document;
|
||||
try {
|
||||
const response = await fetch('review.json');
|
||||
if (!response.ok) throw Error('Review JSON unavailable');
|
||||
const model = await response.json();
|
||||
doc.querySelector('#scope').textContent = 'Case: ' + model.case_id;
|
||||
const media = {};
|
||||
for (const side of ['original', 'port']) {
|
||||
const data = model.sides[side], panel = doc.querySelector('#' + side + '-panel');
|
||||
const m = doc.querySelector('#' + side);
|
||||
media[side] = data.media ? m : null;
|
||||
if (data.media) m.src = safeLocalURL(data.media.url);
|
||||
panel.querySelector('.missing').textContent = data.missing;
|
||||
panel.querySelector('.classification').textContent = [data.evidence_kind ?? 'missing',
|
||||
JSON.stringify(data.platform ?? {}), data.scope ?? '', data.historical ? 'HISTORICAL' : '',
|
||||
...(data.limitations ?? [])].join(' · ');
|
||||
for (const artifact of data.artifacts) {
|
||||
const a = element(doc, 'a', artifact.role + ' · ' + artifact.path);
|
||||
a.href = safeLocalURL(artifact.url); a.target = '_blank'; a.rel = 'noopener';
|
||||
panel.querySelector('.links').append(a);
|
||||
}
|
||||
}
|
||||
const controller = createPairController({...media, onChange: state => {
|
||||
doc.querySelector('#state').textContent = state.problem || 'Paused or playing at actual recording speed';
|
||||
}});
|
||||
const events = doc.querySelector('#events');
|
||||
model.events.forEach((event, i) => { const option = element(doc, 'option', event.name +
|
||||
(!event.original || !event.port ? ' · missing correspondence' : '')); option.value = String(i); events.append(option); });
|
||||
events.addEventListener('change', async () => {
|
||||
if (events.value === '') return;
|
||||
try { await controller.selectEvent(model.events[Number(events.value)]); }
|
||||
catch (error) { doc.querySelector('#state').textContent = error.message; }
|
||||
});
|
||||
doc.querySelector('#play').addEventListener('click', () => controller.play());
|
||||
doc.querySelector('#pause').addEventListener('click', controller.pause);
|
||||
renderCapabilities(doc.querySelector('#capabilities'), model.ledger);
|
||||
} catch (error) { doc.querySelector('#scope').textContent = 'Review unavailable: ' + error.message; }
|
||||
}
|
||||
if (typeof document !== 'undefined') mount();
|
||||
Reference in new issue
Block a user