@wenathlan/extension 1.1.39 → 1.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  <!doctype html>
2
2
  <html lang="en">
3
3
  <head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Devthink review</title><link rel="stylesheet" href="style.css"></head>
4
- <body><main class="wide"><header><p class="eyebrow">REVIEW GATE</p><h1>Plan before action</h1><p>Every browser operation remains blocked until the user reviews and approves it here.</p></header><label for="objective">Objective</label><textarea id="objective" rows="4" placeholder="Describe a browser task to turn into a reviewable plan."></textarea><div class="actions"><button id="localplan">Create local observation plan</button><button id="remoteplan" class="secondary">Ask configured endpoint</button><button id="diagnostic" class="secondary">Capture local diagnostics</button></div><p id="status" role="status">Loading session state.</p><p id="capabilitiestext" role="status" class="muted">Optional capabilities unknown.</p><section><h2>Current plan</h2><progress id="planprogress" max="1" value="0"></progress><div id="plan" class="panel"></div></section><section><h2>Clickable map</h2><ol id="map" class="audit maplist"></ol></section><section><h2>Navigation trail</h2><ol id="trail" class="audit"></ol></section><section><h2>Navigation state</h2><div id="navigation" class="panel"></div></section><section><h2>Tabs and windows</h2><div id="tabswindows" class="panel"></div></section><section><h2>Forms and data</h2><div id="forms" class="panel"></div></section><section><h2>Files and downloads</h2><div id="files" class="panel"></div></section><section><h2>Datasets</h2><div id="datasets" class="panel"></div></section><section><h2>Consent banners</h2><div id="banners" class="panel"></div></section><section><h2>Accessibility tree</h2><div id="a11y" class="panel"></div></section><section><h2>Reader view</h2><div id="reader" class="panel"></div></section><section><h2>Detected shapes</h2><ol id="detections" class="audit maplist"></ol></section><section><h2>Watch stream</h2><ol id="stream" class="audit"></ol></section><section><h2>Snapshot diffs</h2><div id="diffs" class="panel"></div></section><section><h2>Derived selectors</h2><ol id="selectors" class="audit maplist"></ol></section><section><h2>Structured diagnostics</h2><ul id="diagnostics" class="audit"></ul></section><section><h2>Local audit</h2><ol id="audit" class="audit"></ol></section></main><script type="module" src="sidepanel.js"></script></body>
4
+ <body><main class="wide"><header><p class="eyebrow">REVIEW GATE</p><h1>Plan before action</h1><p>Every browser operation remains blocked until the user reviews and approves it here.</p></header><label for="objective">Objective</label><textarea id="objective" rows="4" placeholder="Describe a browser task to turn into a reviewable plan."></textarea><div class="actions"><button id="localplan">Create local observation plan</button><button id="remoteplan" class="secondary">Ask configured endpoint</button><button id="diagnostic" class="secondary">Capture local diagnostics</button></div><p id="status" role="status">Loading session state.</p><p id="capabilitiestext" role="status" class="muted">Optional capabilities unknown.</p><section><h2>Current plan</h2><progress id="planprogress" max="1" value="0"></progress><div id="plan" class="panel"></div></section><section><h2>Clickable map</h2><ol id="map" class="audit maplist"></ol></section><section><h2>Navigation trail</h2><ol id="trail" class="audit"></ol></section><section><h2>Navigation state</h2><div id="navigation" class="panel"></div></section><section><h2>Tabs and windows</h2><div id="tabswindows" class="panel"></div></section><section><h2>Forms and data</h2><div id="forms" class="panel"></div></section><section><h2>Files and downloads</h2><div id="files" class="panel"></div></section><section><h2>Capture gallery</h2><div id="captures" class="panel"></div></section><section><h2>Media</h2><div id="media" class="panel"></div></section><section><h2>Datasets</h2><div id="datasets" class="panel"></div></section><section><h2>Consent banners</h2><div id="banners" class="panel"></div></section><section><h2>Accessibility tree</h2><div id="a11y" class="panel"></div></section><section><h2>Reader view</h2><div id="reader" class="panel"></div></section><section><h2>Detected shapes</h2><ol id="detections" class="audit maplist"></ol></section><section><h2>Watch stream</h2><ol id="stream" class="audit"></ol></section><section><h2>Snapshot diffs</h2><div id="diffs" class="panel"></div></section><section><h2>Derived selectors</h2><ol id="selectors" class="audit maplist"></ol></section><section><h2>Structured diagnostics</h2><ul id="diagnostics" class="audit"></ul></section><section><h2>Local audit</h2><ol id="audit" class="audit"></ol></section></main><script type="module" src="sidepanel.js"></script></body>
5
5
  </html>
