@arbidocs/blocks 0.5.169 → 0.5.170
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.
- package/dist/automation/index.cjs +78 -56
- package/dist/automation/index.cjs.map +1 -1
- package/dist/automation/mount.js +70 -24
- package/dist/automation/mount.js.map +2 -2
- package/dist/automation/views.js +7 -3
- package/dist/automation/views.js.map +2 -2
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
|
@@ -549,6 +549,10 @@ function createViews(options = {}) {
|
|
|
549
549
|
const REPO = { frontend: "ARBI-frontend", backend: "ARBI" };
|
|
550
550
|
const EVIDENCE_KEY = /^rounds\/\d+\/[A-Za-z0-9._-]+$/;
|
|
551
551
|
const fileUrl2 = options.fileUrl ?? ((key) => `${API2}/files/${String(key).split("/").map(encodeURIComponent).join("/")}`);
|
|
552
|
+
const fileAttribute = (key, attribute) => {
|
|
553
|
+
const url = fileUrl2(key);
|
|
554
|
+
return `${url ? `${attribute}="${esc(url)}" ` : ""}data-evidence-key="${esc(key)}" data-evidence-attribute="${attribute}"`;
|
|
555
|
+
};
|
|
552
556
|
const fmtDate2 = (s) => {
|
|
553
557
|
if (!s) return "\u2014";
|
|
554
558
|
const d = new Date(s);
|
|
@@ -867,7 +871,7 @@ function createViews(options = {}) {
|
|
|
867
871
|
D.selected.length > 1 && ["Round", roundChip2(r)],
|
|
868
872
|
shot && [
|
|
869
873
|
"Screenshot",
|
|
870
|
-
`<div class="shots"><a
|
|
874
|
+
`<div class="shots"><a ${fileAttribute(shot, "href")} target="_blank" rel="noopener"><img class="shot" loading="lazy" ${fileAttribute(shot, "src")} alt="What ${esc(t.persona_name || t.persona)} saw: ${esc(t.title)}"></a></div>${other ? `<a class="shot-alt" ${fileAttribute(other, "href")} target="_blank" rel="noopener">Without the markup</a>` : ""}`
|
|
871
875
|
],
|
|
872
876
|
ev.video && [
|
|
873
877
|
"Recording",
|
|
@@ -997,7 +1001,7 @@ function createViews(options = {}) {
|
|
|
997
1001
|
<h3>Goals</h3><div class="md">${p.goals ? md(p.goals) : "\u2014"}</div>
|
|
998
1002
|
${p.recheck ? `<details><summary>Re-check from last round</summary><div class="md">${md(p.recheck)}</div></details>` : ""}
|
|
999
1003
|
${tasks.length ? `<details><summary>How each task went</summary><ul class="outcomes">${tasks.map((t) => `<li><span class="oc" data-oc="${esc(t.outcome)}">${esc(t.outcome || "\u2014")}</span><span>${esc(t.task)}${t.note ? ` <span class="muted">\xB7 ${inline(t.note)}</span>` : ""}</span></li>`).join("")}</ul></details>` : ""}
|
|
1000
|
-
${p.video_key ? `<details class="recording" data-persona="${esc(key)}" data-round="${r.id}"${recOpen ? " open" : ""}><summary>Watch the recording${captions ? " with captions" : ""}</summary>${!recOpen ? "" : !haveFull && captions ? loading : `<div class="player"><video id="${esc(vid)}" data-persona="${esc(key)}" controls preload="metadata"
|
|
1004
|
+
${p.video_key ? `<details class="recording" data-persona="${esc(key)}" data-round="${r.id}"${recOpen ? " open" : ""}><summary>Watch the recording${captions ? " with captions" : ""}</summary>${!recOpen ? "" : !haveFull && captions ? loading : `<div class="player"><video id="${esc(vid)}" data-persona="${esc(key)}" controls preload="metadata" ${fileAttribute(p.video_key, "src")}></video>${narration.length ? `<ol class="timeline" aria-label="What ${esc(p.name || p.id)} said">${narration.map(
|
|
1001
1005
|
(n) => `<li data-t="${Number(n.t)}"${/^⚠/.test(n.text) ? ' class="issue"' : ""}><button type="button" data-seek="${esc(vid)}" data-t="${Number(n.t)}">${fmtSecs2(n.t)}</button><span>${esc(n.text)}</span></li>`
|
|
1002
1006
|
).join("")}</ol>` : ""}</div>`}</details>` : ""}
|
|
1003
1007
|
${p.report || p.has_report ? `<details class="report" data-persona="${esc(key)}" data-round="${r.id}"${reportOpen ? " open" : ""}><summary>Their report</summary>${p.report ? `<div class="md">${md(p.report)}</div>` : reportOpen ? loading : ""}</details>` : ""}
|
|
@@ -1062,7 +1066,7 @@ ${cueText(n.text)}
|
|
|
1062
1066
|
</div>
|
|
1063
1067
|
${a.context ? `<div class="dec-q md">${md(a.context)}</div>` : ""}
|
|
1064
1068
|
${notes.length || keys.length ? `<h3>What the testers hit</h3>${notes.length ? `<ul class="ev">${notes.map((e) => `<li>${inline(e)}</li>`).join("")}</ul>` : ""}${keys.length ? `<div class="shots">${keys.map(
|
|
1065
|
-
(k) => /\.(mp4|webm)$/.test(k) ? `<video controls preload="none"
|
|
1069
|
+
(k) => /\.(mp4|webm)$/.test(k) ? `<video controls preload="none" ${fileAttribute(k, "src")} style="max-width:min(100%,360px)"></video>` : `<a ${fileAttribute(k, "href")} target="_blank" rel="noopener"><img class="shot" loading="lazy" ${fileAttribute(k, "src")} alt="Evidence for: ${esc(a.question)}"></a>`
|
|
1066
1070
|
).join("")}</div>` : ""}` : ""}
|
|
1067
1071
|
${(a.ticket_ids || []).length ? `<div class="muted mono">${a.status === "open" && !isDecision ? "Parks " : ""}${a.ticket_ids.map((id) => `<a href="#/rounds/${a.round_id}/tickets/${id}">${esc(ctx.keys.get(id) || `#${id}`)}</a>`).join(" \xB7 ")}</div>` : ""}
|
|
1068
1072
|
${a.recommendation ? `<div class="rec"><b>Recommendation:</b> ${inline(a.recommendation)}</div>` : ""}
|
|
@@ -1172,35 +1176,7 @@ ${cueText(n.text)}
|
|
|
1172
1176
|
roundsView: roundsView2
|
|
1173
1177
|
};
|
|
1174
1178
|
}
|
|
1175
|
-
|
|
1176
|
-
API,
|
|
1177
|
-
SEV_ORDER,
|
|
1178
|
-
fileUrl,
|
|
1179
|
-
fmtDate,
|
|
1180
|
-
fmtSecs,
|
|
1181
|
-
VERDICT_LABEL,
|
|
1182
|
-
latestVerdicts,
|
|
1183
|
-
stateLabel,
|
|
1184
|
-
SHOWS,
|
|
1185
|
-
stageCounts,
|
|
1186
|
-
filterTickets,
|
|
1187
|
-
roundChip,
|
|
1188
|
-
roundDate,
|
|
1189
|
-
eligibleRounds,
|
|
1190
|
-
selectedIds,
|
|
1191
|
-
pickerLabel,
|
|
1192
|
-
roundPicker,
|
|
1193
|
-
boardHead,
|
|
1194
|
-
filtersBar,
|
|
1195
|
-
ticketList,
|
|
1196
|
-
ticketLabel,
|
|
1197
|
-
ticketDetail,
|
|
1198
|
-
peopleView,
|
|
1199
|
-
narrationVtt,
|
|
1200
|
-
decisionsView,
|
|
1201
|
-
reviewView,
|
|
1202
|
-
roundsView
|
|
1203
|
-
} = createViews();
|
|
1179
|
+
createViews();
|
|
1204
1180
|
|
|
1205
1181
|
// src/automation/settings.js
|
|
1206
1182
|
var PROVIDERS = [
|
|
@@ -1365,13 +1341,21 @@ function mountAutomationBoard(root, request) {
|
|
|
1365
1341
|
const controller = new AbortController();
|
|
1366
1342
|
const signal = controller.signal;
|
|
1367
1343
|
const assets = /* @__PURE__ */ new Map();
|
|
1344
|
+
const assetLoads = /* @__PURE__ */ new Map();
|
|
1345
|
+
const assetQueue = [];
|
|
1346
|
+
let activeAssets = 0;
|
|
1368
1347
|
const objectUrls = /* @__PURE__ */ new Set();
|
|
1369
1348
|
function objectUrl(blob) {
|
|
1370
1349
|
const url = URL.createObjectURL(blob);
|
|
1371
1350
|
objectUrls.add(url);
|
|
1372
1351
|
return url;
|
|
1373
1352
|
}
|
|
1374
|
-
const V = createViews({
|
|
1353
|
+
const V = createViews({
|
|
1354
|
+
fileUrl: (key) => {
|
|
1355
|
+
const asset = assets.get(key);
|
|
1356
|
+
return asset && asset.expires > Date.now() ? asset.url : "";
|
|
1357
|
+
}
|
|
1358
|
+
});
|
|
1375
1359
|
function listen(target, type, fn, options) {
|
|
1376
1360
|
target.addEventListener(type, fn, {
|
|
1377
1361
|
...typeof options === "boolean" ? { capture: options } : options,
|
|
@@ -1432,30 +1416,57 @@ function mountAutomationBoard(root, request) {
|
|
|
1432
1416
|
async function api(method, path, body) {
|
|
1433
1417
|
signal.throwIfAborted();
|
|
1434
1418
|
const data = await request(method, path, body, signal);
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
const
|
|
1443
|
-
|
|
1444
|
-
);
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1419
|
+
signal.throwIfAborted();
|
|
1420
|
+
return data;
|
|
1421
|
+
}
|
|
1422
|
+
function evidenceUrl(key) {
|
|
1423
|
+
const cached = assets.get(key);
|
|
1424
|
+
if (cached && cached.expires > Date.now()) return Promise.resolve(cached.url);
|
|
1425
|
+
if (assetLoads.has(key)) return assetLoads.get(key);
|
|
1426
|
+
const loading = new Promise((resolve, reject) => assetQueue.push({ key, resolve, reject }));
|
|
1427
|
+
assetLoads.set(key, loading);
|
|
1428
|
+
loadEvidence();
|
|
1429
|
+
return loading;
|
|
1430
|
+
}
|
|
1431
|
+
function loadEvidence() {
|
|
1432
|
+
while (activeAssets < 4 && assetQueue.length) {
|
|
1433
|
+
const job = assetQueue.shift();
|
|
1434
|
+
activeAssets++;
|
|
1435
|
+
void (async () => {
|
|
1436
|
+
try {
|
|
1437
|
+
signal.throwIfAborted();
|
|
1438
|
+
const result = await request("GET", `/files/${job.key}`, void 0, signal);
|
|
1451
1439
|
if (!result || !/^https:\/\//.test(result.url))
|
|
1452
1440
|
throw new Error("Invalid private evidence URL");
|
|
1453
|
-
assets.set(key, { url: result.url, expires: Date.now() + 24e4 });
|
|
1441
|
+
assets.set(job.key, { url: result.url, expires: Date.now() + 24e4 });
|
|
1442
|
+
job.resolve(result.url);
|
|
1443
|
+
} catch (error) {
|
|
1444
|
+
job.reject(error);
|
|
1445
|
+
} finally {
|
|
1446
|
+
assetLoads.delete(job.key);
|
|
1447
|
+
activeAssets--;
|
|
1448
|
+
loadEvidence();
|
|
1454
1449
|
}
|
|
1455
|
-
})
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1450
|
+
})();
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
function hydrateEvidence() {
|
|
1454
|
+
for (const element of root.querySelectorAll("[data-evidence-key]")) {
|
|
1455
|
+
if (element.closest("details:not([open])")) continue;
|
|
1456
|
+
if (element.tagName === "VIDEO" && !element.paused) continue;
|
|
1457
|
+
const key = element.dataset.evidenceKey;
|
|
1458
|
+
const attribute = element.dataset.evidenceAttribute;
|
|
1459
|
+
void evidenceUrl(key).then(
|
|
1460
|
+
(url) => {
|
|
1461
|
+
const target = url + (element.dataset.evidenceFragment ?? "");
|
|
1462
|
+
if (!signal.aborted && element.isConnected && !element.closest("details:not([open])") && element.getAttribute(attribute) !== target)
|
|
1463
|
+
element.setAttribute(attribute, target);
|
|
1464
|
+
},
|
|
1465
|
+
() => {
|
|
1466
|
+
if (!signal.aborted && element.isConnected) element.title = "Evidence unavailable";
|
|
1467
|
+
}
|
|
1468
|
+
);
|
|
1469
|
+
}
|
|
1459
1470
|
}
|
|
1460
1471
|
const store = {
|
|
1461
1472
|
get: (k) => {
|
|
@@ -1575,6 +1586,7 @@ function mountAutomationBoard(root, request) {
|
|
|
1575
1586
|
const d = root.querySelector(`details.t[data-ticket="${id}"]`);
|
|
1576
1587
|
const box = d?.querySelector(".detail");
|
|
1577
1588
|
if (box) box.outerHTML = V.ticketDetail(S.fullTickets.get(id), D());
|
|
1589
|
+
hydrateEvidence();
|
|
1578
1590
|
} catch {
|
|
1579
1591
|
}
|
|
1580
1592
|
}
|
|
@@ -1615,6 +1627,7 @@ function mountAutomationBoard(root, request) {
|
|
|
1615
1627
|
});
|
|
1616
1628
|
$("ledger-count").textContent = count;
|
|
1617
1629
|
$("tickets").innerHTML = html;
|
|
1630
|
+
hydrateEvidence();
|
|
1618
1631
|
}
|
|
1619
1632
|
function render() {
|
|
1620
1633
|
renderPicker();
|
|
@@ -1647,6 +1660,7 @@ function mountAutomationBoard(root, request) {
|
|
|
1647
1660
|
} else if (tab === "review") els.view.innerHTML = V.reviewView(D());
|
|
1648
1661
|
else els.view.innerHTML = V.roundsView(S.rounds, S.ids);
|
|
1649
1662
|
S.rendered = key;
|
|
1663
|
+
hydrateEvidence();
|
|
1650
1664
|
if (tab === "personas") attachCaptions();
|
|
1651
1665
|
if (S.route.ticketId && S.scrolledTo !== location.hash) {
|
|
1652
1666
|
S.scrolledTo = location.hash;
|
|
@@ -1776,6 +1790,7 @@ function mountAutomationBoard(root, request) {
|
|
|
1776
1790
|
const t = S.fullTickets.get(id) ?? S.tickets.find((x) => x.id === id);
|
|
1777
1791
|
if (t && !d.querySelector(".detail"))
|
|
1778
1792
|
d.insertAdjacentHTML("beforeend", V.ticketDetail(t, D()));
|
|
1793
|
+
hydrateEvidence();
|
|
1779
1794
|
void loadFullTicket(id);
|
|
1780
1795
|
} else if (!d.open) S.open.delete(id);
|
|
1781
1796
|
return;
|
|
@@ -1809,7 +1824,13 @@ function mountAutomationBoard(root, request) {
|
|
|
1809
1824
|
const act = target.closest("[data-act]")?.dataset.act;
|
|
1810
1825
|
if (act === "ticket-video") {
|
|
1811
1826
|
const box = target.closest("[data-video]");
|
|
1812
|
-
|
|
1827
|
+
try {
|
|
1828
|
+
const url = await evidenceUrl(box.dataset.video);
|
|
1829
|
+
if (!signal.aborted && box.isConnected)
|
|
1830
|
+
box.innerHTML = `<video controls autoplay preload="metadata" data-evidence-key="${esc(box.dataset.video)}" data-evidence-attribute="src" data-evidence-fragment="#t=${Number(box.dataset.t)}" src="${esc(url)}#t=${Number(box.dataset.t)}"></video>`;
|
|
1831
|
+
} catch {
|
|
1832
|
+
if (!signal.aborted && box.isConnected) box.textContent = "Recording unavailable";
|
|
1833
|
+
}
|
|
1813
1834
|
return;
|
|
1814
1835
|
}
|
|
1815
1836
|
if (act === "more") {
|
|
@@ -1936,11 +1957,12 @@ function mountAutomationBoard(root, request) {
|
|
|
1936
1957
|
const a = root.activeElement;
|
|
1937
1958
|
const typing = a?.tagName === "TEXTAREA" && a.value;
|
|
1938
1959
|
const watching = [...root.querySelectorAll("video")].some((v) => !v.paused);
|
|
1939
|
-
if (
|
|
1960
|
+
if (page.events.length && !typing && !watching && !S.pickerOpen) {
|
|
1940
1961
|
const y = window.scrollY;
|
|
1941
1962
|
await refresh();
|
|
1942
1963
|
window.scrollTo(0, y);
|
|
1943
1964
|
}
|
|
1965
|
+
if (!watching) hydrateEvidence();
|
|
1944
1966
|
} catch {
|
|
1945
1967
|
if (signal.aborted) break;
|
|
1946
1968
|
await new Promise((resolve) => {
|