@intentius/behold 0.29.44 → 0.29.46
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/cli.js +101 -5
- package/package.json +1 -1
- package/web/app.js +135 -4
- package/web/event-help-modal.js +58 -8
- package/web/float-place.js +85 -0
- package/web/float-place.test.js +117 -0
- package/web/index.html +6 -2
- package/web/kiosk-demo-frame.test.js +27 -0
- package/web/kiosk-event-help-ui.js +82 -14
- package/web/kiosk-event-help.js +146 -0
- package/web/kiosk-highlight.test.js +249 -0
- package/web/kiosk-modal-sticky.test.js +294 -0
- package/web/kiosk-popover.js +6 -22
- package/web/kiosk-vendor.js +2 -0
- package/web/kiosk-watch.js +16 -9
- package/web/kiosk.html +9 -1
- package/web/kiosk.js +44 -4
- package/web/tg-read-pills.js +23 -0
- package/web/tg-read-pills.test.js +42 -1
- package/web/tooltip.js +5 -2
package/web/kiosk.js
CHANGED
|
@@ -722,6 +722,18 @@ export function readStored(store) {
|
|
|
722
722
|
}
|
|
723
723
|
}
|
|
724
724
|
|
|
725
|
+
/**
|
|
726
|
+
* behold#765: whether chant's demo (`--chant-demo`, the page's own reads) has its graph on this behold. A behold
|
|
727
|
+
* serving one checkout (/api/project names no `viewRepos`) was paired with the demo by its operator, so the frame is
|
|
728
|
+
* the demo's repo; one serving several (`--repos`) draws it when it serves the step's repo by name. `single` is null
|
|
729
|
+
* until /api/project answers. Neither terragucci's answer nor a report naming the repo is asked for: there is none.
|
|
730
|
+
*/
|
|
731
|
+
export function demoFrameOk(own, single, repo, viewRepos) {
|
|
732
|
+
if (!own) return false;
|
|
733
|
+
if (single === true) return true;
|
|
734
|
+
return !!repoParam(repo, viewRepos);
|
|
735
|
+
}
|
|
736
|
+
|
|
725
737
|
/** Whether a tool's pipeline writes no terragucci reports or run view (VENDORS' `reports: false`). */
|
|
726
738
|
export function reportless(vendor) {
|
|
727
739
|
return !!vendor && vendor.reports === false;
|
|
@@ -1485,6 +1497,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1485
1497
|
/** behold#571: the frame and the plan's facts are the served repo's, so a tool's page shows them only for its own repo. */
|
|
1486
1498
|
const frameOk = () => {
|
|
1487
1499
|
if (!vendor) return true;
|
|
1500
|
+
// behold#765: chant's demo has no terragucci answer to name its repo, and one checkout served sends no viewRepos.
|
|
1501
|
+
if (demoFrameOk(reads.own, s.single, s.repo, s.viewRepos)) return true;
|
|
1488
1502
|
// Before the tool's first cycle: its repo's checkout, when this behold serves it.
|
|
1489
1503
|
if (s.mode === "none") return !!notRunRepo(tool, s.viewRepos) && s.aimed === notRunRepo(tool, s.viewRepos);
|
|
1490
1504
|
if (servesRepo(s.answer && !s.answer.error ? s.answer.project : null, s.repo)) return true;
|
|
@@ -1496,6 +1510,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1496
1510
|
// graph's reads from the checkout of the repo the page is about, asked by
|
|
1497
1511
|
// name. `viewRepos` is what it serves, `aimed` the repo the reads are for.
|
|
1498
1512
|
s.viewRepos = null;
|
|
1513
|
+
// behold#765: whether this behold serves one checkout (no viewRepos), null until /api/project answers.
|
|
1514
|
+
s.single = null;
|
|
1499
1515
|
s.aimed = null;
|
|
1500
1516
|
s.viewCommits = null;
|
|
1501
1517
|
const repoNamed = () => repoParam(s.repo, s.viewRepos) || (vendor && s.mode === "none" ? notRunRepo(tool, s.viewRepos) : null);
|
|
@@ -1997,6 +2013,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1997
2013
|
const carvingNow = shownCaption() !== watch.caption || !!s.stageHeld;
|
|
1998
2014
|
const put = (node, n) => {
|
|
1999
2015
|
if (node.hidden) return;
|
|
2016
|
+
// behold#764: measured at its own height, then capped to the view (placeBeside's maxHeight); its body scrolls.
|
|
2017
|
+
node.style.maxHeight = "";
|
|
2000
2018
|
const size = { w: node.offsetWidth, h: node.offsetHeight };
|
|
2001
2019
|
const box = carvingNow ? null : boxOf(n);
|
|
2002
2020
|
// Before the frame says where the box is: the right of the view, under its top.
|
|
@@ -2005,13 +2023,16 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2005
2023
|
const labels = [...((s.boxes && s.boxes.labels) || []).map((r) => ({ x: r.x + view.x, y: r.y + view.y, w: r.w, h: r.h })), chrome];
|
|
2006
2024
|
const p = box ? placeBeside(box, size, view, 18, labels) : { x: view.x + view.w - size.w - 20, y: view.y + FRAME_CONTROLS.h + 8, side: "below" };
|
|
2007
2025
|
// The result card stands level with the middle of the graph it sums up.
|
|
2008
|
-
|
|
2026
|
+
const h = p.maxHeight || size.h;
|
|
2027
|
+
node.style.maxHeight = p.maxHeight ? `${Math.floor(p.maxHeight)}px` : "";
|
|
2028
|
+
node.classList.toggle("k-capped", !!p.maxHeight);
|
|
2029
|
+
if (box && node === watch.result) p.y = Math.max(view.y + 8, Math.min(box.y + box.h / 2 - h / 2, view.y + view.h - h - 8));
|
|
2009
2030
|
node.style.transform = `translate(${Math.round(p.x)}px, ${Math.round(p.y)}px)`;
|
|
2010
|
-
for (const k of ["right", "left", "below"]) node.classList.toggle(`k-side-${k}`, p.side === k);
|
|
2031
|
+
for (const k of ["right", "left", "below", "above"]) node.classList.toggle(`k-side-${k}`, p.side === k);
|
|
2011
2032
|
node.classList.add("k-placed");
|
|
2012
2033
|
const notch = node.querySelector(":scope > .k-notch");
|
|
2013
|
-
if (notch && box) notch.style.top = `${Math.round(Math.max(12, Math.min(
|
|
2014
|
-
taken.push({ x: p.x, y: p.y, x2: p.x + size.w, y2: p.y +
|
|
2034
|
+
if (notch && box) notch.style.top = `${Math.round(Math.max(12, Math.min(h - 26, box.y + 22 - p.y)))}px`;
|
|
2035
|
+
taken.push({ x: p.x, y: p.y, x2: p.x + size.w, y2: p.y + h });
|
|
2015
2036
|
};
|
|
2016
2037
|
put(watch.callout, s.held);
|
|
2017
2038
|
put(watch.drawer, drawerWave !== null ? drawerWave : s.shot && s.shot.waves[0]);
|
|
@@ -2040,6 +2061,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2040
2061
|
window.addEventListener("message", (e) => {
|
|
2041
2062
|
if (e.origin !== origin || !frame || e.source !== frame.contentWindow || !e.data) return;
|
|
2042
2063
|
if (e.data.type === "behold:viewer") return holdShot();
|
|
2064
|
+
// behold#764: the frame's card details popover opened, moved or closed: a modal yields to it, and one held back opens after.
|
|
2065
|
+
if (e.data.type === "behold:pop") {
|
|
2066
|
+
const a = e.data.at;
|
|
2067
|
+
s.framePop = a && [a.x, a.y, a.w, a.h].every(Number.isFinite) ? { x: a.x, y: a.y, w: a.w, h: a.h } : null;
|
|
2068
|
+
if (ehApi) ehApi.tick();
|
|
2069
|
+
return;
|
|
2070
|
+
}
|
|
2043
2071
|
if (e.data.type !== "behold:boxes") return;
|
|
2044
2072
|
s.boxes = e.data;
|
|
2045
2073
|
// A held small stage: nothing the step shows overlays the graph (watchOverlays), and a drawer the viewer opens
|
|
@@ -2097,6 +2125,14 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2097
2125
|
? startEventHelp({
|
|
2098
2126
|
doc: document,
|
|
2099
2127
|
store: shelf,
|
|
2128
|
+
// behold#764: the story modals a viewer closes, for this visit only (never localStorage).
|
|
2129
|
+
session: (() => {
|
|
2130
|
+
try {
|
|
2131
|
+
return typeof sessionStorage !== "undefined" ? sessionStorage : null;
|
|
2132
|
+
} catch {
|
|
2133
|
+
return null;
|
|
2134
|
+
}
|
|
2135
|
+
})(),
|
|
2100
2136
|
switchHost: eh.switchHost,
|
|
2101
2137
|
trailHost: eh.trailHost,
|
|
2102
2138
|
tipsHost: eh.tipsHost,
|
|
@@ -2136,6 +2172,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2136
2172
|
// which the approval card beside the graph wins over.
|
|
2137
2173
|
hideTrail: !!(storyOn(s) && s.trackOn && s.watchMode),
|
|
2138
2174
|
waiting: storyOn(s) && s.watchMode && !(watch && watch.callout && !watch.callout.hidden) ? s.waitingNow || null : null,
|
|
2175
|
+
// behold#764: the card's details popover the frame has open (`behold:pop`), which no modal covers.
|
|
2176
|
+
pop: s.framePop || null,
|
|
2139
2177
|
frame,
|
|
2140
2178
|
watch: s.watchMode,
|
|
2141
2179
|
// The caption shown now: the live carve's while it has the camera (web/kiosk-carve.js).
|
|
@@ -2544,6 +2582,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2544
2582
|
buffer = null;
|
|
2545
2583
|
frameDrawn = true;
|
|
2546
2584
|
s.boxes = null;
|
|
2585
|
+
s.framePop = null; // behold#764: the old frame's details popover went with it
|
|
2547
2586
|
lastFocus = undefined;
|
|
2548
2587
|
tellFrame(true);
|
|
2549
2588
|
tellShot(true);
|
|
@@ -2609,6 +2648,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2609
2648
|
s.viewCommits = p.viewCommits || null;
|
|
2610
2649
|
if (s.aimed === null && p.viewRepo) s.aimed = p.viewRepo;
|
|
2611
2650
|
}
|
|
2651
|
+
if (p && !p.error) s.single = !Array.isArray(p.viewRepos);
|
|
2612
2652
|
// A chant project's graph is its components (web/app.js bootZoom), so it has that view too.
|
|
2613
2653
|
s.components = !!(p && !p.error && (p.terragucciComponents || chantProject(p)));
|
|
2614
2654
|
// behold#631: a chant project may run chant's pull-request loop; /api/chant/pr says (its `loop`).
|
package/web/tg-read-pills.js
CHANGED
|
@@ -120,3 +120,26 @@ export function pillSpots(box, p0, w, h, { gaps = [6, 18, 34], slides = [0, -0.3
|
|
|
120
120
|
export function nearestOn(r, p) {
|
|
121
121
|
return { x: Math.max(r.x, Math.min(p.x, r.x2)), y: Math.max(r.y, Math.min(p.y, r.y2)) };
|
|
122
122
|
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* behold#762: whether a read's root (a path, "apps/app-01", or a name) is the card `id` names: the components zoom names a
|
|
126
|
+
* card after the root, and the read after its path (tipComponentEdges matches them the same way).
|
|
127
|
+
*/
|
|
128
|
+
const sameEnd = (root, id) => !!root && !!id && (root === id || root.endsWith(`/${id}`));
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* behold#762: which dependency edges a read line already draws, so a pair gets one line, not two. `deps` are the graph's
|
|
132
|
+
* edges ({ from, to }, as pinhole names their ends); answers, for each, the key of the read (readKey) whose ends are the
|
|
133
|
+
* edge's, in either direction, or null when no read covers it.
|
|
134
|
+
*/
|
|
135
|
+
export function coveredEdges(reads, deps) {
|
|
136
|
+
return (deps || []).map((d) => {
|
|
137
|
+
const r = (reads || []).find((e) => (sameEnd(e.from, d.from) && sameEnd(e.to, d.to)) || (sameEnd(e.from, d.to) && sameEnd(e.to, d.from)));
|
|
138
|
+
return r ? readKey(r) : null;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** behold#762: what a dependency edge means, in the words its own tooltip had (behold#744), for the read line that stands for it. */
|
|
143
|
+
export function dependsLine(d) {
|
|
144
|
+
return `${d.from} → ${d.to}\n${d.from} depends on ${d.to}, so ${d.to} applies first`;
|
|
145
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { FLASH_MAX, FLASH_MS, createReadFlash, hotReads, nearestOn, pillSpots, readKey, readerStates } from "./tg-read-pills.js";
|
|
2
|
+
import { FLASH_MAX, FLASH_MS, coveredEdges, createReadFlash, dependsLine, hotReads, nearestOn, pillSpots, readKey, readerStates } from "./tg-read-pills.js";
|
|
3
3
|
|
|
4
4
|
// behold#744: the tofu fan-out's reads: cluster-a and cluster-b read network; app-01..06 read cluster-a.
|
|
5
5
|
const apps = ["app-01", "app-02", "app-03", "app-04", "app-05", "app-06"];
|
|
@@ -115,3 +115,44 @@ describe("where a pill goes (behold#744)", () => {
|
|
|
115
115
|
expect(nearestOn({ x: 0, y: 0, x2: 10, y2: 10 }, { x: -4, y: -4 })).toEqual({ x: 0, y: 0 });
|
|
116
116
|
});
|
|
117
117
|
});
|
|
118
|
+
|
|
119
|
+
describe("a read line stands for the dependency edge on its pair (behold#762)", () => {
|
|
120
|
+
// The tofu fan-out's dependency edges as pinhole draws them: each app on its cluster, each cluster on network.
|
|
121
|
+
const deps = [
|
|
122
|
+
{ from: "cluster-a", to: "network" },
|
|
123
|
+
{ from: "cluster-b", to: "network" },
|
|
124
|
+
...apps.map((a) => ({ from: a, to: "cluster-a" })),
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
it("covers every edge whose pair has a read, and names the read", () => {
|
|
128
|
+
expect(coveredEdges(edges, deps)).toEqual(deps.map((d) => readKey(d)));
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("leaves an edge with no read on its pair to draw itself", () => {
|
|
132
|
+
const reads = edges.filter((e) => e.from !== "app-03" && e.to !== "network");
|
|
133
|
+
const out = coveredEdges(reads, deps);
|
|
134
|
+
expect(out[0]).toBeNull();
|
|
135
|
+
expect(out[1]).toBeNull();
|
|
136
|
+
expect(out[deps.findIndex((d) => d.from === "app-03")]).toBeNull();
|
|
137
|
+
expect(out.filter(Boolean)).toHaveLength(5);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("matches the pair in either direction", () => {
|
|
141
|
+
expect(coveredEdges([{ from: "app-01", to: "cluster-a" }], [{ from: "cluster-a", to: "app-01" }])).toEqual(["app-01→cluster-a"]);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("matches a read named by its root's path to a card named after the root, and no other card", () => {
|
|
145
|
+
const reads = [{ from: "apps/app-01", to: "clusters/cluster-a" }];
|
|
146
|
+
expect(coveredEdges(reads, [{ from: "app-01", to: "cluster-a" }, { from: "app-1", to: "cluster-a" }, { from: "pp-01", to: "cluster-a" }])).toEqual(["apps/app-01→clusters/cluster-a", null, null]);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("covers nothing without reads (a chant repo) or without edges", () => {
|
|
150
|
+
expect(coveredEdges([], deps)).toEqual(deps.map(() => null));
|
|
151
|
+
expect(coveredEdges(undefined, deps)).toEqual(deps.map(() => null));
|
|
152
|
+
expect(coveredEdges(edges, [])).toEqual([]);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("says what the hidden edge meant", () => {
|
|
156
|
+
expect(dependsLine({ from: "app-01", to: "cluster-a" })).toBe("app-01 → cluster-a\napp-01 depends on cluster-a, so cluster-a applies first");
|
|
157
|
+
});
|
|
158
|
+
});
|
package/web/tooltip.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
// its words go into the shared tooltip; they go back when the pointer or the
|
|
11
11
|
// focus leaves. An HTML element can ask for the tooltip with data-tip.
|
|
12
12
|
|
|
13
|
+
import { shiftInto } from "./float-place.js";
|
|
14
|
+
|
|
13
15
|
export const TIP_ID = "b-tip";
|
|
14
16
|
/** The room between the tooltip and what it describes, and between it and the window's edge, in px. */
|
|
15
17
|
export const TIP_GAP = 8;
|
|
@@ -29,8 +31,9 @@ export function placeTip(target, size, view, { gap = TIP_GAP, margin = TIP_MARGI
|
|
|
29
31
|
const side = fitsBelow || above < margin ? "below" : "above";
|
|
30
32
|
const top = side === "below" ? below : above;
|
|
31
33
|
const centred = (target.left + target.right) / 2 - size.width / 2;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
// behold#764: inside the window on every side (web/float-place.js), its bottom too when it fits neither way.
|
|
35
|
+
const { dx, dy } = shiftInto({ left: centred, top, width: size.width, height: size.height }, { left: 0, top: 0, width: view.width, height: view.height }, margin);
|
|
36
|
+
return { left: Math.round(centred + dx), top: Math.round(top + dy), side };
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
/** An id list (aria-describedby) with `id` in it once. */
|