@@ -1,7 +1,7 @@
1
1
  // policy.ts
2
- var sensitiveactions = /* @__PURE__ */ new Set(["click", "type", "navigate", "select", "presskey", "drag", "drop", "upload", "clear", "check", "uncheck", "toggle", "submit", "reload", "back", "forward", "writestorage", "setattribute", "removeattribute", "evaluate", "tabcreate", "tabactivate", "tabclose", "tabreload", "windowcreate", "windowclose", "windowresize", "downloadfile", "clickpoint", "shiftclick", "dismissdialog", "enterframe", "typetime", "appendtext", "setvalue", "typeedit", "keyhold", "keyrelease", "submitsearch", "selectmulti", "chooseradio", "setslider", "setdate", "setcolor", "openlink", "openprivate", "reloadcache", "stopnav", "followlink", "spanav", "rewritequery", "setfragment", "navlist", "navprofile", "handleauth", "printpdf", "prefetch", "preconnect", "deeplink", "reopentab", "pausenav", "navrate", "openclipboard", "batchopen", "duplicatetab", "closepattern", "pintab", "mutetab", "movetab", "movetabwindow", "grouptabs", "colorgroup", "collapsegroup", "discardtab", "reloadtabs", "zoomin", "zoomout", "switchtab", "maximizewindow", "minimizewindow", "restorewindow", "focuswindow", "scratchwindow", "incognitowindow", "restoretab", "restorelayout", "reopenrun", "badgetab", "fillform", "filllabel", "fillplaceholder", "submitform", "retryform", "runwizard", "selectchain", "picktypeahead", "pickdate", "attachfile", "fillcard", "fillcode", "consentpassword", "exportcsv", "exportjson", "exportexcel", "copytable", "pushsheets", "streamdisk", "paginateextract", "resumeextract", "batchdownload", "pausedownload", "resumedownload", "interceptmime", "readclipboard", "writeclipboard", "copyscreen", "quarantinedownload", "scanvirus", "cleanupartifacts"]);
2
+ var sensitiveactions = /* @__PURE__ */ new Set(["click", "type", "navigate", "select", "presskey", "drag", "drop", "upload", "clear", "check", "uncheck", "toggle", "submit", "reload", "back", "forward", "writestorage", "setattribute", "removeattribute", "evaluate", "tabcreate", "tabactivate", "tabclose", "tabreload", "windowcreate", "windowclose", "windowresize", "downloadfile", "clickpoint", "shiftclick", "dismissdialog", "enterframe", "typetime", "appendtext", "setvalue", "typeedit", "keyhold", "keyrelease", "submitsearch", "selectmulti", "chooseradio", "setslider", "setdate", "setcolor", "openlink", "openprivate", "reloadcache", "stopnav", "followlink", "spanav", "rewritequery", "setfragment", "navlist", "navprofile", "handleauth", "printpdf", "prefetch", "preconnect", "deeplink", "reopentab", "pausenav", "navrate", "openclipboard", "batchopen", "duplicatetab", "closepattern", "pintab", "mutetab", "movetab", "movetabwindow", "grouptabs", "colorgroup", "collapsegroup", "discardtab", "reloadtabs", "zoomin", "zoomout", "switchtab", "maximizewindow", "minimizewindow", "restorewindow", "focuswindow", "scratchwindow", "incognitowindow", "restoretab", "restorelayout", "reopenrun", "badgetab", "fillform", "filllabel", "fillplaceholder", "submitform", "retryform", "runwizard", "selectchain", "picktypeahead", "pickdate", "attachfile", "fillcard", "fillcode", "consentpassword", "exportcsv", "exportjson", "exportexcel", "copytable", "pushsheets", "streamdisk", "paginateextract", "resumeextract", "batchdownload", "pausedownload", "resumedownload", "interceptmime", "readclipboard", "writeclipboard", "copyscreen", "quarantinedownload", "scanvirus", "cleanupartifacts", "recordscreen", "captureaudio", "downloadimages"]);
3
3
  var interactionactions = /* @__PURE__ */ new Set(["focus", "scroll", "hover", "clickdeep", "rightclick", "doubleclick", "scrollpage", "scrollby", "scrollend", "scrolltop", "fullscreen", "zoomset", "movepointer", "clicktext", "clickaria", "clickname", "expanddetails", "pierceshadow", "retryaction"]);
4
- var readactions = /* @__PURE__ */ new Set(["observe", "inspect", "extract", "wait", "waitfor", "waittext", "readattribute", "readstyle", "readgeometry", "readvalue", "readtext", "readhtml", "countelements", "readtable", "readlinks", "readimages", "readmeta", "readforms", "readstorage", "highlight", "tablist", "windowlist", "tabsnapshot", "mapclicks", "verifyvisible", "verifyenabled", "resolvexpath", "a11ytree", "readvisible", "readertree", "detectlists", "detecttables", "readjson", "watchmutate", "waitquiet", "watchbanner", "detectinfinitescroll", "detectvirtual", "detectlazy", "readscrollpos", "readlang", "readoutline", "countpages", "listshadow", "listframes", "classifypage", "fingerprintsection", "diffsnapshots", "readselection", "watchfocus", "detectsticky", "detectscrolllock", "readopengraph", "detectlanguage", "deriveselector", "waitload", "waiturl", "spawait", "detecthttp", "readredirects", "readfinalurl", "trailaudit", "navintent", "checksafe", "querytabs", "watchtab", "findclones", "searchtabs", "listaudio", "snapshotsession", "savelayout", "attachmeta", "detectfields", "generatevalues", "saveprofiles", "asksubmit", "readerrors", "skiphoneypot", "detectlogin", "detecttemplate", "handoffcaptcha", "scrapetable", "importcsv", "looprows", "transformvalues", "deduperows", "mergepages", "stamplerows", "previewgrid", "logprovenance", "verifydownload", "exportnetlog", "namecaptures"]);
4
+ var readactions = /* @__PURE__ */ new Set(["observe", "inspect", "extract", "wait", "waitfor", "waittext", "readattribute", "readstyle", "readgeometry", "readvalue", "readtext", "readhtml", "countelements", "readtable", "readlinks", "readimages", "readmeta", "readforms", "readstorage", "highlight", "tablist", "windowlist", "tabsnapshot", "mapclicks", "verifyvisible", "verifyenabled", "resolvexpath", "a11ytree", "readvisible", "readertree", "detectlists", "detecttables", "readjson", "watchmutate", "waitquiet", "watchbanner", "detectinfinitescroll", "detectvirtual", "detectlazy", "readscrollpos", "readlang", "readoutline", "countpages", "listshadow", "listframes", "classifypage", "fingerprintsection", "diffsnapshots", "readselection", "watchfocus", "detectsticky", "detectscrolllock", "readopengraph", "detectlanguage", "deriveselector", "waitload", "waiturl", "spawait", "detecthttp", "readredirects", "readfinalurl", "trailaudit", "navintent", "checksafe", "querytabs", "watchtab", "findclones", "searchtabs", "listaudio", "snapshotsession", "savelayout", "attachmeta", "detectfields", "generatevalues", "saveprofiles", "asksubmit", "readerrors", "skiphoneypot", "detectlogin", "detecttemplate", "handoffcaptcha", "scrapetable", "importcsv", "looprows", "transformvalues", "deduperows", "mergepages", "stamplerows", "previewgrid", "logprovenance", "verifydownload", "exportnetlog", "namecaptures", "shotview", "shotfullpage", "shotelement", "shotregion", "contactsheet", "capturepdf", "captureframe", "readmedia", "readassets", "probestream", "timelapse", "shotcanvas", "convertimage", "makethumbs"]);
5
5
  var allowedactions = /* @__PURE__ */ new Set([...sensitiveactions, ...interactionactions, ...readactions]);
6
6
 
7
7
  // extension/tabscommand.ts
@@ -63,6 +63,8 @@ var tabswindowsroot = document.querySelector("#tabswindows");
63
63
  var formsroot = document.querySelector("#forms");
64
64
  var datasetsroot = document.querySelector("#datasets");
65
65
  var filesroot = document.querySelector("#files");
66
+ var capturesroot = document.querySelector("#captures");
67
+ var mediaroot = document.querySelector("#media");
66
68
  var statusnode = document.querySelector("#status");
67
69
  var progressnode = document.querySelector("#planprogress");
68
70
  var capabilitiestext = document.querySelector("#capabilitiestext");
@@ -1301,6 +1303,390 @@ function renderfiles(context) {
1301
1303
  filesroot.append(hookcard);
1302
1304
  }
1303
1305
  }
1306
+ async function capturebytes(id) {
1307
+ try {
1308
+ const record = await request({ kind: "capturebytes", id });
1309
+ return record.bytes;
1310
+ } catch {
1311
+ return void 0;
1312
+ }
1313
+ }
1314
+ function opencapture(record) {
1315
+ if (!capturesroot) return;
1316
+ const viewer = document.createElement("div");
1317
+ viewer.className = "panel captureviewer";
1318
+ const head = document.createElement("p");
1319
+ head.textContent = `${record.kind} \xB7 ${record.format} \xB7 ${record.width}\xD7${record.height} px \xB7 step ${record.stepid}${record.annotated ? " \xB7 annotated evidence" : ""}${record.name !== void 0 ? ` \xB7 ${record.name}` : ""}`;
1320
+ viewer.append(head);
1321
+ const image = document.createElement("img");
1322
+ image.alt = `Capture ${record.id} of kind ${record.kind}`;
1323
+ image.src = "";
1324
+ void capturebytes(record.id).then((bytes) => {
1325
+ if (bytes) image.src = bytes;
1326
+ else viewer.append(Object.assign(document.createElement("p"), { textContent: "The capture bytes expired from the retention window; the metadata stays for the audit trail." }));
1327
+ });
1328
+ viewer.append(image);
1329
+ const actions = document.createElement("div");
1330
+ actions.className = "actions";
1331
+ actions.append(button("Download", () => request({ kind: "downloadcapture", id: record.id }).then(() => status(`Downloaded capture ${record.id} through the reviewed download flow.`))));
1332
+ actions.append(button("Copy to clipboard", () => request({ kind: "copycapture", id: record.id }).then(() => status(`Copied capture ${record.id} to the clipboard.`))));
1333
+ actions.append(button("Close", async () => viewer.remove()));
1334
+ viewer.append(actions);
1335
+ capturesroot.append(viewer);
1336
+ }
1337
+ async function mediabytes(id) {
1338
+ try {
1339
+ const record = await request({ kind: "mediabytes", id });
1340
+ return record.bytes;
1341
+ } catch {
1342
+ return void 0;
1343
+ }
1344
+ }
1345
+ function playframes(frameids, interval, label) {
1346
+ if (!mediaroot) return;
1347
+ const viewer = document.createElement("div");
1348
+ viewer.className = "panel captureviewer";
1349
+ const head = document.createElement("p");
1350
+ head.textContent = `${label}: ${frameids.length} frames at ${interval} millisecond intervals`;
1351
+ viewer.append(head);
1352
+ const image = document.createElement("img");
1353
+ image.alt = "Lapse frame";
1354
+ viewer.append(image);
1355
+ let index = 0;
1356
+ let stopped = false;
1357
+ const show = async () => {
1358
+ if (stopped) return;
1359
+ const bytes = await capturebytes(frameids[index] ?? "");
1360
+ if (bytes) image.src = bytes;
1361
+ index = (index + 1) % Math.max(1, frameids.length);
1362
+ };
1363
+ void show();
1364
+ const timer = window.setInterval(() => {
1365
+ void show();
1366
+ }, Math.max(100, interval));
1367
+ const actions = document.createElement("div");
1368
+ actions.className = "actions";
1369
+ actions.append(button("Stop", async () => {
1370
+ stopped = true;
1371
+ window.clearInterval(timer);
1372
+ viewer.remove();
1373
+ }));
1374
+ viewer.append(actions);
1375
+ mediaroot.append(viewer);
1376
+ }
1377
+ function rendermedia(context) {
1378
+ if (!mediaroot) return;
1379
+ mediaroot.replaceChildren();
1380
+ const active = context.session && !context.session.stoppedat && context.session.expiresat > Date.now();
1381
+ if ((context.recordingactive ?? []).length > 0) {
1382
+ const indicator = document.createElement("p");
1383
+ indicator.className = "recordingindicator";
1384
+ indicator.textContent = `\u25CF recording in progress: ${context.recordingactive?.map((item) => `${item.kind} of ${item.scope} scope`).join(", ")}`;
1385
+ mediaroot.append(indicator);
1386
+ }
1387
+ for (const consent of (context.recordingconsents ?? []).filter((item) => item.approved === void 0)) {
1388
+ const card = document.createElement("div");
1389
+ card.className = "panel recordingcard";
1390
+ const head = document.createElement("p");
1391
+ head.textContent = `Recording consent ${consent.id} for step ${consent.stepid} on ${consent.origin}: ${consent.prompt}`;
1392
+ card.append(head);
1393
+ const actions = document.createElement("div");
1394
+ actions.className = "actions";
1395
+ actions.append(button("Approve recording", () => request({ kind: "approverecordingconsent", id: consent.id, approved: true }).then(() => status(`Recording consent ${consent.id} approved; rerun the recording step.`)).then(refresh)));
1396
+ actions.append(button("Decline", () => request({ kind: "approverecordingconsent", id: consent.id, approved: false }).then(() => status(`Recording consent ${consent.id} declined.`)).then(refresh)));
1397
+ card.append(actions);
1398
+ mediaroot.append(card);
1399
+ }
1400
+ const records = context.media ?? [];
1401
+ const pdfs = records.filter((record) => record.pages !== void 0);
1402
+ const recordings = records.filter((record) => record.startedat !== void 0);
1403
+ const frames = records.filter((record) => record.timestamp !== void 0);
1404
+ const canvases = records.filter((record) => record.context !== void 0);
1405
+ const streams = records.filter((record) => record.tracks !== void 0);
1406
+ const assets = records.filter((record) => record.url !== void 0 && record.kind !== void 0 && (record.kind === "favicon" || record.kind === "logo"));
1407
+ if (pdfs.length > 0) {
1408
+ const card = document.createElement("div");
1409
+ card.className = "panel";
1410
+ const head = document.createElement("p");
1411
+ head.textContent = `pdf reports: ${pdfs.length}`;
1412
+ card.append(head);
1413
+ for (const pdf of pdfs) {
1414
+ const row = document.createElement("p");
1415
+ row.textContent = `${String(pdf.name ?? pdf.id)} \xB7 ${String(pdf.pages)} page${String(pdf.pages) === "1" ? "" : "s"} \xB7 ${String(pdf.pagewidth)}\xD7${String(pdf.pageheight)} pt${pdf.landscape === true ? " \xB7 landscape" : ""} \xB7 ${String(pdf.bytes)} bytes${pdf.bytesexpired === true ? " \xB7 bytes expired" : ""}`;
1416
+ card.append(row);
1417
+ const actions = document.createElement("div");
1418
+ actions.className = "actions";
1419
+ actions.append(button("Download pdf", () => request({ kind: "downloadmedia", id: String(pdf.id) }).then(() => status(`Downloaded the pdf report ${String(pdf.name ?? pdf.id)} through the reviewed download flow.`)), !active || pdf.bytesexpired === true));
1420
+ card.append(actions);
1421
+ }
1422
+ mediaroot.append(card);
1423
+ }
1424
+ for (const batch of context.imagebatches ?? []) {
1425
+ const card = document.createElement("div");
1426
+ card.className = "panel";
1427
+ const head = document.createElement("p");
1428
+ head.textContent = `image batch of step ${batch.stepid}: ${batch.matched} of ${batch.images.length} observed images matched, ${batch.downloaded} downloaded`;
1429
+ card.append(head);
1430
+ const list = document.createElement("ol");
1431
+ list.className = "audit";
1432
+ for (const image of batch.images.slice(0, 12)) {
1433
+ const entry = document.createElement("li");
1434
+ entry.textContent = `${image.url}${image.alt ? ` \xB7 ${image.alt}` : ""} \xB7 ${image.width}\xD7${image.height} \xB7 ${image.bytes} bytes \xB7 ${image.mime}`;
1435
+ list.append(entry);
1436
+ }
1437
+ card.append(list);
1438
+ mediaroot.append(card);
1439
+ }
1440
+ if (frames.length > 0) {
1441
+ const card = document.createElement("div");
1442
+ card.className = "panel";
1443
+ const head = document.createElement("p");
1444
+ head.textContent = `video frames: ${frames.length}`;
1445
+ card.append(head);
1446
+ const grid = document.createElement("div");
1447
+ grid.className = "capturegrid";
1448
+ for (const frame of frames) {
1449
+ const cell = document.createElement("button");
1450
+ cell.type = "button";
1451
+ cell.className = "capturecard";
1452
+ const label = document.createElement("span");
1453
+ label.textContent = `${String(frame.source)} \xB7 ${String(frame.timestamp)}s${frame.poster === true ? " \xB7 poster" : ""}${frame.bytesexpired === true ? " \xB7 bytes expired" : ""}`;
1454
+ cell.append(label);
1455
+ const image = document.createElement("img");
1456
+ image.alt = `Video frame ${String(frame.id)}`;
1457
+ if (frame.bytesexpired !== true) void mediabytes(String(frame.id)).then((bytes) => {
1458
+ if (bytes) image.src = bytes;
1459
+ });
1460
+ cell.append(image);
1461
+ grid.append(cell);
1462
+ }
1463
+ card.append(grid);
1464
+ mediaroot.append(card);
1465
+ }
1466
+ const timelapse = (context.captures ?? []).filter((record) => record.kind === "timelapse");
1467
+ if (timelapse.length > 1) {
1468
+ const card = document.createElement("div");
1469
+ card.className = "panel";
1470
+ const head = document.createElement("p");
1471
+ head.textContent = `time lapse sequences: ${timelapse.length} frames`;
1472
+ card.append(head);
1473
+ card.append(button("Play lapse sequence", async () => {
1474
+ const ordered = await request({ kind: "capturereport" });
1475
+ const ids = ordered.records.filter((record) => record.kind === "timelapse").sort((left, right) => left.capturedat - right.capturedat).map((record) => record.id);
1476
+ playframes(ids, 800, "time lapse");
1477
+ }));
1478
+ mediaroot.append(card);
1479
+ }
1480
+ if (canvases.length > 0) {
1481
+ const card = document.createElement("div");
1482
+ card.className = "panel";
1483
+ const head = document.createElement("p");
1484
+ head.textContent = `canvas captures: ${canvases.length}`;
1485
+ card.append(head);
1486
+ const grid = document.createElement("div");
1487
+ grid.className = "capturegrid";
1488
+ for (const canvas of canvases) {
1489
+ const cell = document.createElement("button");
1490
+ cell.type = "button";
1491
+ cell.className = "capturecard";
1492
+ const label = document.createElement("span");
1493
+ label.textContent = `${String(canvas.element)} \xB7 ${String(canvas.context)} \xB7 ${String(canvas.width)}\xD7${String(canvas.height)}${canvas.bytesexpired === true ? " \xB7 bytes expired" : ""}`;
1494
+ cell.append(label);
1495
+ const image = document.createElement("img");
1496
+ image.alt = `Canvas capture ${String(canvas.id)}`;
1497
+ if (canvas.bytesexpired !== true) void mediabytes(String(canvas.id)).then((bytes) => {
1498
+ if (bytes) image.src = bytes;
1499
+ });
1500
+ cell.append(image);
1501
+ grid.append(cell);
1502
+ }
1503
+ card.append(grid);
1504
+ mediaroot.append(card);
1505
+ }
1506
+ for (const stream of streams) {
1507
+ const card = document.createElement("div");
1508
+ card.className = "panel";
1509
+ const head = document.createElement("p");
1510
+ head.textContent = `stream probe ${String(stream.label || stream.id)}: ${String(stream.tracks)} track${String(stream.tracks) === "1" ? "" : "s"} \xB7 ${stream.live === true ? "live" : "ended"}`;
1511
+ card.append(head);
1512
+ const detail = stream.detail;
1513
+ if (Array.isArray(detail)) {
1514
+ const list = document.createElement("ul");
1515
+ list.className = "audit";
1516
+ for (const track of detail) {
1517
+ const entry = document.createElement("li");
1518
+ entry.textContent = `${track.kind} track${track.label ? ` ${track.label}` : ""}${track.width !== void 0 ? ` \xB7 ${track.width}\xD7${track.height}` : ""}${track.framerate !== void 0 ? ` \xB7 ${Math.round(track.framerate)} fps` : ""} \xB7 ${track.state}`;
1519
+ list.append(entry);
1520
+ }
1521
+ card.append(list);
1522
+ }
1523
+ mediaroot.append(card);
1524
+ }
1525
+ if (assets.length > 0) {
1526
+ const card = document.createElement("div");
1527
+ card.className = "panel";
1528
+ const head = document.createElement("p");
1529
+ head.textContent = `page assets: ${assets.filter((asset) => asset.kind === "favicon").length} favicon and ${assets.filter((asset) => asset.kind === "logo").length} logo entries`;
1530
+ card.append(head);
1531
+ const list = document.createElement("ul");
1532
+ list.className = "audit";
1533
+ for (const asset of assets.slice(0, 12)) {
1534
+ const entry = document.createElement("li");
1535
+ entry.textContent = `${String(asset.kind)} \xB7 ${String(asset.url)}${asset.sizes !== void 0 ? ` \xB7 ${String(asset.sizes)}` : ""}`;
1536
+ list.append(entry);
1537
+ }
1538
+ card.append(list);
1539
+ mediaroot.append(card);
1540
+ }
1541
+ for (const recording of recordings) {
1542
+ const card = document.createElement("div");
1543
+ card.className = "panel recordingcard";
1544
+ const head = document.createElement("p");
1545
+ head.textContent = `${String(recording.kind)} recording ${String(recording.id)} \xB7 ${String(recording.scope)} scope \xB7 ${String(recording.duration ?? 0)} ms \xB7 ${Array.isArray(recording.frames) ? String(recording.frames.length) : "0"} frames \xB7 manifest ${String(recording.bytes ?? 0)} bytes${recording.bytesexpired === true ? " \xB7 bytes expired" : ""}`;
1546
+ card.append(head);
1547
+ const actions = document.createElement("div");
1548
+ actions.className = "actions";
1549
+ const frames2 = Array.isArray(recording.frames) ? recording.frames : [];
1550
+ if (String(recording.kind) === "screen" && frames2.length > 0) {
1551
+ actions.append(button("Play frames", async () => {
1552
+ const state = await request({ kind: "recordingframes", id: String(recording.id) });
1553
+ playframes(state.frames, state.interval, `screen recording ${String(recording.id)}`);
1554
+ }));
1555
+ }
1556
+ actions.append(button("Download manifest", () => request({ kind: "downloadrecording", id: String(recording.id) }).then(() => status(`Downloaded the recording manifest ${String(recording.id)} through the reviewed download flow.`)), !active));
1557
+ actions.append(button("Delete", () => request({ kind: "deleterecording", id: String(recording.id) }).then(() => status(`Deleted the recording ${String(recording.id)}.`)).then(refresh), !active));
1558
+ card.append(actions);
1559
+ mediaroot.append(card);
1560
+ }
1561
+ const stored = (context.captures ?? []).filter((record) => record.bytesexpired !== true).slice(0, 12);
1562
+ if (stored.length > 0) {
1563
+ const card = document.createElement("div");
1564
+ card.className = "panel";
1565
+ const head = document.createElement("p");
1566
+ head.textContent = "capture transforms: convertimage and makethumbs actions on stored captures";
1567
+ card.append(head);
1568
+ for (const record of stored) {
1569
+ const row = document.createElement("div");
1570
+ row.className = "actions";
1571
+ const label = document.createElement("p");
1572
+ label.textContent = `${record.kind} ${record.id} (${record.format})`;
1573
+ row.append(label);
1574
+ for (const target of ["png", "jpeg", "webp"]) {
1575
+ if (target !== record.format) row.append(button(`\u2192 ${target}`, () => request({ kind: "convertcapture", id: record.id, target }).then(() => status(`Converted capture ${record.id} to ${target}.`)).then(refresh), !active));
1576
+ }
1577
+ row.append(button("thumbnail", () => request({ kind: "thumbcapture", id: record.id, size: 240, fit: "cover", suffix: "thumb" }).then(() => status(`Thumbnailed capture ${record.id}.`)).then(refresh), !active));
1578
+ card.append(row);
1579
+ }
1580
+ mediaroot.append(card);
1581
+ }
1582
+ if (records.length === 0 && (context.imagebatches ?? []).length === 0 && (context.recordingactive ?? []).length === 0) {
1583
+ mediaroot.append(Object.assign(document.createElement("p"), { textContent: "No media stored yet; run a capturepdf, recordscreen, captureaudio, captureframe, downloadimages, shotcanvas, probestream, readmedia, readassets, timelapse, convertimage or makethumbs step." }));
1584
+ }
1585
+ }
1586
+ function rendercaptures(context) {
1587
+ if (!capturesroot) return;
1588
+ capturesroot.replaceChildren();
1589
+ const active = context.session && !context.session.stoppedat && context.session.expiresat > Date.now();
1590
+ const policy = context.capturepolicy ?? "manual";
1591
+ const policyrow = document.createElement("div");
1592
+ policyrow.className = "actions";
1593
+ const policylabel = document.createElement("p");
1594
+ policylabel.textContent = `capture policy: ${policy}${policy === "beforeafter" ? " \u2014 state pairs wrap every page moving action" : ""}`;
1595
+ policyrow.append(policylabel);
1596
+ for (const mode of ["off", "manual", "annotated", "beforeafter"]) {
1597
+ policyrow.append(button(mode, async () => {
1598
+ await request({ kind: "setcapturepolicy", mode });
1599
+ status(`Capture policy set to ${mode}.`);
1600
+ await refresh();
1601
+ }, !active || mode === policy));
1602
+ }
1603
+ capturesroot.append(policyrow);
1604
+ for (const progress of context.stitchprogress ?? []) {
1605
+ const bar = document.createElement("progress");
1606
+ bar.max = Math.max(1, progress.total);
1607
+ bar.value = progress.done;
1608
+ const label = document.createElement("p");
1609
+ label.textContent = `stitching full page capture of step ${progress.stepid}: tile ${progress.done} of ${progress.total}`;
1610
+ capturesroot.append(label, bar);
1611
+ }
1612
+ const captures = context.captures ?? [];
1613
+ if (captures.length === 0 && (context.capturepairs ?? []).length === 0) {
1614
+ capturesroot.append(Object.assign(document.createElement("p"), { textContent: "No captures stored yet; run a shotview, shotfullpage, shotelement, shotregion or contactsheet step." }));
1615
+ return;
1616
+ }
1617
+ const runs = [...new Set(captures.map((record) => record.runid))];
1618
+ for (const run of runs) {
1619
+ const runcaptures = captures.filter((record) => record.runid === run);
1620
+ const card = document.createElement("div");
1621
+ card.className = "panel";
1622
+ const head = document.createElement("p");
1623
+ head.textContent = `run ${run}: ${runcaptures.length} capture${runcaptures.length === 1 ? "" : "s"}`;
1624
+ card.append(head);
1625
+ const grid = document.createElement("div");
1626
+ grid.className = "capturegrid";
1627
+ for (const record of runcaptures) {
1628
+ const cell = document.createElement("button");
1629
+ cell.type = "button";
1630
+ cell.className = record.annotated ? "capturecard annotated" : "capturecard";
1631
+ const label = document.createElement("span");
1632
+ label.textContent = `${record.kind} \xB7 ${record.format} \xB7 ${record.width}\xD7${record.height}${record.annotated ? " \xB7 annotated" : ""}${record.bytesexpired ? " \xB7 bytes expired" : ""}`;
1633
+ cell.append(label);
1634
+ const image = document.createElement("img");
1635
+ image.alt = `Capture ${record.id} of kind ${record.kind}`;
1636
+ if (!record.bytesexpired) void capturebytes(record.id).then((bytes) => {
1637
+ if (bytes) image.src = bytes;
1638
+ });
1639
+ cell.append(image);
1640
+ cell.addEventListener("click", () => opencapture(record));
1641
+ grid.append(cell);
1642
+ if (record.kind === "contactsheet") {
1643
+ const cells = (context.outcomes ?? []).find((outcome) => outcome.stepid === record.stepid && outcome.details?.cells !== void 0)?.details?.cells;
1644
+ for (const sheetcell of cells ?? []) {
1645
+ const cellbutton = document.createElement("button");
1646
+ cellbutton.type = "button";
1647
+ cellbutton.className = "secondary";
1648
+ cellbutton.textContent = sheetcell.caption || sheetcell.selector;
1649
+ cellbutton.addEventListener("click", () => opencapture(record));
1650
+ grid.append(cellbutton);
1651
+ }
1652
+ }
1653
+ }
1654
+ card.append(grid);
1655
+ capturesroot.append(card);
1656
+ }
1657
+ for (const pair of context.capturepairs ?? []) {
1658
+ const card = document.createElement("div");
1659
+ card.className = "panel pairview";
1660
+ const head = document.createElement("p");
1661
+ head.textContent = `state pair around the ${pair.actionkind} action${pair.target !== void 0 ? ` on ${pair.target}` : ""}${pair.domsnapshotid !== void 0 ? ` \xB7 dom snapshot ${pair.domsnapshotid}` : ""}`;
1662
+ card.append(head);
1663
+ const row = document.createElement("div");
1664
+ row.className = "pairrow";
1665
+ const before = document.createElement("img");
1666
+ before.alt = `Before shot ${pair.beforeid}`;
1667
+ const after = document.createElement("img");
1668
+ after.alt = `After shot ${pair.afterid}`;
1669
+ void capturebytes(pair.beforeid).then((bytes) => {
1670
+ if (bytes) before.src = bytes;
1671
+ });
1672
+ void capturebytes(pair.afterid).then((bytes) => {
1673
+ if (bytes) after.src = bytes;
1674
+ });
1675
+ row.append(before, after);
1676
+ const divider = document.createElement("input");
1677
+ divider.type = "range";
1678
+ divider.min = "0";
1679
+ divider.max = "100";
1680
+ divider.value = "50";
1681
+ divider.setAttribute("aria-label", "Before and after divider");
1682
+ divider.addEventListener("input", () => {
1683
+ before.style.width = `${100 - Number(divider.value)}%`;
1684
+ after.style.width = `${Number(divider.value)}%`;
1685
+ });
1686
+ card.append(row, divider);
1687
+ capturesroot.append(card);
1688
+ }
1689
+ }
1304
1690
  function rendercapabilities(report) {
1305
1691
  if (!capabilitiestext) return;
1306
1692
  if (!report) {
@@ -1350,6 +1736,8 @@ async function refresh() {
1350
1736
  renderforms(context);
1351
1737
  renderdatasets(context);
1352
1738
  renderfiles(context);
1739
+ rendercaptures(context);
1740
+ rendermedia(context);
1353
1741
  renderaudit(context.audit);
1354
1742
  rendercapabilities(context.capabilities);
1355
1743
  if (context.session?.pausedat) status("Session paused. Reviewed actions are blocked until resume.");