@intentius/behold 0.29.43 → 0.29.45
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/AGENTS.md +77 -0
- package/dist/cli.js +4065 -1918
- package/package.json +1 -1
- package/web/app.js +1469 -74
- package/web/carve-narration.js +33 -1
- package/web/chant-live-pace.js +138 -0
- package/web/chant-live-pace.test.js +116 -0
- package/web/chant-pr-marks.js +417 -39
- package/web/chant-pr-marks.test.js +208 -4
- package/web/collision-marks.js +124 -0
- package/web/collision-marks.test.js +89 -0
- package/web/cone.js +269 -0
- package/web/cone.test.js +213 -0
- package/web/dots-live.test.js +151 -1
- package/web/dots-lod.js +20 -0
- package/web/dots-lod.test.js +19 -1
- package/web/dots-scene.js +110 -10
- package/web/dots.js +144 -31
- package/web/embed.js +1 -1
- package/web/event-help-modal.js +98 -3
- package/web/event-help-modal.test.js +85 -1
- package/web/feature-flags.js +143 -0
- package/web/feature-flags.test.js +96 -0
- package/web/index.html +33 -0
- package/web/kiosk-carve.js +59 -6
- package/web/kiosk-demo-frame.test.js +27 -0
- package/web/kiosk-event-help-ui.js +186 -20
- package/web/kiosk-event-help.js +175 -15
- package/web/kiosk-event-help.test.js +58 -1
- package/web/kiosk-highlight.test.js +249 -0
- package/web/kiosk-metrics.js +4 -3
- package/web/kiosk-runs.js +8 -5
- package/web/kiosk-shot.js +157 -3
- package/web/kiosk-shot.test.js +223 -1
- package/web/kiosk-source.js +43 -0
- package/web/kiosk-source.test.js +39 -0
- package/web/kiosk-story-gate.test.js +44 -0
- package/web/kiosk-track.js +312 -0
- package/web/kiosk-track.test.js +148 -0
- package/web/kiosk-unknown-step.test.js +58 -0
- package/web/kiosk-vendor.js +73 -4
- package/web/kiosk-vendor.test.js +103 -3
- package/web/kiosk-watch.js +154 -1
- package/web/kiosk-watch.test.js +53 -1
- package/web/kiosk.html +57 -22
- package/web/kiosk.js +583 -53
- package/web/kiosk.test.js +2 -1
- package/web/small-stage.test.js +150 -0
- package/web/terragucci-blocked.test.js +192 -0
- package/web/terragucci-change.js +197 -17
- package/web/terragucci-components-live.js +189 -13
- package/web/terragucci-live-pace.js +92 -0
- package/web/terragucci-wave-results.test.js +125 -0
- package/web/terralith.html +7 -7
- package/web/tg-outside.js +124 -0
- package/web/tg-outside.test.js +100 -0
- package/web/tg-read-pills.js +145 -0
- package/web/tg-read-pills.test.js +158 -0
- package/web/theme.js +13 -1
- package/web/theme.test.js +21 -1
- package/web/tooltip.js +19 -7
- package/web/tooltip.test.js +15 -0
- package/web/tours/terralith.json +4 -4
- package/web/trunk-lane.test.js +1 -1
- package/web/view-url.js +8 -2
- package/web/why.js +129 -1
- package/web/why.test.js +113 -1
package/web/app.js
CHANGED
|
@@ -21,14 +21,18 @@ import { renderLane } from "./terragucci-lifecycle.js";
|
|
|
21
21
|
import { renderReleases } from "./releases.js";
|
|
22
22
|
import { renderTrunkLane } from "./trunk-lane.js";
|
|
23
23
|
import { entriesFor as csEntriesFor, gapLines as csGapLines, inspectHeading as csInspectHeading, nodeMarks as csNodeMarks, offGraph as csOffGraph, overlayHeader as csHeader, overlayLegend as csLegend, PREVIEW_NOTE as CS_PREVIEW_NOTE } from "./change-set-overlay.js";
|
|
24
|
+
import { collisionFilter as coFilter, collisionHeader as coHeader, collisionMarks as coMarks, collisionsFor as coFor, COLLISION_NOTE as CO_NOTE, FILES_NOTE as CO_FILES_NOTE, FILTER_OFF as CO_FILTER_OFF, FILTER_ON as CO_FILTER_ON, gapLines as coGapLines, hideEdge as coHideEdge, itemRow as coItemRow, nodeRow as coNodeRow, sideLines as coSideLines } from "./collision-marks.js";
|
|
25
|
+
import { flagMarks as flFlagMarks, flagRow as flFlagRow, flagsFor as flFlagsFor, flagsHeader as flHeader, gapLines as flGapLines, NODES_NOTE as FL_NODES_NOTE, pickEnv as flPickEnv, STALE_COLOR as FL_STALE_COLOR, TURN_ON_NOTE as FL_TURN_ON_NOTE } from "./feature-flags.js";
|
|
24
26
|
import { renderYodelLane } from "./sql-yodeler-lane.js";
|
|
25
27
|
import { initTerragucciEstate } from "./terragucci-estate.js";
|
|
26
28
|
import { chantComponentMarks } from "./chant-pr-marks.js";
|
|
29
|
+
import { createLivePacer } from "./chant-live-pace.js";
|
|
30
|
+
import { createProgressPacer } from "./terragucci-live-pace.js";
|
|
27
31
|
import { noStateFill } from "./frame-fill.js";
|
|
28
32
|
import { componentMarks as tgComponentMarks, runsCommit as tgRunsCommit, statusShort as tgStatusShort, waveOfKey as tgWaveOfKey } from "./terragucci-components-live.js";
|
|
29
33
|
import { FORGES, MARK, componentsForge, forgeOfName, iconSvg, markLink, markTitle, waveJobUrl } from "./forge-mark.js";
|
|
30
34
|
import { TOOLS, orderTools } from "./tool-mark.js";
|
|
31
|
-
import { STATE_WORDS as tgStateWords, changeSection as tgChangeSection, readCardIds as tgReadCardIds, readEdges as tgReadEdges, readLabel as tgReadLabel, readLine as tgReadLine, readTag as tgReadTag, rootStates as tgRootStates, viewCaption as tgViewCaption, pinnedAnswer as tgPinnedAnswer, pinnedCaption as tgPinnedCaption, pinsCommit as tgPinsCommit } from "./terragucci-change.js";
|
|
35
|
+
import { STATE_WORDS as tgStateWords, changeSection as tgChangeSection, readCardIds as tgReadCardIds, readEdges as tgReadEdges, readLabel as tgReadLabel, readLine as tgReadLine, readTag as tgReadTag, rootStates as tgRootStates, viewCaption as tgViewCaption, pinnedAnswer as tgPinnedAnswer, pinnedCaption as tgPinnedCaption, pinsCommit as tgPinsCommit, pinWaits as tgPinWaits } from "./terragucci-change.js";
|
|
32
36
|
import { auditLines as yrAuditLines, cornerText as yrCorner, datedWords as yrDated, environmentLines as yrEnvLines, joinMarks as yrJoin, legend as yrLegend, markLine as yrMarkLine } from "./yodel-report.js";
|
|
33
37
|
import { cardProgress as tgCardProgress, progressLines as tgProgressLines, progressSection as tgProgressSection, stampProgress as tgStampProgress } from "./terragucci-progress.js";
|
|
34
38
|
import { seconds, whyQuery, whyView } from "./why.js";
|
|
@@ -116,14 +120,18 @@ import { danglingFor, danglingRows, danglingHeading, DANGLING_EXPLAINED } from "
|
|
|
116
120
|
import { comparisonRow, comparisonSummary } from "./cross-env.js";
|
|
117
121
|
// The marker-vs-derived mark on a choudoufu card: how its identity was found.
|
|
118
122
|
import { identityMark, tagGlyphSvg } from "./identity-mark.js";
|
|
119
|
-
import { shotFromMessage, shotViewBox, tweenViewBox, unionBox, sameViewBox } from "./kiosk-shot.js"; // behold#571: Watch's camera
|
|
123
|
+
import { shotFromMessage, shotViewBox, tweenViewBox, unionBox, sameViewBox, heldFrame, heldInsets, heldTarget, holdsStage, medianWidth, smallStage } from "./kiosk-shot.js"; // behold#571: Watch's camera
|
|
120
124
|
// #712, #715: the dots layer, the zoom past the cards. Mounted for a live
|
|
121
125
|
// carve when the estate has choudoufu roots or estate rosters
|
|
122
126
|
// (/api/terragucci/carve, liveCarveGate below), or when /api/graph's meta
|
|
123
127
|
// carries `dots` (the local preview server, scripts/dots-preview.ts). With
|
|
124
128
|
// neither it stays unmounted, and its hooks below are no-ops.
|
|
125
|
-
import { mountDots, unmountDots, dotsCamera, dotsZoomOutFactor, dotsCarving, dotsMinViewWidth } from "./dots.js";
|
|
129
|
+
import { mountDots, unmountDots, dotsCamera, dotsZoomOutFactor, dotsCarving, dotsMinViewWidth, setDotsCone } from "./dots.js";
|
|
130
|
+
// Report minor 34: a cone plan's lights, on the cards and the dots (web/cone.js).
|
|
131
|
+
import { cardRoot as coneCardRoot, coneLights, coneOf, resourceLight as coneResourceLight, rootLight as coneRootLight, wrapWords } from "./cone.js";
|
|
126
132
|
import { carveDrawable } from "./dots-live.js";
|
|
133
|
+
import { FLASH_MS as TG_FLASH_MS, coveredEdges as tgCoveredEdges, createReadFlash, dependsLine as tgDependsLine, hotReads as tgHotReads, nearestOn as tgNearestOn, pillSpots as tgPillSpots, readKey as tgReadKey, readerStates as tgReaderStates } from "./tg-read-pills.js"; // behold#744
|
|
134
|
+
import { outsideCard as tgOutsideCard, outsideModel as tgOutsideModel, outsideSpots as tgOutsideSpots } from "./tg-outside.js"; // behold#743
|
|
127
135
|
initTheme();
|
|
128
136
|
// #476: framed in a host pane. The flag is a class on <html>, so the CSS that
|
|
129
137
|
// folds the chrome away needs no JS, and the theme is the host's for this
|
|
@@ -694,7 +702,7 @@ function renderWhySection(panel, ask) {
|
|
|
694
702
|
box.replaceChildren();
|
|
695
703
|
const p = document.createElement("p");
|
|
696
704
|
p.className = "queried";
|
|
697
|
-
p.textContent = note || `The decisions that cover ${ask.node ? "this card" : `member ${memberName}`},
|
|
705
|
+
p.textContent = note || `The decisions that cover ${ask.node ? "this card" : `member ${memberName}`}, the runs and commits behind it, and the chain from each commit's work item to its release, from chant workspace graph --intent. Reading walks the repository's history; on a large one it takes a while.`;
|
|
698
706
|
box.append(p, button("Read why", "Ask chant now. Nothing is read until you click.", read));
|
|
699
707
|
};
|
|
700
708
|
const read = async () => {
|
|
@@ -795,6 +803,7 @@ function paintWhy(box, answer, again) {
|
|
|
795
803
|
return li(lead, c.subject, c.meta);
|
|
796
804
|
});
|
|
797
805
|
for (const g of v.gaps) para(g, "why-gap");
|
|
806
|
+
if (v.chain) paintChain(box, v.chain, para);
|
|
798
807
|
}
|
|
799
808
|
if (v.footer) para(v.footer, "queried");
|
|
800
809
|
const b = document.createElement("button");
|
|
@@ -806,6 +815,61 @@ function paintWhy(box, answer, again) {
|
|
|
806
815
|
box.appendChild(b);
|
|
807
816
|
}
|
|
808
817
|
|
|
818
|
+
/**
|
|
819
|
+
* #682: the chain under the why, one entry per commit chant walked, each link
|
|
820
|
+
* a row: what it is, chant's words for it, and the git line that opens its
|
|
821
|
+
* source record with a copy button. A missing link is drawn as missing, in
|
|
822
|
+
* the pending colour, with chant's reason.
|
|
823
|
+
*/
|
|
824
|
+
function paintChain(box, chain, para) {
|
|
825
|
+
const t = document.createElement("div");
|
|
826
|
+
t.className = "why-head";
|
|
827
|
+
t.textContent = `chain, from work item to release${chain.more ? ` · ${chain.commits.length} of ${chain.commits.length + chain.more} commits` : ""}`;
|
|
828
|
+
box.appendChild(t);
|
|
829
|
+
for (const r of chain.reasons) para(r, "why-gap");
|
|
830
|
+
if (chain.note) {
|
|
831
|
+
para(chain.note, "why-gap");
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
const ul = document.createElement("ul");
|
|
835
|
+
ul.className = "why-list why-chain";
|
|
836
|
+
for (const c of chain.commits) {
|
|
837
|
+
const li = document.createElement("li");
|
|
838
|
+
const top = document.createElement("div");
|
|
839
|
+
const sha = document.createElement("code");
|
|
840
|
+
sha.textContent = c.sha;
|
|
841
|
+
top.append(sha, c.subject ? ` ${c.subject}` : "");
|
|
842
|
+
li.appendChild(top);
|
|
843
|
+
for (const row of c.rows) {
|
|
844
|
+
const el = document.createElement("div");
|
|
845
|
+
el.className = row.missing ? "why-link why-missing" : "why-link";
|
|
846
|
+
const label = document.createElement("span");
|
|
847
|
+
label.className = "why-meta";
|
|
848
|
+
label.textContent = `${row.label} `;
|
|
849
|
+
el.append(label, row.text);
|
|
850
|
+
if (row.meta) {
|
|
851
|
+
const m = document.createElement("div");
|
|
852
|
+
m.className = "why-meta";
|
|
853
|
+
m.textContent = row.meta;
|
|
854
|
+
el.appendChild(m);
|
|
855
|
+
}
|
|
856
|
+
if (row.source) {
|
|
857
|
+
const src = document.createElement("div");
|
|
858
|
+
src.className = "why-source";
|
|
859
|
+
const line = document.createElement("code");
|
|
860
|
+
line.textContent = row.source.open;
|
|
861
|
+
line.title = row.source.title;
|
|
862
|
+
const copy = actButton("copy", () => copyToClipboard(row.source.open, copy), `Copy the line that opens this link's source record:\n${row.source.open}`);
|
|
863
|
+
src.append(line, copy);
|
|
864
|
+
el.appendChild(src);
|
|
865
|
+
}
|
|
866
|
+
li.appendChild(el);
|
|
867
|
+
}
|
|
868
|
+
ul.appendChild(li);
|
|
869
|
+
}
|
|
870
|
+
box.appendChild(ul);
|
|
871
|
+
}
|
|
872
|
+
|
|
809
873
|
/** A member's box was picked: what the declaration says of it, and its why. */
|
|
810
874
|
function inspectMember(name) {
|
|
811
875
|
const m = declaredMember(name);
|
|
@@ -969,6 +1033,32 @@ function inspect(node) {
|
|
|
969
1033
|
panel.appendChild(h);
|
|
970
1034
|
for (const e of csEntries) panel.appendChild(csEntryEl(e));
|
|
971
1035
|
}
|
|
1036
|
+
// #683: the feature flags of this card's member, in the environment the Flags tab draws.
|
|
1037
|
+
const flRows = flAnswer && flOn ? flFlagsFor(flAnswer, nodeMember(node.id), flEnv) : [];
|
|
1038
|
+
if (flRows.length) {
|
|
1039
|
+
const h = document.createElement("h3");
|
|
1040
|
+
h.textContent = "feature flags";
|
|
1041
|
+
h.title = FL_NODES_NOTE;
|
|
1042
|
+
panel.appendChild(h);
|
|
1043
|
+
for (const r of flRows) {
|
|
1044
|
+
const row = panelDotRow(r.color, r.text, "");
|
|
1045
|
+
row.title = r.title;
|
|
1046
|
+
panel.appendChild(row);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
// #684: the in-flight work items colliding on this card.
|
|
1050
|
+
const coRows = coAnswer && coOn ? coFor(coAnswer, node.id) : [];
|
|
1051
|
+
if (coRows.length) {
|
|
1052
|
+
const h = document.createElement("h3");
|
|
1053
|
+
h.textContent = "colliding work";
|
|
1054
|
+
h.title = CO_NOTE;
|
|
1055
|
+
panel.appendChild(h);
|
|
1056
|
+
for (const r of coRows) {
|
|
1057
|
+
const row = panelDotRow(r.color, r.text, "");
|
|
1058
|
+
row.title = r.title;
|
|
1059
|
+
panel.appendChild(row);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
972
1062
|
// #526: SQL Yodeler's drift on this card, each dated by its file.
|
|
973
1063
|
const yrMarks = yrJoined && yrJoined.cards[node.id];
|
|
974
1064
|
if (yrMarks && yrMarks.length) {
|
|
@@ -2539,6 +2629,7 @@ function applyWantedView(want) {
|
|
|
2539
2629
|
if ("gates" in apply) view.gates = apply.gates;
|
|
2540
2630
|
if ("focus" in apply) view.focus = apply.focus; // #569: drawn by drawTgReads, no new read
|
|
2541
2631
|
if ("run" in apply) view.run = apply.run; // #569: which run the view draws; read in the message handler
|
|
2632
|
+
if ("pull" in apply) view.pull = apply.pull; // the cycle's pull request: a commit's run never draws another's plan
|
|
2542
2633
|
if (want.member === null) {
|
|
2543
2634
|
view.member = null;
|
|
2544
2635
|
selectedNodeId = null;
|
|
@@ -2564,10 +2655,14 @@ window.addEventListener("message", (e) => {
|
|
|
2564
2655
|
const gatesBefore = view.gates;
|
|
2565
2656
|
const focusBefore = view.focus;
|
|
2566
2657
|
const runBefore = view.run;
|
|
2658
|
+
const pullBefore = view.pull;
|
|
2567
2659
|
const moved = applyWantedView(want);
|
|
2568
|
-
if (view.run !== runBefore) {
|
|
2569
|
-
void loadTgProgress({ fresh: true }); // #569: the run the narration is about
|
|
2660
|
+
if (view.run !== runBefore || view.pull !== pullBefore) {
|
|
2661
|
+
if (tgServed) void loadTgProgress({ fresh: true }); // #569: the run the narration is about
|
|
2570
2662
|
if (chantFacets) void loadChantPr(); // behold#631
|
|
2663
|
+
// The reports too, read fresh now, and again every few seconds while the pin's plan or run isn't written yet:
|
|
2664
|
+
// the reports a frame read a step ago don't hold this cycle's pull request.
|
|
2665
|
+
if (tgAnswer && embedOpts.bare) void refreshTgAnswer();
|
|
2571
2666
|
}
|
|
2572
2667
|
else if (view.focus !== focusBefore && !moved) drawTgReads(); // #569
|
|
2573
2668
|
// #477: the host's env for the gate strip moved. Read it now, not on the
|
|
@@ -3458,10 +3553,13 @@ let tgAnswer = null;
|
|
|
3458
3553
|
let tgHost = null;
|
|
3459
3554
|
let tgTimeline = null; // #506: /api/terragucci/timeline, the audit record's lane
|
|
3460
3555
|
let tgHistory = null; // #522: /api/lifecycle/history, the gate ledgers' history
|
|
3556
|
+
/** behold#752: whether serve reads terragucci's reports; without them a pin's run view is never asked (chant's demo has none). */
|
|
3557
|
+
let tgServed = false;
|
|
3461
3558
|
async function initTerragucci() {
|
|
3462
3559
|
const project = await apiFetch("/api/project").then((r) => r.json()).catch(() => ({}));
|
|
3463
3560
|
kioskRoots = project.terragucciRoots || null; // behold#571
|
|
3464
3561
|
if (!project.terragucciReports) return;
|
|
3562
|
+
tgServed = true;
|
|
3465
3563
|
// #715: the live carve's gate, asked beside the reports; closed, nothing below changes.
|
|
3466
3564
|
if (!staticMode) void liveCarveGate();
|
|
3467
3565
|
await loadTerragucci();
|
|
@@ -3507,6 +3605,8 @@ function mountLiveCarve(g, svgEl) {
|
|
|
3507
3605
|
vbInit: vbInit.slice(),
|
|
3508
3606
|
getVB: () => vb,
|
|
3509
3607
|
setVB: (a) => {
|
|
3608
|
+
// A held small stage in Watch keeps its one framing: only the carve's director moves the camera then.
|
|
3609
|
+
if (kioskHeld && kioskShot && !dotsCarving()) return;
|
|
3510
3610
|
vb = a.slice();
|
|
3511
3611
|
vbAtFit = false;
|
|
3512
3612
|
applyVB();
|
|
@@ -3575,6 +3675,38 @@ async function loadTerragucci({ fresh = false } = {}) {
|
|
|
3575
3675
|
renderTerragucciPanel();
|
|
3576
3676
|
markTerragucciCards();
|
|
3577
3677
|
if (!staticMode) await loadTgProgress({ fresh });
|
|
3678
|
+
tgRefreshSoon();
|
|
3679
|
+
}
|
|
3680
|
+
/**
|
|
3681
|
+
* The kiosk's frame is pinned to one step's run (#569) and swapped for the next step's, so it reads again soon while
|
|
3682
|
+
* what its pin names isn't written yet: the pull request's plan (the plan job is still running), or the merge's run
|
|
3683
|
+
* view (the waves have not started). The plan then lights from planned on, and the waves' own states take over as
|
|
3684
|
+
* soon as their run view is there, without waiting for the reports poll.
|
|
3685
|
+
*/
|
|
3686
|
+
var tgSoon = null;
|
|
3687
|
+
var TG_SOON_MS = 5_000;
|
|
3688
|
+
/** The reports alone, read fresh and drawn at once: the timeline and the gate ledgers' history (slow reads) wait for the next full read. */
|
|
3689
|
+
async function refreshTgAnswer() {
|
|
3690
|
+
const answer = await apiFetch("/api/terragucci?fresh=1")
|
|
3691
|
+
.then((r) => r.json())
|
|
3692
|
+
.catch((e) => ({ error: String(e), code: "terragucci-report", remedy: "" }));
|
|
3693
|
+
if (!answer.error || !tgAnswer) tgAnswer = answer;
|
|
3694
|
+
renderTerragucciPanel();
|
|
3695
|
+
markTerragucciCards();
|
|
3696
|
+
drawTgReads();
|
|
3697
|
+
tgRefreshSoon();
|
|
3698
|
+
}
|
|
3699
|
+
function tgRefreshSoon() {
|
|
3700
|
+
if (!embedOpts.bare || staticMode || tgSoon) return;
|
|
3701
|
+
const waits = tgPinWaits(tgAnswer, tgProgress, view.run, view.pull || null);
|
|
3702
|
+
if (!waits.plan && !waits.run) return;
|
|
3703
|
+
tgSoon = setTimeout(() => {
|
|
3704
|
+
tgSoon = null;
|
|
3705
|
+
// Asked again now: the pin may have moved while the timer ran.
|
|
3706
|
+
const now = tgPinWaits(tgAnswer, tgProgress, view.run, view.pull || null);
|
|
3707
|
+
if (now.plan) void refreshTgAnswer();
|
|
3708
|
+
else if (now.run) void loadTgProgress({ fresh: true }).then(tgRefreshSoon);
|
|
3709
|
+
}, TG_SOON_MS);
|
|
3578
3710
|
}
|
|
3579
3711
|
// #511: /api/terragucci/progress, the newest apply's run view on the cards.
|
|
3580
3712
|
let tgProgress = null;
|
|
@@ -3606,7 +3738,7 @@ function tgPushFits(answer) {
|
|
|
3606
3738
|
}
|
|
3607
3739
|
/** #569: the reports as the view draws them: at `run=base` no pull request, at `run=pull-<n>` only that one's plan. */
|
|
3608
3740
|
function tgAnswerDrawn() {
|
|
3609
|
-
return tgPinnedAnswer(tgAnswer, view.run);
|
|
3741
|
+
return tgPinnedAnswer(tgAnswer, view.run, view.pull || null);
|
|
3610
3742
|
}
|
|
3611
3743
|
function paintTgProgress() {
|
|
3612
3744
|
tgStampProgress(document.querySelector("#graph svg"), tgProgress, new Date());
|
|
@@ -3636,6 +3768,9 @@ function drawTgReads() {
|
|
|
3636
3768
|
if (!svg) return;
|
|
3637
3769
|
drawPipelineMarks(svg); // behold#571: the forge and tool marks, before the wave boxes' status finds room around them
|
|
3638
3770
|
for (const old of svg.querySelectorAll("[data-tg-reads]")) old.remove();
|
|
3771
|
+
tgReadEdgesNow = []; // behold#744
|
|
3772
|
+
// behold#762: an edge a read line stood for comes back; this draw hides the ones its own lines stand for.
|
|
3773
|
+
for (const g of svg.querySelectorAll("g[data-tg-read-covers]")) g.removeAttribute("data-tg-read-covers");
|
|
3639
3774
|
for (const old of svg.querySelectorAll("[data-tg-root]")) old.remove();
|
|
3640
3775
|
for (const r of svg.querySelectorAll("rect[data-tg-stroke0]")) {
|
|
3641
3776
|
r.setAttribute("stroke", r.getAttribute("data-tg-stroke0"));
|
|
@@ -3643,6 +3778,11 @@ function drawTgReads() {
|
|
|
3643
3778
|
r.removeAttribute("data-tg-stroke0");
|
|
3644
3779
|
r.removeAttribute("data-tg-width0");
|
|
3645
3780
|
}
|
|
3781
|
+
// A card grown to hold a cone's lines goes back to its own height (drawTgComponentMarks).
|
|
3782
|
+
for (const r of svg.querySelectorAll("rect[data-tg-h0]")) {
|
|
3783
|
+
r.setAttribute("height", r.getAttribute("data-tg-h0"));
|
|
3784
|
+
r.removeAttribute("data-tg-h0");
|
|
3785
|
+
}
|
|
3646
3786
|
for (const r of svg.querySelectorAll("[data-tg-fill0]")) {
|
|
3647
3787
|
r.setAttribute("fill", r.getAttribute("data-tg-fill0"));
|
|
3648
3788
|
r.removeAttribute("data-tg-fill0");
|
|
@@ -3657,6 +3797,8 @@ function drawTgReads() {
|
|
|
3657
3797
|
}
|
|
3658
3798
|
// behold#631: a chant repo's pull-request loop marks its components from chant's records, not terragucci's reports.
|
|
3659
3799
|
const chantMode = chantPrDrawn();
|
|
3800
|
+
// Report minor 34: last draw's cone lights go; drawConeLights sets this draw's.
|
|
3801
|
+
if (chantMode || !tgAnswer || tgAnswer.error || !tgAnswer.roots) drawConeLights(svg, { stage: null });
|
|
3660
3802
|
if (!chantMode && (!tgAnswer || tgAnswer.error || !tgAnswer.roots)) return;
|
|
3661
3803
|
const toSvg = svg.getScreenCTM && svg.getScreenCTM();
|
|
3662
3804
|
if (!toSvg) return;
|
|
@@ -3710,14 +3852,25 @@ function drawTgReads() {
|
|
|
3710
3852
|
return n;
|
|
3711
3853
|
};
|
|
3712
3854
|
if (chantMode) {
|
|
3713
|
-
|
|
3855
|
+
// behold#631: a kiosk passer-by can't place a card's type glyph (it reads as a checkbox): a chant repo's kiosk hides it.
|
|
3856
|
+
if (embedOpts.bare) kioskCardGlyphs(svg);
|
|
3857
|
+
const chantMarks = chantComponentMarks(chantPaced(), chantFacets, { kiosk: !!embedOpts.bare });
|
|
3858
|
+
if (embedOpts.bare) chantKioskWaves(svg, boxOf, chantMarks.waveFont || 18);
|
|
3859
|
+
drawTgComponentMarks(svg, { marks: chantMarks, focus: null, boxOf, make, edgePoints: chantEdgePoints(svg) });
|
|
3860
|
+
drawReach(svg, chantMarks.reach || null, boxOf, chantMarks.waveFont || 18);
|
|
3861
|
+
tipComponentEdges(svg); // behold#744
|
|
3714
3862
|
return;
|
|
3715
3863
|
}
|
|
3716
3864
|
const layer = make("g", { "data-tg-reads": "1", "pointer-events": "none" });
|
|
3717
3865
|
svg.appendChild(layer); // over the boxes and cards: the lines end at the borders, and the labels carry a background
|
|
3866
|
+
// behold#744: the read lines' pointer targets, under the cards (a line crossing a card leaves the card its pointer) and over the edges.
|
|
3867
|
+
const hits = make("g", { "data-tg-reads": "hits" });
|
|
3868
|
+
let under = svg.querySelector("[data-node-id]");
|
|
3869
|
+
while (under && under.parentNode !== svg) under = under.parentNode;
|
|
3870
|
+
svg.insertBefore(hits, under || layer);
|
|
3718
3871
|
// A pill of text with a background, centred on (cx, cy); measured once it is in the svg.
|
|
3719
|
-
const pill = (parent, cx, cy, text, { stroke, fill = "var(--panel)", color = "var(--fg)", size = 13, weight = 600, anchor = "middle", cls = "" } = {}) => {
|
|
3720
|
-
const g = make("g", cls ? { class: cls } : {});
|
|
3872
|
+
const pill = (parent, cx, cy, text, { stroke, fill = "var(--panel)", color = "var(--fg)", size = 13, weight = 600, anchor = "middle", cls = "", attrs = {} } = {}) => {
|
|
3873
|
+
const g = make("g", { ...(cls ? { class: cls } : {}), ...attrs }); // behold#744: a read's pill is hidden from its first style, never faded out
|
|
3721
3874
|
const rect = make("rect", { rx: 6, fill, stroke: stroke || "var(--rule)", "stroke-width": 1.5 });
|
|
3722
3875
|
const t = make("text", { x: cx, y: cy, "text-anchor": anchor, "dominant-baseline": "central", "font-size": size, "font-weight": weight, fill: color }, text);
|
|
3723
3876
|
g.append(rect, t);
|
|
@@ -3825,11 +3978,33 @@ function drawTgReads() {
|
|
|
3825
3978
|
}
|
|
3826
3979
|
}
|
|
3827
3980
|
|
|
3981
|
+
// Report minor 34: a cone plan lights what it planned and dims the rest, never hiding it (web/cone.js).
|
|
3982
|
+
drawConeLights(svg, { stage: states.stage, drawnAnswer, compMode, componentsOfRoot, rootOf });
|
|
3983
|
+
|
|
3984
|
+
// behold#762: one line per pair. Where a read joins the two cards a dependency edge joins (either way round), the read's
|
|
3985
|
+
// line says both, so the edge is hidden (not removed: the layout and every index of the edges stay as they were), before
|
|
3986
|
+
// the read lines are routed clear of the edges that still show. An edge whose read draws no line shows again below.
|
|
3987
|
+
const edges = tgReadEdges(drawnAnswer, tgProgress);
|
|
3988
|
+
const depEdges = compMode ? [...svg.querySelectorAll("g[data-edge-from]")] : [];
|
|
3989
|
+
tgCoveredEdges(edges, depEdges.map((g) => ({ from: g.getAttribute("data-edge-from"), to: g.getAttribute("data-edge-to") }))).forEach((key, i) => key && depEdges[i].setAttribute("data-tg-read-covers", key));
|
|
3990
|
+
if (depEdges.length) ensureTgReadStyle();
|
|
3828
3991
|
// #571: the components zoom's own marks; its wave boxes are the boxes the caption and the labels keep clear of.
|
|
3829
3992
|
const edgePoints = compMode ? chantEdgePoints(svg) : [];
|
|
3993
|
+
let readMarks = null; // behold#744: the cards' and waves' states (a story's paced) that a read's pill flashes on
|
|
3830
3994
|
if (compMode) {
|
|
3831
3995
|
boxes.length = 0;
|
|
3832
|
-
|
|
3996
|
+
// behold#741: a kiosk telling a chapter-carrying scenario looks as chant's loop does: no type glyph, the waves
|
|
3997
|
+
// read bottom to top, the bigger words, and the reach wedge. Without a chapter, today's marks alone.
|
|
3998
|
+
const story = tgStoryMarks();
|
|
3999
|
+
if (story) kioskCardGlyphs(svg);
|
|
4000
|
+
const marks = story ? tgComponentMarks(drawnAnswer, tgPacedProgress(), tgComponentFacets, { runs: tgRuns, pin: view.run || null, story }) : null;
|
|
4001
|
+
if (marks) {
|
|
4002
|
+
readMarks = marks;
|
|
4003
|
+
tgStoryRemember(marks);
|
|
4004
|
+
chantKioskWaves(svg, boxOf, marks.waveFont || 18);
|
|
4005
|
+
}
|
|
4006
|
+
boxes.push(...drawTgComponentMarks(svg, { drawnAnswer, focus, boxOf, make, edgePoints, ...(marks ? { marks } : {}) }));
|
|
4007
|
+
if (marks) drawReach(svg, marks.reach || null, boxOf, marks.waveFont || 18, marks.needs || {});
|
|
3833
4008
|
}
|
|
3834
4009
|
|
|
3835
4010
|
// The reads. #569 review: no line or label crosses text. Each line is the
|
|
@@ -3837,7 +4012,7 @@ function drawTgReads() {
|
|
|
3837
4012
|
// on the read root's box border, that crosses no text and as few cards as
|
|
3838
4013
|
// there are; each label then sits beside its line where it covers no text
|
|
3839
4014
|
// and crosses no line.
|
|
3840
|
-
|
|
4015
|
+
if (compMode) tipComponentEdges(svg, edges); // behold#744
|
|
3841
4016
|
const centre = (b) => ({ x: (b.x + b.x2) / 2, y: (b.y + b.y2) / 2 });
|
|
3842
4017
|
const grow = (b, d) => ({ x: b.x - d, y: b.y - d, x2: b.x2 + d, y2: b.y2 + d });
|
|
3843
4018
|
// Whether the segment p-q passes through the box (Liang-Barsky).
|
|
@@ -3943,70 +4118,94 @@ function drawTgReads() {
|
|
|
3943
4118
|
}
|
|
3944
4119
|
if (!best) continue;
|
|
3945
4120
|
const { p0, p1 } = best;
|
|
3946
|
-
const
|
|
3947
|
-
line
|
|
4121
|
+
const key = tgReadKey(e);
|
|
4122
|
+
const line = make("line", { x1: p0.x, y1: p0.y, x2: p1.x, y2: p1.y, stroke: color, "stroke-width": 3, "stroke-dasharray": e.outputs === "planned" ? "9 6" : "none", "marker-end": `url(#tg-arrow-${kind})`, "data-tg-read-from": e.from, "data-tg-read-to": e.to, "data-tg-read": key });
|
|
3948
4123
|
if (focus && !(focus.has(e.from) || focus.has(e.to))) line.style.opacity = "0.5";
|
|
3949
4124
|
layer.appendChild(line);
|
|
4125
|
+
// behold#744: a wide clear stroke along the line takes the pointer (the drawn layer lets it through): pointing at it shows the
|
|
4126
|
+
// read's pill; outside a kiosk frame the shared tooltip adds the whole sentence (data-tip, no <title>: no second, native one).
|
|
4127
|
+
// behold#762: a line that stands for a hidden dependency edge says what the edge said too, in a kiosk frame as well.
|
|
4128
|
+
const stands = depEdges.filter((g) => g.getAttribute("data-tg-read-covers") === key).map((g) => tgDependsLine({ from: g.getAttribute("data-edge-from"), to: g.getAttribute("data-edge-to") }));
|
|
4129
|
+
const tip = stands.length ? [...stands, tgReadLine(e)].join("\n") : embedOpts.bare ? null : tgReadLine(e);
|
|
4130
|
+
hits.appendChild(make("line", { x1: p0.x, y1: p0.y, x2: p1.x, y2: p1.y, stroke: "transparent", "stroke-width": 16, "pointer-events": "stroke", "data-tg-read-hit": key, ...(tip ? { "data-tip": tip } : {}) }));
|
|
3950
4131
|
drawn.push({ p0, p1 });
|
|
3951
|
-
labels.push({ e, p0, p1, color, kind });
|
|
4132
|
+
labels.push({ e, p0, p1, color, kind, key, fromBox });
|
|
3952
4133
|
}
|
|
4134
|
+
// behold#762: a read that found no route (or no card) drew no line: its pair keeps the dependency edge.
|
|
4135
|
+
const lined = new Set(labels.map((l) => l.key));
|
|
4136
|
+
for (const g of depEdges) if (g.hasAttribute("data-tg-read-covers") && !lined.has(g.getAttribute("data-tg-read-covers"))) g.removeAttribute("data-tg-read-covers");
|
|
3953
4137
|
// behold#571: the marks step aside from the read lines, and a box lifts its marks off an arrowhead (its box then reaches higher).
|
|
3954
4138
|
for (const [rect] of clearMarksOfReads(svg, drawn)) {
|
|
3955
4139
|
const now = boxOf(rect);
|
|
3956
4140
|
for (const b of boxes) if (now && Math.abs(b.x - now.x) < 0.5 && Math.abs(b.x2 - now.x2) < 0.5 && Math.abs(b.y2 - now.y2) < 0.5) b.y = now.y;
|
|
3957
4141
|
}
|
|
3958
|
-
//
|
|
3959
|
-
//
|
|
4142
|
+
// behold#744: each read's words in a pill at the reader's end of its line, beside the reader's card and joined to it by a
|
|
4143
|
+
// short leader in the line's colour: covering no text where it can, never out in open ground. Drawn hidden; the pointer
|
|
4144
|
+
// (on the reader, the root it reads or the line), a kiosk's flash or an Inspect focus shows it (tgReadShow).
|
|
3960
4145
|
const cardBoxes = cardEls.map((g) => cardBoxOf.get(g)).filter(Boolean);
|
|
3961
4146
|
const headers = boxes.map((b) => ({ x: b.x, y: b.y - 14, x2: b.x2, y2: b.y + 36 }));
|
|
3962
4147
|
const placed = [];
|
|
4148
|
+
const pillsBy = []; // behold#743: each pill's rect and its reader, shown or not
|
|
3963
4149
|
const overlap = (r, b) => Math.max(0, Math.min(r.x2, b.x2) - Math.max(r.x, b.x)) * Math.max(0, Math.min(r.y2, b.y2) - Math.max(r.y, b.y));
|
|
3964
4150
|
const sum = (r, list, k) => list.reduce((a, b) => a + k * overlap(r, b), 0);
|
|
3965
|
-
|
|
4151
|
+
const span = union(boxes);
|
|
4152
|
+
// A kiosk with no chapters flashes on the marks drawTgComponentMarks drew from the same reads (wave jobs' status included).
|
|
4153
|
+
if (embedOpts.bare && compMode && !readMarks) readMarks = tgComponentMarks(drawnAnswer, tgProgress, tgComponentFacets, { runs: tgRuns, pin: view.run || null });
|
|
4154
|
+
const flash = embedOpts.bare ? new Map(tgReadFlash.live(edges, tgReaderStates(readMarks, states.roots)).map((f) => [f.key, f.age])) : new Map();
|
|
4155
|
+
// The flashing pills first: they show together, so each keeps clear of the others; a hidden one only shows with its own root's.
|
|
4156
|
+
const lit = [];
|
|
4157
|
+
for (const l of [...labels].sort((a, b) => Number(flash.has(b.key)) - Number(flash.has(a.key)))) {
|
|
3966
4158
|
const words = `${l.e.from} ${tgReadLabel(l.e)}`;
|
|
3967
|
-
const size = 13;
|
|
3968
|
-
const
|
|
3969
|
-
const h =
|
|
3970
|
-
|
|
3971
|
-
const dy = l.p1.y - l.p0.y;
|
|
3972
|
-
let best = null;
|
|
3973
|
-
// behold#571: the label's own line may run under it; every other read line may not.
|
|
4159
|
+
const size = embedOpts.bare ? 15 : 13; // a kiosk's card words are bigger too
|
|
4160
|
+
const p = pill(layer, 0, 0, words, { stroke: l.color, fill: "var(--bg)", color: "var(--fg)", size, weight: 600, attrs: { "data-tg-read-pill": "1", "data-tg-read": l.key } });
|
|
4161
|
+
const { w, h } = p;
|
|
4162
|
+
// The pill's own line may run under it; every other read line costs, though only a few pills show at once.
|
|
3974
4163
|
const others = drawn.filter((d) => !(d.p0 === l.p0 && d.p1 === l.p1));
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
}
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
// Outside the boxes' own span the label may leave the drawing when the view is fitted: keep it in.
|
|
3992
|
-
// behold#571: never above the top box, where the caption says which run the marks are from.
|
|
3993
|
-
const span = union(boxes);
|
|
3994
|
-
const out = span ? (r.x2 - r.x) * (r.y2 - r.y) - overlap(r, { x: span.x - 40, y: span.y, x2: span.x2 + 40, y2: span.y2 + 40 }) : 0;
|
|
3995
|
-
// behold#571: a card or a box's title row under the words costs as much as text does, so a label sits on open ground between boxes.
|
|
3996
|
-
// A dependency line under a label costs less than a card or text does, and far less than another read's line.
|
|
3997
|
-
const score = out * 80 + lineHits * 1e6 + edgeIn(r) * 30 + Math.hypot(c.x - m.x, c.y - m.y) * 2 + sum(r, textBoxes, 50) + sum(r, placed, 50) + sum(r, cardBoxes, 50) + sum(r, headers, 40) + sum(r, boxes, 0.15) + Math.abs(t - 0.5) * 300 + c.off * 4;
|
|
3998
|
-
if (!best || score < best.score) best = { c, r, score };
|
|
3999
|
-
}
|
|
4164
|
+
let best = null;
|
|
4165
|
+
// A kiosk frame's popover opens to the right of a pointed card (placePopover): the pill keeps out from under it.
|
|
4166
|
+
const fb = l.fromBox;
|
|
4167
|
+
const popRoom = embedOpts.bare ? [{ x: fb.x2, y: fb.y, x2: fb.x2 + 3 * (fb.x2 - fb.x), y2: fb.y + 3 * (fb.y2 - fb.y) }] : [];
|
|
4168
|
+
// A kiosk's camera (Watch's shot) frames part of the graph: a pill stays inside what it shows.
|
|
4169
|
+
const vb = embedOpts.bare && svg.viewBox && svg.viewBox.baseVal && svg.viewBox.baseVal.width ? svg.viewBox.baseVal : null;
|
|
4170
|
+
const seen = vb ? { x: vb.x + 8, y: vb.y + 8, x2: vb.x + vb.width - 8, y2: vb.y + vb.height - 8 } : null;
|
|
4171
|
+
for (const s of tgPillSpots(fb, l.p0, w, h)) {
|
|
4172
|
+
const r = s.r;
|
|
4173
|
+
const lineHits = others.filter((d) => crosses(d.p0, d.p1, r)).length;
|
|
4174
|
+
// Outside the boxes' own span the pill may leave the drawing when the view is fitted: keep it in, and never above the
|
|
4175
|
+
// top box, where the caption says which run the marks are from (behold#571).
|
|
4176
|
+
const out = span ? (r.x2 - r.x) * (r.y2 - r.y) - overlap(r, { x: span.x - 40, y: span.y, x2: span.x2 + 40, y2: span.y2 + 40 }) : 0;
|
|
4177
|
+
const unseen = seen ? (r.x2 - r.x) * (r.y2 - r.y) - overlap(r, seen) : 0;
|
|
4178
|
+
const score = out * 80 + unseen * 80 + lineHits * 2000 + edgeIn(r) * 30 + sum(r, textBoxes, 50) + sum(r, lit, 200) + sum(r, placed, 50) + sum(r, cardBoxes, 50) + sum(r, headers, 20) + sum(r, popRoom, 4) + s.far * 12 + s.gap * 3 + s.round * 150;
|
|
4179
|
+
if (!best || score < best.score) best = { s, score };
|
|
4000
4180
|
}
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4181
|
+
if (!best) {
|
|
4182
|
+
p.g.remove();
|
|
4183
|
+
continue;
|
|
4184
|
+
}
|
|
4185
|
+
const { c, r } = best.s;
|
|
4186
|
+
(flash.has(l.key) ? lit : placed).push(r);
|
|
4187
|
+
pillsBy.push({ from: l.e.from, r, lit: flash.has(l.key) });
|
|
4188
|
+
p.g.setAttribute("transform", `translate(${c.x} ${c.y})`);
|
|
4189
|
+
// The leader: from the line's start on the card's border to the pill's nearest edge, with a dot where it leaves the card.
|
|
4190
|
+
const q = tgNearestOn(r, l.p0);
|
|
4191
|
+
p.g.insertBefore(make("line", { x1: l.p0.x - c.x, y1: l.p0.y - c.y, x2: q.x - c.x, y2: q.y - c.y, stroke: l.color, "stroke-width": 2.5 }), p.g.firstChild);
|
|
4192
|
+
p.g.insertBefore(make("circle", { cx: l.p0.x - c.x, cy: l.p0.y - c.y, r: 4, fill: l.color }), p.g.firstChild);
|
|
4193
|
+
if (flash.has(l.key)) {
|
|
4194
|
+
// A kiosk's flash: TG_FLASH_MS from when its reader came into the state, so a redraw midway carries on where it was.
|
|
4195
|
+
p.g.classList.add("tg-flash");
|
|
4196
|
+
p.g.style.animationDuration = `${TG_FLASH_MS}ms`;
|
|
4197
|
+
p.g.style.animationDelay = `-${Math.round(flash.get(l.key))}ms`;
|
|
4198
|
+
}
|
|
4199
|
+
// Inspect's focus keeps the focused roots' reads in words, as every read was before.
|
|
4200
|
+
if (!embedOpts.bare && focus && (focus.has(l.e.from) || focus.has(l.e.to))) p.g.classList.add("tg-shown");
|
|
4004
4201
|
}
|
|
4202
|
+
tgReadEdgesNow = edges;
|
|
4203
|
+
tgReadShow(svg);
|
|
4005
4204
|
|
|
4006
4205
|
// Which run the marks come from, above the boxes.
|
|
4007
4206
|
// #569: a pin that holds the view off every plan says why in its own words.
|
|
4008
|
-
const shown = tgViewCaption(drawnAnswer, tgProgress, new Date());
|
|
4009
|
-
const caption = tgPinnedCaption(tgAnswer, view.run) || (shown ? `Showing ${shown}` : null);
|
|
4207
|
+
const shown = tgViewCaption(drawnAnswer, tgProgress, new Date(), { merged: tgPinsCommit(view.run) });
|
|
4208
|
+
const caption = tgPinnedCaption(tgAnswer, view.run, view.pull || null, tgProgress) || (shown ? `Showing ${shown}` : null);
|
|
4010
4209
|
const all = union(boxes);
|
|
4011
4210
|
if (caption && all) {
|
|
4012
4211
|
const line = make("text", { "data-tg-reads": "caption", x: all.x, y: all.y - 22, "font-size": 16, "font-weight": 600, fill: "var(--muted)" }, caption);
|
|
@@ -4025,9 +4224,312 @@ function drawTgReads() {
|
|
|
4025
4224
|
layer.appendChild(make("text", { "data-tg-reads": "caption", x: all.x, y: all.y - 22, "font-size": 16, "font-weight": 600, fill: "var(--muted)" }, caption.slice(cut + 2)));
|
|
4026
4225
|
}
|
|
4027
4226
|
}
|
|
4227
|
+
// behold#743: an apply made outside the pipeline, on its estate's card, clear of the reads' pills and the caption.
|
|
4228
|
+
if (compMode && readMarks) {
|
|
4229
|
+
const captions = [...layer.querySelectorAll("text[data-tg-reads=caption]")].map(boxOf).filter(Boolean).map((b) => grow(b, 4));
|
|
4230
|
+
drawTgOutside(svg, { layer, make, boxOf, marks: readMarks, roots: states.roots, cardBoxOf, avoid: { pills: pillsBy, texts: textBoxes, captions, headers }, edgeIn, crosses });
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
|
|
4234
|
+
/**
|
|
4235
|
+
* behold#743: demo.json's `outside` (an operator's apply to app-01's estate while the pipeline's wave 3 applies it),
|
|
4236
|
+
* drawn as a mark joined to the estate's card: dashed, tagged "outside the pipeline", with who ran it, the command, its
|
|
4237
|
+
* state and its resources, and what the pipeline does to the same estate meanwhile; once both land, both changes. Only
|
|
4238
|
+
* a kiosk frame telling a chapter-carrying story draws it, and only while the step carries one: other scenarios, and
|
|
4239
|
+
* steps without it, draw nothing new. The mark is a child of the reads' layer, so the kiosk's modals and callouts keep
|
|
4240
|
+
* clear of it as of the pills (kioskTellBoxes' `labels`).
|
|
4241
|
+
*/
|
|
4242
|
+
function drawTgOutside(svg, { layer, make, boxOf, marks, roots, cardBoxOf, avoid, edgeIn, crosses }) {
|
|
4243
|
+
const outside = tgStoryOn() && tgStory.outside ? tgStory.outside : null;
|
|
4244
|
+
if (!outside || !marks || !marks.cards) return;
|
|
4245
|
+
const cards = marks.cards;
|
|
4246
|
+
const id = tgOutsideCard(outside.estate, [...Object.keys(cards), ...Object.values(cards).map((c) => c && c.root)]);
|
|
4247
|
+
const cid = id && (cards[id] ? id : Object.keys(cards).find((k) => cards[k] && cards[k].root === id));
|
|
4248
|
+
const el = cid ? svg.querySelector(`[data-node-id="${CSS.escape(cid)}"]`) : null;
|
|
4249
|
+
const cardBox = el ? cardBoxOf.get(el) || boxOf(el) : null;
|
|
4250
|
+
if (!cardBox) return;
|
|
4251
|
+
const m = cards[cid];
|
|
4252
|
+
// The pipeline's own state for the card, as the reads' flash reads it: a card whose wave's job runs now is applying.
|
|
4253
|
+
const pipeline = tgReaderStates(marks, roots)[m.root] || m.state;
|
|
4254
|
+
const plans = (m.facts || []).find((f) => /^plans /.test(f));
|
|
4255
|
+
const model = tgOutsideModel(outside, { pipeline, card: cid, change: plans ? plans.slice(6) : null, wave: Number.isInteger(m.wave) ? m.wave : null });
|
|
4256
|
+
if (!model) return;
|
|
4257
|
+
const tone = TG_TONE[model.tone] || TG_TONE.idle;
|
|
4258
|
+
const g = make("g", { "data-tg-outside": cid, "pointer-events": "none" });
|
|
4259
|
+
layer.appendChild(g);
|
|
4260
|
+
// The card's own ring, dashed in the mark's tone: the estate the outside apply is on.
|
|
4261
|
+
const ring = make("rect", { x: cardBox.x - 6, y: cardBox.y - 6, width: cardBox.x2 - cardBox.x + 12, height: cardBox.y2 - cardBox.y + 12, rx: 10, fill: "none", stroke: tone, "stroke-width": 2.5, "stroke-dasharray": "7 5" });
|
|
4262
|
+
g.appendChild(ring);
|
|
4263
|
+
// The words, measured where they are drawn; the box is sized to them.
|
|
4264
|
+
const size = embedOpts.bare ? 15 : 13;
|
|
4265
|
+
const mono = "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
|
|
4266
|
+
const style = {
|
|
4267
|
+
who: { size, weight: 700, fill: tone },
|
|
4268
|
+
landed: { size, weight: 700, fill: tone },
|
|
4269
|
+
command: { size: size - 2, weight: 500, fill: "var(--fg)", family: mono },
|
|
4270
|
+
resources: { size: size - 1, weight: 600, fill: "var(--fg)", family: mono },
|
|
4271
|
+
pipeline: { size: size - 1, weight: 600, fill: "var(--muted)" },
|
|
4272
|
+
};
|
|
4273
|
+
const body = make("g", {});
|
|
4274
|
+
g.appendChild(body);
|
|
4275
|
+
const texts = model.lines.map((l) => {
|
|
4276
|
+
const s = style[l.kind] || style.pipeline;
|
|
4277
|
+
const t = make("text", { "font-size": s.size, "font-weight": s.weight, fill: s.fill, ...(s.family ? { "font-family": s.family } : {}) }, l.text);
|
|
4278
|
+
if (l.kind === "who" && model.pulse) t.setAttribute("class", "pin-pulse");
|
|
4279
|
+
body.appendChild(t);
|
|
4280
|
+
let w = l.text.length * s.size * 0.6;
|
|
4281
|
+
try {
|
|
4282
|
+
w = t.getComputedTextLength() || w;
|
|
4283
|
+
} catch {
|
|
4284
|
+
/* not laid out: the estimate stands */
|
|
4285
|
+
}
|
|
4286
|
+
return { t, w, s };
|
|
4287
|
+
});
|
|
4288
|
+
const tagSize = size - 3;
|
|
4289
|
+
const tag = make("text", { "font-size": tagSize, "font-weight": 800, fill: "var(--bg)", "letter-spacing": "0.04em" }, model.tag.toUpperCase());
|
|
4290
|
+
let tagW = model.tag.length * tagSize * 0.72;
|
|
4291
|
+
g.appendChild(tag);
|
|
4292
|
+
try {
|
|
4293
|
+
tagW = tag.getComputedTextLength() || tagW;
|
|
4294
|
+
} catch {
|
|
4295
|
+
/* not laid out */
|
|
4296
|
+
}
|
|
4297
|
+
const padX = 14;
|
|
4298
|
+
const lineGap = 7;
|
|
4299
|
+
const top = 18; // under the tag, which sits across the top border
|
|
4300
|
+
const w = Math.max(tagW + 24, ...texts.map((x) => x.w)) + 2 * padX;
|
|
4301
|
+
const h = top + texts.reduce((a, x) => a + x.s.size + lineGap, 0) + 6;
|
|
4302
|
+
// Where it goes: beside the card, clear of the other cards, the card's read pills (behold#744), the caption and the
|
|
4303
|
+
// text around, and inside what Watch's camera shows.
|
|
4304
|
+
const vbb = embedOpts.bare && svg.viewBox && svg.viewBox.baseVal && svg.viewBox.baseVal.width ? svg.viewBox.baseVal : null;
|
|
4305
|
+
const seen = vbb ? { x: vbb.x + 8, y: vbb.y + 8, x2: vbb.x + vbb.width - 8, y2: vbb.y + vbb.height - 8 } : null;
|
|
4306
|
+
const overlap = (r, b) => Math.max(0, Math.min(r.x2, b.x2) - Math.max(r.x, b.x)) * Math.max(0, Math.min(r.y2, b.y2) - Math.max(r.y, b.y));
|
|
4307
|
+
const sum = (r, list, k) => list.reduce((a, b) => a + k * overlap(r, b), 0);
|
|
4308
|
+
const others = [...cardBoxOf.values()].filter((b) => b && b !== cardBox);
|
|
4309
|
+
const ringBox = { x: cardBox.x - 8, y: cardBox.y - 8, x2: cardBox.x2 + 8, y2: cardBox.y2 + 8 };
|
|
4310
|
+
// The card's own read pills (behold#744) and the ones flashing now must stay clear; the others show only on a pointer.
|
|
4311
|
+
const ownPills = avoid.pills.filter((x) => x.lit || x.from === m.root || x.from === cid).map((x) => x.r);
|
|
4312
|
+
const restPills = avoid.pills.filter((x) => !(x.lit || x.from === m.root || x.from === cid)).map((x) => x.r);
|
|
4313
|
+
// The leader: from the box's nearest edge to the card's ring, which it meets with a dot.
|
|
4314
|
+
const inner = { x: ringBox.x + 2, y: ringBox.y + 2, x2: ringBox.x2 - 2, y2: ringBox.y2 - 2 };
|
|
4315
|
+
const leaderOf = (r) => {
|
|
4316
|
+
const q = tgNearestOn(r, { x: (cardBox.x + cardBox.x2) / 2, y: (cardBox.y + cardBox.y2) / 2 });
|
|
4317
|
+
return { p: tgNearestOn(inner, q), q };
|
|
4318
|
+
};
|
|
4319
|
+
let best = null;
|
|
4320
|
+
// Slid further along a side than a pill is: the mark is wide, and a caption may sit over the card's box.
|
|
4321
|
+
for (const s of tgOutsideSpots(ringBox, w, h + 12, { gaps: [12, 28, 48, 72, 100, 140, 180], slides: [0, -0.25, 0.25, -0.5, 0.5, 0.75, 1, 1.25, 1.5, 1.75, -0.75, -1, -1.25] })) {
|
|
4322
|
+
const r = { ...s.r, y: s.r.y + 12 }; // the tag reaches 12 above the box
|
|
4323
|
+
const hit = { ...r, y: r.y - 12 };
|
|
4324
|
+
const unseen = seen ? (hit.x2 - hit.x) * (hit.y2 - hit.y) - overlap(hit, seen) : 0;
|
|
4325
|
+
const { p, q } = leaderOf(r);
|
|
4326
|
+
const across = [...avoid.texts, ...avoid.captions, ...ownPills, ...others].filter((t) => crosses(p, q, t)).length;
|
|
4327
|
+
const score = sum(hit, [ringBox], 400) + sum(hit, others, 200) + sum(hit, ownPills, 300) + sum(hit, restPills, 10) + sum(hit, avoid.captions, 300) + sum(hit, avoid.texts, 60) + sum(hit, avoid.headers, 15) + unseen * 120 + edgeIn(hit) * 4 + across * 4000 + s.far * 6;
|
|
4328
|
+
if (!best || score < best.score) best = { r, score };
|
|
4329
|
+
}
|
|
4330
|
+
if (!best) return g.remove();
|
|
4331
|
+
const r = best.r;
|
|
4332
|
+
body.prepend(make("rect", { x: r.x, y: r.y, width: w, height: h, rx: 9, fill: "var(--bg)", stroke: tone, "stroke-width": 2.5, "stroke-dasharray": "9 5" }));
|
|
4333
|
+
// The tag across the top border, filled, so it reads as a label of the box and not as one of the pipeline's states.
|
|
4334
|
+
g.insertBefore(make("rect", { x: r.x + padX - 8, y: r.y - 12, width: tagW + 16, height: 24, rx: 12, fill: tone }), tag);
|
|
4335
|
+
tag.setAttribute("x", String(r.x + padX));
|
|
4336
|
+
tag.setAttribute("y", String(r.y));
|
|
4337
|
+
tag.setAttribute("dominant-baseline", "central");
|
|
4338
|
+
let y = r.y + top;
|
|
4339
|
+
for (const x of texts) {
|
|
4340
|
+
y += x.s.size;
|
|
4341
|
+
x.t.setAttribute("x", String(r.x + padX));
|
|
4342
|
+
x.t.setAttribute("y", String(y));
|
|
4343
|
+
y += lineGap;
|
|
4344
|
+
}
|
|
4345
|
+
const { p, q } = leaderOf(r);
|
|
4346
|
+
if (Math.hypot(q.x - p.x, q.y - p.y) > 3) {
|
|
4347
|
+
g.insertBefore(make("line", { x1: p.x, y1: p.y, x2: q.x, y2: q.y, stroke: tone, "stroke-width": 2.5, "stroke-dasharray": "6 4" }), body);
|
|
4348
|
+
g.insertBefore(make("circle", { cx: p.x, cy: p.y, r: 4.5, fill: tone }), body);
|
|
4349
|
+
}
|
|
4350
|
+
g.appendChild(make("title", {}, [`${model.tag}: ${outside.who} ran ${outside.command} on ${outside.estate}`, `${outside.state}${(outside.resources || []).length ? ` · ${outside.resources.join(", ")}` : ""}`, ...(outside.log || []).slice(-3)].join("\n") + "\n(from the demo's narration, demo.json)"));
|
|
4351
|
+
}
|
|
4352
|
+
/**
|
|
4353
|
+
* Report minor 34: while the view draws a pull request's plan that has a cone
|
|
4354
|
+
* view, each card of a root it names takes `data-cone`: `changed` and `lit`
|
|
4355
|
+
* (planned: outlined in the plan's colour), or `dim` (not planned: faded,
|
|
4356
|
+
* still drawn). A components card, one per root, lights as its root does.
|
|
4357
|
+
* The dots layer is told the same lights. Any other plan sets nothing.
|
|
4358
|
+
*/
|
|
4359
|
+
function drawConeLights(svg, { stage, drawnAnswer, compMode, componentsOfRoot, rootOf }) {
|
|
4360
|
+
for (const g of svg.querySelectorAll("[data-cone]")) g.removeAttribute("data-cone");
|
|
4361
|
+
for (const g of svg.querySelectorAll("[data-cone-dim]")) {
|
|
4362
|
+
g.removeAttribute("data-cone-dim");
|
|
4363
|
+
g.style.opacity = g.getAttribute("data-tg-dim") ? "0.5" : "";
|
|
4364
|
+
}
|
|
4365
|
+
const lights = stage === "pull-request" ? coneLights(coneOf(drawnAnswer && drawnAnswer.pull_request)) : null;
|
|
4366
|
+
setDotsCone(lights);
|
|
4367
|
+
if (!lights) return;
|
|
4368
|
+
const outline = (g, width) => {
|
|
4369
|
+
const r = g.querySelector(":scope > rect");
|
|
4370
|
+
if (!r) return;
|
|
4371
|
+
if (!r.hasAttribute("data-tg-stroke0")) {
|
|
4372
|
+
r.setAttribute("data-tg-stroke0", r.getAttribute("stroke") || "");
|
|
4373
|
+
r.setAttribute("data-tg-width0", r.getAttribute("stroke-width") || "1.2");
|
|
4374
|
+
}
|
|
4375
|
+
r.setAttribute("stroke", TG_TONE.plan);
|
|
4376
|
+
r.setAttribute("stroke-width", width);
|
|
4377
|
+
};
|
|
4378
|
+
const dim = (g) => {
|
|
4379
|
+
g.setAttribute("data-cone-dim", "1");
|
|
4380
|
+
g.style.opacity = "0.35";
|
|
4381
|
+
};
|
|
4382
|
+
const mark = (g, light) => {
|
|
4383
|
+
if (!light) return;
|
|
4384
|
+
g.setAttribute("data-cone", light);
|
|
4385
|
+
if (light === "dim") dim(g);
|
|
4386
|
+
// A components card is outlined by its root's state already (drawTgComponentMarks), which keeps the original stroke to put back.
|
|
4387
|
+
else if (!compMode) outline(g, light === "changed" ? "4" : "2.5");
|
|
4388
|
+
};
|
|
4389
|
+
if (compMode) {
|
|
4390
|
+
// Each components card by the root its job names (terragucci.components.json), else by the answer's root.
|
|
4391
|
+
const named = (tgComponentFacets && tgComponentFacets.roots) || {};
|
|
4392
|
+
const done = new Set();
|
|
4393
|
+
for (const g of svg.querySelectorAll("[data-node-id]")) {
|
|
4394
|
+
const id = g.getAttribute("data-node-id");
|
|
4395
|
+
const path = [named[id], id].find((p) => p && lights.roots.has(p));
|
|
4396
|
+
if (path) {
|
|
4397
|
+
mark(g, coneRootLight(lights, path));
|
|
4398
|
+
done.add(g);
|
|
4399
|
+
}
|
|
4400
|
+
}
|
|
4401
|
+
for (const path of lights.roots.keys()) {
|
|
4402
|
+
const r = rootOf(path);
|
|
4403
|
+
if (!r) continue;
|
|
4404
|
+
for (const c of componentsOfRoot(r)) {
|
|
4405
|
+
const g = svg.querySelector(`[data-node-id="${CSS.escape(c)}"]`);
|
|
4406
|
+
if (g && !done.has(g)) mark(g, coneRootLight(lights, path));
|
|
4407
|
+
}
|
|
4408
|
+
}
|
|
4409
|
+
return;
|
|
4410
|
+
}
|
|
4411
|
+
for (const g of svg.querySelectorAll("[data-node-id]")) {
|
|
4412
|
+
const at = coneCardRoot(g.getAttribute("data-node-id"), lights, (tgAnswer && tgAnswer.roots) || []);
|
|
4413
|
+
if (at) mark(g, coneResourceLight(lights, at.root, at.address));
|
|
4414
|
+
}
|
|
4415
|
+
// Each root's box says how the plan took it (the badge's words, web/terragucci-change.js rootStates).
|
|
4416
|
+
for (const m of svg.querySelectorAll("g[data-tg-root]")) {
|
|
4417
|
+
const light = coneRootLight(lights, m.getAttribute("data-tg-root"));
|
|
4418
|
+
if (light) m.setAttribute("data-cone", light);
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
/**
|
|
4422
|
+
* How far a card (`b`, svg units) may grow down: to the next card under it, or the bottom of the box that holds it,
|
|
4423
|
+
* with a gap; nothing when no box holds it, so a grown card never changes what the graph spans.
|
|
4424
|
+
*/
|
|
4425
|
+
function roomUnder(b, svg, boxOf, own, need = 0) {
|
|
4426
|
+
// The innermost box that holds the card.
|
|
4427
|
+
let box = null;
|
|
4428
|
+
let boxB = null;
|
|
4429
|
+
for (const r of svg.querySelectorAll("rect[data-group-id]")) {
|
|
4430
|
+
const g = boxOf(r);
|
|
4431
|
+
if (g && b.x >= g.x - 0.5 && b.x2 <= g.x2 + 0.5 && b.y >= g.y - 0.5 && b.y2 <= g.y2 + 0.5 && (!boxB || g.y2 - g.y < boxB.y2 - boxB.y)) {
|
|
4432
|
+
box = r;
|
|
4433
|
+
boxB = g;
|
|
4434
|
+
}
|
|
4435
|
+
}
|
|
4436
|
+
if (!box) return 0;
|
|
4437
|
+
let cardRoom = Infinity;
|
|
4438
|
+
for (const c of svg.querySelectorAll("[data-node-id]")) {
|
|
4439
|
+
if (c === own) continue;
|
|
4440
|
+
const o = boxOf(c);
|
|
4441
|
+
if (o && o.x < b.x2 && o.x2 > b.x && o.y >= b.y2 - 0.5) cardRoom = Math.min(cardRoom, o.y - b.y2 - 8);
|
|
4442
|
+
}
|
|
4443
|
+
let room = boxB.y2 - b.y2 - 10;
|
|
4444
|
+
// Not enough in the box, and no card under this one in it: the box grows too, when nothing lies under the box.
|
|
4445
|
+
if (need > room && cardRoom === Infinity) {
|
|
4446
|
+
const extra = need - room;
|
|
4447
|
+
const below = [...svg.querySelectorAll("rect[data-group-id], [data-node-id]")].some((n) => {
|
|
4448
|
+
if (n === box || n === own || box.contains(n)) return false;
|
|
4449
|
+
const o = boxOf(n);
|
|
4450
|
+
return o && o.x < boxB.x2 && o.x2 > boxB.x && o.y >= boxB.y2 - 0.5 && o.y < boxB.y2 + extra + 12;
|
|
4451
|
+
});
|
|
4452
|
+
if (!below) {
|
|
4453
|
+
const h0 = Number(box.getAttribute("height"));
|
|
4454
|
+
if (!box.hasAttribute("data-tg-h0")) box.setAttribute("data-tg-h0", String(h0));
|
|
4455
|
+
box.setAttribute("height", String(h0 + extra));
|
|
4456
|
+
room = need;
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
return Math.max(0, Math.min(room, cardRoom));
|
|
4028
4460
|
}
|
|
4029
4461
|
const sameBox = (a, b) => !!a && !!b && Math.abs(a.x - b.x) < 0.5 && Math.abs(a.y - b.y) < 0.5 && Math.abs(a.x2 - b.x2) < 0.5 && Math.abs(a.y2 - b.y2) < 0.5;
|
|
4030
4462
|
|
|
4463
|
+
/**
|
|
4464
|
+
* behold#744: on the components zoom an edge says what it means, not only "app-01 → cluster-a": the one depends on the
|
|
4465
|
+
* other, which applies first, and what it reads of it. In its <title>, which the shared tooltip shows (a kiosk frame's too).
|
|
4466
|
+
*/
|
|
4467
|
+
function tipComponentEdges(svg, edges = []) {
|
|
4468
|
+
for (const g of svg.querySelectorAll("g[data-edge-from]")) {
|
|
4469
|
+
const from = g.getAttribute("data-edge-from");
|
|
4470
|
+
const to = g.getAttribute("data-edge-to");
|
|
4471
|
+
const title = [...g.children].find((c) => c.localName === "title");
|
|
4472
|
+
if (!from || !to || !title) continue;
|
|
4473
|
+
const read = edges.find((e) => (e.from === from || e.from.endsWith(`/${from}`)) && (e.to === to || e.to.endsWith(`/${to}`)));
|
|
4474
|
+
title.textContent = `${from} → ${to}\n${from} depends on ${to}, so ${to} applies first${read ? `\n${tgReadLine(read)}` : ""}`;
|
|
4475
|
+
}
|
|
4476
|
+
}
|
|
4477
|
+
|
|
4478
|
+
// behold#744: the reads' pills show while they matter (web/tg-read-pills.js): the pointer's, a kiosk's flash, Inspect's focus.
|
|
4479
|
+
const tgReadFlash = createReadFlash();
|
|
4480
|
+
let tgReadEdgesNow = [];
|
|
4481
|
+
let tgReadHot = [];
|
|
4482
|
+
/** The reads the pointer (or the focus) on `target` lights: a read's line, or a card or box of a root that reads or is read. */
|
|
4483
|
+
function tgReadHotOf(target) {
|
|
4484
|
+
if (!target || !target.closest || !target.closest("#graph svg") || !tgReadEdgesNow.length) return [];
|
|
4485
|
+
const hit = target.closest("[data-tg-read-hit]");
|
|
4486
|
+
if (hit) return tgHotReads(tgReadEdgesNow, { key: hit.getAttribute("data-tg-read-hit") });
|
|
4487
|
+
const h = kioskHoverOf(target);
|
|
4488
|
+
return h && h.root ? tgHotReads(tgReadEdgesNow, { root: h.root }) : [];
|
|
4489
|
+
}
|
|
4490
|
+
function tgReadSetHot(keys) {
|
|
4491
|
+
if (keys.length === tgReadHot.length && keys.every((k, i) => k === tgReadHot[i])) return;
|
|
4492
|
+
tgReadHot = keys;
|
|
4493
|
+
const svg = document.querySelector("#graph svg");
|
|
4494
|
+
if (svg) tgReadShow(svg);
|
|
4495
|
+
}
|
|
4496
|
+
/** Light the hot reads' pills and lines, the lit pills last in their layer so they sit over the rest. */
|
|
4497
|
+
function tgReadShow(svg) {
|
|
4498
|
+
ensureTgReadStyle();
|
|
4499
|
+
const hot = new Set(tgReadHot);
|
|
4500
|
+
for (const el of svg.querySelectorAll("[data-tg-read]")) el.classList.toggle("tg-hot", hot.has(el.getAttribute("data-tg-read")));
|
|
4501
|
+
for (const g of svg.querySelectorAll("g[data-tg-read-pill].tg-hot")) g.parentNode.appendChild(g);
|
|
4502
|
+
}
|
|
4503
|
+
let tgReadWired = false;
|
|
4504
|
+
function wireTgReadHover() {
|
|
4505
|
+
if (tgReadWired || typeof document === "undefined") return;
|
|
4506
|
+
tgReadWired = true;
|
|
4507
|
+
document.addEventListener("pointerover", (e) => tgReadSetHot(tgReadHotOf(e.target)));
|
|
4508
|
+
document.addEventListener("pointerout", (e) => !e.relatedTarget && tgReadSetHot([]));
|
|
4509
|
+
document.addEventListener("focusin", (e) => tgReadSetHot(tgReadHotOf(e.target)));
|
|
4510
|
+
document.addEventListener("focusout", (e) => !e.relatedTarget && tgReadSetHot([]));
|
|
4511
|
+
}
|
|
4512
|
+
/** The pills' looks, once per document: hidden until lit; a flash shows and fades; no fade under prefers-reduced-motion. */
|
|
4513
|
+
function ensureTgReadStyle() {
|
|
4514
|
+
wireTgReadHover();
|
|
4515
|
+
if (document.getElementById("tg-read-style")) return;
|
|
4516
|
+
const st = document.createElement("style");
|
|
4517
|
+
st.id = "tg-read-style";
|
|
4518
|
+
st.textContent = `#graph g[data-tg-read-pill] { opacity: 0; }
|
|
4519
|
+
#graph g[data-tg-read-pill].tg-hot, #graph g[data-tg-read-pill].tg-shown { opacity: 1 !important; }
|
|
4520
|
+
#graph g[data-tg-read-pill].tg-hot { transition: opacity .15s ease; }
|
|
4521
|
+
#graph g[data-tg-read-pill].tg-flash { animation: tg-read-flash 6s linear both; }
|
|
4522
|
+
#graph line[data-tg-read].tg-hot { stroke-width: 5; filter: drop-shadow(0 0 3px var(--bg)); }
|
|
4523
|
+
#graph g[data-tg-read-covers] { display: none !important; }
|
|
4524
|
+
@keyframes tg-read-flash { 0% { opacity: 0; } 4%, 80% { opacity: 1; } 100% { opacity: 0; } }
|
|
4525
|
+
@keyframes tg-read-flash-step { 0%, 99.9% { opacity: 1; } 100% { opacity: 0; } }
|
|
4526
|
+
@media (prefers-reduced-motion: reduce) {
|
|
4527
|
+
#graph g[data-tg-read-pill].tg-hot { transition: none; }
|
|
4528
|
+
#graph g[data-tg-read-pill].tg-flash { animation-name: tg-read-flash-step; animation-timing-function: step-end; }
|
|
4529
|
+
}`;
|
|
4530
|
+
document.head.appendChild(st);
|
|
4531
|
+
}
|
|
4532
|
+
|
|
4031
4533
|
/** #571: points along the components graph's own edges, in the svg's coordinates, every few units. */
|
|
4032
4534
|
function chantEdgePoints(svg) {
|
|
4033
4535
|
const toSvg = svg.getScreenCTM && svg.getScreenCTM();
|
|
@@ -4035,6 +4537,7 @@ function chantEdgePoints(svg) {
|
|
|
4035
4537
|
const inv = toSvg.inverse();
|
|
4036
4538
|
const out = [];
|
|
4037
4539
|
for (const path of svg.querySelectorAll("path.pin-edge-line")) {
|
|
4540
|
+
if (path.closest("[data-tg-read-covers]")) continue; // behold#762: hidden, a read line stands for it
|
|
4038
4541
|
let len = 0;
|
|
4039
4542
|
try {
|
|
4040
4543
|
len = path.getTotalLength();
|
|
@@ -4084,6 +4587,330 @@ function watchTgRuns() {
|
|
|
4084
4587
|
* spot that is clear, in the words that fit, else only in the tooltip.
|
|
4085
4588
|
* Returns the wave boxes, in the svg's coordinates.
|
|
4086
4589
|
*/
|
|
4590
|
+
/** behold#631: a kiosk passer-by can't place a card's type glyph (it reads as a checkbox): hide it, once per card. */
|
|
4591
|
+
function kioskCardGlyphs(svg) {
|
|
4592
|
+
for (const card of svg.querySelectorAll("[data-node-id]")) {
|
|
4593
|
+
const icon = card.querySelector(":scope > g[transform]");
|
|
4594
|
+
if (!icon || card.hasAttribute("data-kiosk-glyph")) continue;
|
|
4595
|
+
icon.setAttribute("visibility", "hidden");
|
|
4596
|
+
// The name and the state line take the glyph's room, so the bigger state words fit.
|
|
4597
|
+
card.setAttribute("data-kiosk-glyph", "1");
|
|
4598
|
+
for (const t of card.querySelectorAll(":scope > text")) t.setAttribute("x", String(Number(t.getAttribute("x")) - 30));
|
|
4599
|
+
}
|
|
4600
|
+
}
|
|
4601
|
+
/** The convex hull of points (monotone chain), counter-clockwise. */
|
|
4602
|
+
function hullOf(points) {
|
|
4603
|
+
const p = [...points].sort((a, b) => a.x - b.x || a.y - b.y);
|
|
4604
|
+
if (p.length < 3) return p;
|
|
4605
|
+
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
|
4606
|
+
const lower = [];
|
|
4607
|
+
for (const q of p) {
|
|
4608
|
+
while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], q) <= 0) lower.pop();
|
|
4609
|
+
lower.push(q);
|
|
4610
|
+
}
|
|
4611
|
+
const upper = [];
|
|
4612
|
+
for (const q of [...p].reverse()) {
|
|
4613
|
+
while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], q) <= 0) upper.pop();
|
|
4614
|
+
upper.push(q);
|
|
4615
|
+
}
|
|
4616
|
+
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
|
|
4617
|
+
}
|
|
4618
|
+
/** A closed path through a hull, each corner rounded by at most `r`, the `sharp` point (the apex) left a point. */
|
|
4619
|
+
function smoothPath(h, sharp = null, r = 28) {
|
|
4620
|
+
if (h.length < 3) return "";
|
|
4621
|
+
const f = (n) => Math.round(n * 10) / 10;
|
|
4622
|
+
const toward = (p, q, d) => {
|
|
4623
|
+
const len = Math.hypot(q.x - p.x, q.y - p.y) || 1;
|
|
4624
|
+
return { x: p.x + ((q.x - p.x) / len) * d, y: p.y + ((q.y - p.y) / len) * d };
|
|
4625
|
+
};
|
|
4626
|
+
let d = "";
|
|
4627
|
+
h.forEach((p, i) => {
|
|
4628
|
+
const prev = h[(i - 1 + h.length) % h.length];
|
|
4629
|
+
const next = h[(i + 1) % h.length];
|
|
4630
|
+
if (sharp && p.x === sharp.x && p.y === sharp.y) {
|
|
4631
|
+
d += `${i ? "L" : "M"}${f(p.x)},${f(p.y)} `;
|
|
4632
|
+
return;
|
|
4633
|
+
}
|
|
4634
|
+
const k = Math.min(r, Math.hypot(prev.x - p.x, prev.y - p.y) / 2, Math.hypot(next.x - p.x, next.y - p.y) / 2);
|
|
4635
|
+
const a = toward(p, prev, k);
|
|
4636
|
+
const b = toward(p, next, k);
|
|
4637
|
+
d += `${i ? "L" : "M"}${f(a.x)},${f(a.y)} Q${f(p.x)},${f(p.y)} ${f(b.x)},${f(b.y)} `;
|
|
4638
|
+
});
|
|
4639
|
+
return `${d}Z`;
|
|
4640
|
+
}
|
|
4641
|
+
const REACH_TONE = { plan: "var(--frame-pending, var(--pending))", bad: "var(--frame-degraded, var(--degraded))" };
|
|
4642
|
+
/**
|
|
4643
|
+
* behold#631: what a change reaches, drawn on a chant repo's components graph:
|
|
4644
|
+
* a soft wedge per root, from the root card's top centre up over the cards
|
|
4645
|
+
* downstream of it, padded, behind the cards and in front of the wave boxes.
|
|
4646
|
+
* It grows from the root outward over about 1.2 s (none under reduced motion)
|
|
4647
|
+
* and then rests faint, with its words at its upper edge. A new reach
|
|
4648
|
+
* crossfades the old one out; the same one redrawn only follows the cards.
|
|
4649
|
+
*/
|
|
4650
|
+
function drawReach(svg, reach, boxOf, size = 18, needs = null) {
|
|
4651
|
+
// Its words inside it, beside its apex: just right of the root card, in the open space between the root's wave box and the one above.
|
|
4652
|
+
const labelAt = (shapes) => {
|
|
4653
|
+
const at = shapes[0];
|
|
4654
|
+
const waveBoxes = [...svg.querySelectorAll("rect[data-group-id]")].map((r) => boxOf(r)).filter(Boolean);
|
|
4655
|
+
const inBox = waveBoxes.find((b) => at.root.x >= b.x && at.root.x2 <= b.x2 && at.root.y >= b.y && at.root.y2 <= b.y2) || null;
|
|
4656
|
+
const above = inBox ? waveBoxes.filter((b) => b.y2 <= inBox.y + 1).sort((a, b) => b.y2 - a.y2)[0] : null;
|
|
4657
|
+
return { x: at.root.x2 + 14, y: inBox && above ? (inBox.y + above.y2) / 2 : at.root.y - 24 };
|
|
4658
|
+
};
|
|
4659
|
+
const NS = "http://www.w3.org/2000/svg";
|
|
4660
|
+
const old = svg.querySelector("g[data-reach]");
|
|
4661
|
+
const key = reach ? reach.key : null;
|
|
4662
|
+
const fadeOut = (g) => {
|
|
4663
|
+
if (!g) return;
|
|
4664
|
+
// Its words, drawn on top in their own group, go with it.
|
|
4665
|
+
const words = svg.querySelector(`g[data-reach-words="${CSS.escape(g.getAttribute("data-reach") || "")}"]`);
|
|
4666
|
+
if (words) {
|
|
4667
|
+
words.removeAttribute("data-reach-words");
|
|
4668
|
+
words.style.transition = "opacity 0.5s ease-out";
|
|
4669
|
+
words.style.opacity = "0";
|
|
4670
|
+
setTimeout(() => words.remove(), 600);
|
|
4671
|
+
}
|
|
4672
|
+
g.removeAttribute("data-reach");
|
|
4673
|
+
g.setAttribute("data-reach-old", "1");
|
|
4674
|
+
g.style.transition = "opacity 0.5s ease-out";
|
|
4675
|
+
g.style.opacity = "0";
|
|
4676
|
+
setTimeout(() => g.remove(), 600);
|
|
4677
|
+
};
|
|
4678
|
+
if (!reach) return fadeOut(old);
|
|
4679
|
+
const card = (id) => svg.querySelector(`[data-node-id="${CSS.escape(id)}"]`);
|
|
4680
|
+
const box = (id) => {
|
|
4681
|
+
const g = card(id);
|
|
4682
|
+
return g ? boxOf(g) : null;
|
|
4683
|
+
};
|
|
4684
|
+
const pad = 16;
|
|
4685
|
+
const shapes = [];
|
|
4686
|
+
const covered = new Set(reach.covered);
|
|
4687
|
+
// behold#741: a terragucci repo's marks carry their own edges (the plan report's reads, the run view's).
|
|
4688
|
+
const needsOf = needs || (chantFacets && chantFacets.needs) || {};
|
|
4689
|
+
for (const root of reach.roots) {
|
|
4690
|
+
const rb = box(root);
|
|
4691
|
+
if (!rb) continue;
|
|
4692
|
+
// This root's own reach: the covered cards downstream of it.
|
|
4693
|
+
const mine = [...covered].filter((c) => c !== root && (reach.roots.length === 1 || reachesFrom(root, c, needsOf)));
|
|
4694
|
+
const boxes = mine.map(box).filter(Boolean);
|
|
4695
|
+
if (!boxes.length) continue;
|
|
4696
|
+
// The apex just below the root card's bottom centre; the root card itself inside, so the shape comes out of it.
|
|
4697
|
+
const apex = { x: (rb.x + rb.x2) / 2, y: rb.y2 + pad + 10 };
|
|
4698
|
+
const pts = [apex];
|
|
4699
|
+
for (const b of [rb, ...boxes]) pts.push({ x: b.x - pad, y: b.y - pad }, { x: b.x2 + pad, y: b.y - pad }, { x: b.x - pad, y: b.y2 + pad }, { x: b.x2 + pad, y: b.y2 + pad });
|
|
4700
|
+
const top = Math.min(...boxes.map((b) => b.y)) - pad;
|
|
4701
|
+
shapes.push({ d: smoothPath(hullOf(pts), apex), apex, root: rb, top, cx: (Math.min(...boxes.map((b) => b.x)) + Math.max(...boxes.map((b) => b.x2))) / 2, reachR: Math.max(...pts.map((p) => Math.hypot(p.x - apex.x, p.y - apex.y))) });
|
|
4702
|
+
}
|
|
4703
|
+
if (!shapes.length) return fadeOut(old);
|
|
4704
|
+
const tone = REACH_TONE[reach.tone] || REACH_TONE.plan;
|
|
4705
|
+
if (old && old.getAttribute("data-reach") === key) {
|
|
4706
|
+
// The same reach: follow the cards, no new growth, and never left part-grown (a frame drawn while hidden pauses its animation).
|
|
4707
|
+
old.querySelectorAll("path[data-reach-shape], path[data-reach-edge]").forEach((p) => {
|
|
4708
|
+
const i = Number(p.getAttribute("data-reach-i"));
|
|
4709
|
+
if (shapes[i]) p.setAttribute("d", shapes[i].d);
|
|
4710
|
+
});
|
|
4711
|
+
reachFinal(old, shapes, labelAt(shapes));
|
|
4712
|
+
return;
|
|
4713
|
+
}
|
|
4714
|
+
fadeOut(old);
|
|
4715
|
+
const g = document.createElementNS(NS, "g");
|
|
4716
|
+
g.setAttribute("data-reach", key);
|
|
4717
|
+
g.setAttribute("pointer-events", "none");
|
|
4718
|
+
const reduce = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4719
|
+
const id = `reach-${Date.now().toString(36)}`;
|
|
4720
|
+
// The growth: each wedge revealed by a circle from its apex, widening out and up as if along the edges.
|
|
4721
|
+
const defs = document.createElementNS(NS, "defs");
|
|
4722
|
+
const clip = document.createElementNS(NS, "clipPath");
|
|
4723
|
+
clip.setAttribute("id", id);
|
|
4724
|
+
for (const sh of shapes) {
|
|
4725
|
+
const c = document.createElementNS(NS, "circle");
|
|
4726
|
+
c.setAttribute("cx", String(sh.apex.x));
|
|
4727
|
+
c.setAttribute("cy", String(sh.apex.y));
|
|
4728
|
+
c.setAttribute("r", reduce ? String(sh.reachR) : "0");
|
|
4729
|
+
if (!reduce) {
|
|
4730
|
+
const a = document.createElementNS(NS, "animate");
|
|
4731
|
+
for (const [k, v] of Object.entries({ attributeName: "r", from: "0", to: String(sh.reachR), dur: "1.2s", fill: "freeze", calcMode: "spline", keyTimes: "0;1", keySplines: "0.16 1 0.3 1" })) a.setAttribute(k, v);
|
|
4732
|
+
c.appendChild(a);
|
|
4733
|
+
}
|
|
4734
|
+
clip.appendChild(c);
|
|
4735
|
+
}
|
|
4736
|
+
defs.appendChild(clip);
|
|
4737
|
+
g.appendChild(defs);
|
|
4738
|
+
// One fill for all the wedges, so where two roots' wedges meet they merge rather than darken.
|
|
4739
|
+
const fill = document.createElementNS(NS, "g");
|
|
4740
|
+
fill.setAttribute("clip-path", `url(#${id})`);
|
|
4741
|
+
fill.setAttribute("opacity", "0.13");
|
|
4742
|
+
const edge = document.createElementNS(NS, "g");
|
|
4743
|
+
edge.setAttribute("clip-path", `url(#${id})`);
|
|
4744
|
+
for (const sh of shapes) {
|
|
4745
|
+
const p = document.createElementNS(NS, "path");
|
|
4746
|
+
p.setAttribute("d", sh.d);
|
|
4747
|
+
p.setAttribute("fill", tone);
|
|
4748
|
+
p.setAttribute("data-reach-shape", "1");
|
|
4749
|
+
p.setAttribute("data-reach-i", String(shapes.indexOf(sh)));
|
|
4750
|
+
fill.appendChild(p);
|
|
4751
|
+
const e = document.createElementNS(NS, "path");
|
|
4752
|
+
e.setAttribute("d", sh.d);
|
|
4753
|
+
e.setAttribute("fill", "none");
|
|
4754
|
+
e.setAttribute("stroke", tone);
|
|
4755
|
+
e.setAttribute("stroke-opacity", "0.55");
|
|
4756
|
+
e.setAttribute("stroke-width", "1.5");
|
|
4757
|
+
e.setAttribute("data-reach-edge", "1");
|
|
4758
|
+
e.setAttribute("data-reach-i", String(shapes.indexOf(sh)));
|
|
4759
|
+
edge.appendChild(e);
|
|
4760
|
+
}
|
|
4761
|
+
g.append(fill, edge);
|
|
4762
|
+
const where = labelAt(shapes);
|
|
4763
|
+
const label = document.createElementNS(NS, "text");
|
|
4764
|
+
for (const [k, v] of Object.entries({ x: String(where.x), y: String(where.y), "text-anchor": "start", "dominant-baseline": "central", "font-size": String(size), "font-weight": "700", fill: tone, stroke: "var(--bg)", "stroke-width": "5", "paint-order": "stroke", "stroke-linejoin": "round", "data-reach-label": "1" })) label.setAttribute(k, v);
|
|
4765
|
+
label.textContent = reach.label;
|
|
4766
|
+
if (!reduce) {
|
|
4767
|
+
label.style.opacity = "0";
|
|
4768
|
+
label.style.transition = "opacity 0.4s ease-out 1s";
|
|
4769
|
+
requestAnimationFrame(() => (label.style.opacity = "1"));
|
|
4770
|
+
}
|
|
4771
|
+
// The shape lies under everything, a shadow on the stage floor: before the wave boxes, the edges and the cards.
|
|
4772
|
+
// Its words sit on top, in their own group, so they stay readable.
|
|
4773
|
+
const words = document.createElementNS(NS, "g");
|
|
4774
|
+
words.setAttribute("data-reach-words", key);
|
|
4775
|
+
words.setAttribute("pointer-events", "none");
|
|
4776
|
+
words.appendChild(label);
|
|
4777
|
+
// Above the stage's own backdrop (pinhole's gradient and dot pattern), under all else.
|
|
4778
|
+
const backdrop = (n) => n.tagName.toLowerCase() === "rect" && !n.hasAttribute("data-group-id") && /^url\(#pin-/.test(n.getAttribute("fill") || "");
|
|
4779
|
+
const floor = [...svg.children].find((n) => !["defs", "style", "title"].includes(n.tagName.toLowerCase()) && !backdrop(n) && !n.hasAttribute("data-reach-old"));
|
|
4780
|
+
if (floor) svg.insertBefore(g, floor);
|
|
4781
|
+
else svg.appendChild(g);
|
|
4782
|
+
svg.appendChild(words);
|
|
4783
|
+
// Whatever the animation did (a hidden frame pauses it), the reach ends whole, its words up.
|
|
4784
|
+
setTimeout(() => g.isConnected && reachFinal(g, shapes, labelAt(shapes)), reduce ? 0 : 1_400);
|
|
4785
|
+
}
|
|
4786
|
+
/**
|
|
4787
|
+
* behold#631: a chant kiosk reads its waves bottom to top. Each wave box's
|
|
4788
|
+
* title says "wave N" at the header's size in a readable tone, each edge
|
|
4789
|
+
* carries an arrowhead at its dependent's end (so up reads as "then"), and
|
|
4790
|
+
* the bottom box says once that the waves apply from the bottom up.
|
|
4791
|
+
*/
|
|
4792
|
+
function chantKioskWaves(svg, boxOf, size) {
|
|
4793
|
+
const NS = "http://www.w3.org/2000/svg";
|
|
4794
|
+
let relabelled = false;
|
|
4795
|
+
for (const rect of svg.querySelectorAll("rect[data-group-id]")) {
|
|
4796
|
+
const n = tgWaveOfKey(rect.getAttribute("data-group-id"));
|
|
4797
|
+
if (n === null) continue;
|
|
4798
|
+
let title = null;
|
|
4799
|
+
for (let el = rect.nextElementSibling; el; el = el.nextElementSibling) {
|
|
4800
|
+
if (el.tagName.toLowerCase() === "text") {
|
|
4801
|
+
title = el;
|
|
4802
|
+
break;
|
|
4803
|
+
}
|
|
4804
|
+
if (el.tagName.toLowerCase() === "rect") break;
|
|
4805
|
+
}
|
|
4806
|
+
// The reach lies under the boxes: on a chant kiosk their fill lets it show through faintly; the border stays.
|
|
4807
|
+
if (!rect.hasAttribute("data-kiosk-fill")) {
|
|
4808
|
+
rect.setAttribute("data-kiosk-fill", rect.getAttribute("fill-opacity") || "");
|
|
4809
|
+
rect.setAttribute("fill-opacity", "0.3");
|
|
4810
|
+
}
|
|
4811
|
+
if (!title || title.hasAttribute("data-kiosk-wave")) continue;
|
|
4812
|
+
title.setAttribute("data-kiosk-wave", "1");
|
|
4813
|
+
title.textContent = `wave ${n}`;
|
|
4814
|
+
title.setAttribute("font-size", String(size));
|
|
4815
|
+
title.dataset.pinFont = String(size);
|
|
4816
|
+
title.setAttribute("fill", "var(--fg)");
|
|
4817
|
+
relabelled = true;
|
|
4818
|
+
}
|
|
4819
|
+
// scaleBoxLabels indexed the titles at pinhole's size: index them again at this one.
|
|
4820
|
+
if (relabelled) {
|
|
4821
|
+
boxLabelCache = { svg: null, labels: [] };
|
|
4822
|
+
boxLabelScale = null;
|
|
4823
|
+
}
|
|
4824
|
+
// Arrowheads: one marker, at the end of each edge that meets its dependent (the edge's `from`, consumer -> producer).
|
|
4825
|
+
if (!svg.querySelector("#k-then-arrow")) {
|
|
4826
|
+
const defs = svg.querySelector("defs") || svg.insertBefore(document.createElementNS(NS, "defs"), svg.firstChild);
|
|
4827
|
+
const m = document.createElementNS(NS, "marker");
|
|
4828
|
+
for (const [k, v] of Object.entries({ id: "k-then-arrow", viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "7", markerHeight: "7", markerUnits: "userSpaceOnUse", orient: "auto-start-reverse" })) m.setAttribute(k, v);
|
|
4829
|
+
const p = document.createElementNS(NS, "path");
|
|
4830
|
+
p.setAttribute("d", "M0,0 L10,5 L0,10 z");
|
|
4831
|
+
p.setAttribute("fill", "var(--muted)");
|
|
4832
|
+
m.appendChild(p);
|
|
4833
|
+
defs.appendChild(m);
|
|
4834
|
+
}
|
|
4835
|
+
for (const g of svg.querySelectorAll("g[data-edge-from]")) {
|
|
4836
|
+
const path = g.querySelector("path.pin-edge-line") || g.querySelector("path");
|
|
4837
|
+
if (!path || path.hasAttribute("data-kiosk-then")) continue;
|
|
4838
|
+
path.setAttribute("data-kiosk-then", "1");
|
|
4839
|
+
const from = svg.querySelector(`[data-node-id="${CSS.escape(g.getAttribute("data-edge-from"))}"]`);
|
|
4840
|
+
const fb = from ? boxOf(from) : null;
|
|
4841
|
+
let start = null;
|
|
4842
|
+
let end = null;
|
|
4843
|
+
try {
|
|
4844
|
+
const len = path.getTotalLength();
|
|
4845
|
+
start = path.getPointAtLength(0);
|
|
4846
|
+
end = path.getPointAtLength(len);
|
|
4847
|
+
} catch {
|
|
4848
|
+
continue;
|
|
4849
|
+
}
|
|
4850
|
+
if (!fb || !start || !end) continue;
|
|
4851
|
+
const near = (p) => Math.hypot(p.x - (fb.x + fb.x2) / 2, p.y - (fb.y + fb.y2) / 2);
|
|
4852
|
+
// The arrow points into the dependent: at whichever end of the path meets it.
|
|
4853
|
+
if (near(start) < near(end)) path.setAttribute("marker-start", "url(#k-then-arrow)");
|
|
4854
|
+
else path.setAttribute("marker-end", "url(#k-then-arrow)");
|
|
4855
|
+
}
|
|
4856
|
+
// The bottom box says which way the waves go, once.
|
|
4857
|
+
if (!svg.querySelector("text[data-kiosk-upward]")) {
|
|
4858
|
+
const boxes = [...svg.querySelectorAll("rect[data-group-id]")].filter((r) => tgWaveOfKey(r.getAttribute("data-group-id")) !== null);
|
|
4859
|
+
const low = boxes.map((r) => ({ r, b: boxOf(r) })).filter((x) => x.b).sort((a, b) => b.b.y2 - a.b.y2)[0];
|
|
4860
|
+
if (low) {
|
|
4861
|
+
const t = document.createElementNS(NS, "text");
|
|
4862
|
+
for (const [k, v] of Object.entries({ x: String(low.b.x + 18), y: String(low.b.y2 - 12), "font-size": "13", "font-weight": "600", fill: "var(--muted)", "data-kiosk-upward": "1" })) t.setAttribute(k, v);
|
|
4863
|
+
t.textContent = "the waves apply from the bottom up";
|
|
4864
|
+
svg.appendChild(t);
|
|
4865
|
+
}
|
|
4866
|
+
}
|
|
4867
|
+
}
|
|
4868
|
+
/** A reach at its end state: each clip circle at full radius on its apex, no animation left, its words shown where they go. */
|
|
4869
|
+
function reachFinal(g, shapes, where) {
|
|
4870
|
+
const svgEl = g.ownerSVGElement || g.parentNode;
|
|
4871
|
+
g.querySelectorAll("clipPath circle").forEach((c, i) => {
|
|
4872
|
+
for (const a of c.querySelectorAll("animate")) a.remove();
|
|
4873
|
+
const sh = shapes[i];
|
|
4874
|
+
if (!sh) return;
|
|
4875
|
+
c.setAttribute("cx", String(sh.apex.x));
|
|
4876
|
+
c.setAttribute("cy", String(sh.apex.y));
|
|
4877
|
+
c.setAttribute("r", String(sh.reachR));
|
|
4878
|
+
});
|
|
4879
|
+
const key = g.getAttribute("data-reach") || "";
|
|
4880
|
+
const words = svgEl && svgEl.querySelector ? svgEl.querySelector(`g[data-reach-words="${CSS.escape(key)}"]`) : null;
|
|
4881
|
+
const label = (words && words.querySelector("text[data-reach-label]")) || g.querySelector("text[data-reach-label]");
|
|
4882
|
+
if (label) {
|
|
4883
|
+
label.setAttribute("x", String(where.x));
|
|
4884
|
+
label.setAttribute("y", String(where.y));
|
|
4885
|
+
label.style.transition = "";
|
|
4886
|
+
label.style.opacity = "1";
|
|
4887
|
+
}
|
|
4888
|
+
}
|
|
4889
|
+
/** Whether `c` is downstream of `root` along `needs`. */
|
|
4890
|
+
function reachesFrom(root, c, needs) {
|
|
4891
|
+
const seen = new Set();
|
|
4892
|
+
const up = (n) => {
|
|
4893
|
+
for (const d of needs[n] || []) {
|
|
4894
|
+
if (d === root) return true;
|
|
4895
|
+
if (seen.has(d)) continue;
|
|
4896
|
+
seen.add(d);
|
|
4897
|
+
if (up(d)) return true;
|
|
4898
|
+
}
|
|
4899
|
+
return false;
|
|
4900
|
+
};
|
|
4901
|
+
return up(c);
|
|
4902
|
+
}
|
|
4903
|
+
/** behold#631: the "working" outline pulse, once per document; no motion under prefers-reduced-motion. */
|
|
4904
|
+
function ensureWorkingStyle() {
|
|
4905
|
+
if (document.getElementById("k-working-style")) return;
|
|
4906
|
+
const st = document.createElement("style");
|
|
4907
|
+
st.id = "k-working-style";
|
|
4908
|
+
st.textContent = `@media (prefers-reduced-motion: no-preference) {
|
|
4909
|
+
rect.k-working { animation: k-working 1.6s ease-in-out infinite; stroke: var(--frame-runtime, var(--runtime)); }
|
|
4910
|
+
@keyframes k-working { 0%, 100% { stroke-opacity: 0.35; stroke-width: 1.5; } 50% { stroke-opacity: 1; stroke-width: 3; } }
|
|
4911
|
+
}`;
|
|
4912
|
+
document.head.appendChild(st);
|
|
4913
|
+
}
|
|
4087
4914
|
function drawTgComponentMarks(svg, { drawnAnswer, focus, boxOf, make, edgePoints, marks: given = null }) {
|
|
4088
4915
|
const marks = given || tgComponentMarks(drawnAnswer, tgProgress, tgComponentFacets, { runs: tgRuns, pin: view.run || null });
|
|
4089
4916
|
// behold#631: where the marks came from, said in each tooltip.
|
|
@@ -4099,6 +4926,8 @@ function drawTgComponentMarks(svg, { drawnAnswer, focus, boxOf, make, edgePoints
|
|
|
4099
4926
|
.map(boxOf)
|
|
4100
4927
|
.filter(Boolean);
|
|
4101
4928
|
const cardEls = [...svg.querySelectorAll("[data-node-id]")];
|
|
4929
|
+
// behold#631: last draw's "working" pulse goes; this draw's marks say which cards still have it.
|
|
4930
|
+
for (const r of svg.querySelectorAll("rect.k-working")) r.setAttribute("class", (r.getAttribute("class") || "").replace(/\bk-working\b/g, "").trim());
|
|
4102
4931
|
const cardBoxes = cardEls.map(boxOf).filter(Boolean);
|
|
4103
4932
|
const edgeHit = (r) => edgePoints.some((p) => p.x >= r.x - 4 && p.x <= r.x2 + 4 && p.y >= r.y - 4 && p.y <= r.y2 + 4);
|
|
4104
4933
|
const probe = make("text", { "font-size": 12, "font-weight": 700 });
|
|
@@ -4124,7 +4953,7 @@ function drawTgComponentMarks(svg, { drawnAnswer, focus, boxOf, make, edgePoints
|
|
|
4124
4953
|
const rects = [...g.querySelectorAll(":scope > rect")];
|
|
4125
4954
|
const body = rects.reduce((a, r) => (!a || Number(r.getAttribute("width")) * Number(r.getAttribute("height")) > Number(a.getAttribute("width")) * Number(a.getAttribute("height")) ? r : a), null);
|
|
4126
4955
|
const bar = rects.find((r) => r !== body && Number(r.getAttribute("width")) <= 6);
|
|
4127
|
-
const quiet = m.state === "outside" || m.state === "unchanged" || m.state === "not-started";
|
|
4956
|
+
const quiet = m.state === "outside" || m.state === "unchanged" || m.state === "not-started" || m.state === "reading";
|
|
4128
4957
|
const inFocus = !focus || focus.has(m.root) || focus.has(id);
|
|
4129
4958
|
if (body) {
|
|
4130
4959
|
body.setAttribute("data-tg-stroke0", body.getAttribute("stroke") || "");
|
|
@@ -4138,20 +4967,67 @@ function drawTgComponentMarks(svg, { drawnAnswer, focus, boxOf, make, edgePoints
|
|
|
4138
4967
|
bar.setAttribute("data-tg-fill0", bar.getAttribute("fill") || "");
|
|
4139
4968
|
bar.setAttribute("fill", tone(m.tone));
|
|
4140
4969
|
}
|
|
4970
|
+
// behold#631: a card the pipeline is about to work on, between events, pulses its outline (none under reduced motion).
|
|
4971
|
+
if (body) {
|
|
4972
|
+
if (m.working) body.setAttribute("class", `${body.getAttribute("class") || ""} k-working`.trim());
|
|
4973
|
+
else if ((body.getAttribute("class") || "").includes("k-working")) body.setAttribute("class", (body.getAttribute("class") || "").replace(/\bk-working\b/g, "").trim());
|
|
4974
|
+
if (m.working) ensureWorkingStyle();
|
|
4975
|
+
}
|
|
4976
|
+
if (!m.words && m.working) continue;
|
|
4141
4977
|
const texts = [...g.querySelectorAll(":scope > text")];
|
|
4142
4978
|
const sub = texts.find((t) => /^Component\b/.test((t.textContent || "").trim())) || texts[1];
|
|
4143
4979
|
if (!sub || !body) continue;
|
|
4144
4980
|
const x = Number(sub.getAttribute("x"));
|
|
4145
4981
|
const y = Number(sub.getAttribute("y"));
|
|
4146
4982
|
const room = Number(body.getAttribute("x")) + Number(body.getAttribute("width")) - 10 - x;
|
|
4147
|
-
|
|
4983
|
+
// behold#631: a middle form (a failure's first words, a blocker's name) before the one-word short.
|
|
4984
|
+
// behold#631: a chant kiosk says a card's state at the size of its name, readable from a few feet.
|
|
4985
|
+
const cardFont = marks.cardFont || 12;
|
|
4986
|
+
// A cone root's words that don't fit: the state on this line, the cone's size wrapped under it (never cut).
|
|
4987
|
+
const coneCard = m.cone === "cone" || m.cone === "full";
|
|
4988
|
+
// behold#736: a fallback's line breaks after "planned in full", its kind under it ("empty cone").
|
|
4989
|
+
const coneCut = coneCard ? m.words.indexOf(m.cone === "full" ? ": " : " · ") : -1;
|
|
4990
|
+
const words = width(m.words, cardFont, 700) <= room ? m.words : coneCut > 0 ? m.words.slice(0, coneCut) : m.mid && width(m.mid, cardFont, 700) <= room ? m.mid : m.short;
|
|
4148
4991
|
sub.setAttribute("visibility", "hidden");
|
|
4149
4992
|
sub.setAttribute("data-tg-hid", "1");
|
|
4150
|
-
const t = make("text", { "data-tg-root": "card", x, y, "font-size":
|
|
4993
|
+
const t = make("text", { "data-tg-root": "card", x, y: marks.cardFont ? y + 4 : y, "font-size": cardFont, "font-weight": 700, fill: quiet ? "var(--frame-card-muted, var(--muted))" : TG_CARD_TONE[m.tone] || TG_CARD_TONE.idle }, words);
|
|
4151
4994
|
if (m.state === "applying") t.setAttribute("class", "pin-pulse");
|
|
4152
4995
|
if (!inFocus) t.style.opacity = "0.6";
|
|
4153
|
-
|
|
4154
|
-
g
|
|
4996
|
+
// The tooltip (with where the marks come from) beside the words, in a group of their own, so the card's text is its words alone.
|
|
4997
|
+
const tip = make("g", { "data-tg-root": "card-tip" });
|
|
4998
|
+
tip.append(make("title", {}, [`wave ${m.wave} · ${m.words}`, ...m.facts].join("\n") + "\n" + cardSource), t);
|
|
4999
|
+
g.appendChild(tip);
|
|
5000
|
+
// Report minor 34: under the state, what didn't fit of its words (the cone's size), then the cone's resources, a
|
|
5001
|
+
// line each, each wrapped to the card's width (web/cone.js wrapWords) so it reads in full. The card's body grows
|
|
5002
|
+
// to hold them when the gap under it has room; no box round them.
|
|
5003
|
+
const rest = words !== m.words && coneCut > 0 ? [m.words.slice(words.length).replace(/^(?: · |: )/, "")] : [];
|
|
5004
|
+
// behold#736: a story's cards say their state at its bigger size (cardFont); the lines under it follow, a size smaller.
|
|
5005
|
+
const lineFont = marks.cardFont ? cardFont - 2 : 11.5;
|
|
5006
|
+
const y0 = marks.cardFont ? y + 4 : y;
|
|
5007
|
+
const said = [...rest, ...(m.lines || [])].flatMap((line) => wrapWords(line, room, (txt) => width(txt, lineFont, 600)));
|
|
5008
|
+
if (said.length) {
|
|
5009
|
+
const LH = lineFont + 3.5;
|
|
5010
|
+
const top = Number(body.getAttribute("y"));
|
|
5011
|
+
const h0 = Number(body.getAttribute("height"));
|
|
5012
|
+
const need = y0 + LH * said.length + 8 - top;
|
|
5013
|
+
if (need > h0) {
|
|
5014
|
+
// Grow into the gap under the card, never onto another card; its box grows with it when nothing lies under the box.
|
|
5015
|
+
const b = boxOf(body);
|
|
5016
|
+
const gap = b ? roomUnder(b, svg, boxOf, g, need - h0) : 0;
|
|
5017
|
+
const grow = Math.max(0, Math.min(need - h0, gap));
|
|
5018
|
+
if (grow > 0) {
|
|
5019
|
+
body.setAttribute("data-tg-h0", String(h0));
|
|
5020
|
+
body.setAttribute("height", String(h0 + grow));
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5023
|
+
const floor = top + Number(body.getAttribute("height")) - 6;
|
|
5024
|
+
said.forEach((line, k) => {
|
|
5025
|
+
const ly = y0 + LH * (k + 1);
|
|
5026
|
+
if (ly > floor) return;
|
|
5027
|
+
const last = k === said.length - 1 || y0 + LH * (k + 2) <= floor ? line : `${line} …`;
|
|
5028
|
+
g.appendChild(make("text", { "data-tg-root": "cone-line", x, y: ly, "font-size": lineFont, "font-weight": 600, fill: "var(--frame-card-muted, var(--muted))" }, last));
|
|
5029
|
+
});
|
|
5030
|
+
}
|
|
4155
5031
|
}
|
|
4156
5032
|
|
|
4157
5033
|
// The wave boxes.
|
|
@@ -4181,10 +5057,13 @@ function drawTgComponentMarks(svg, { drawnAnswer, focus, boxOf, make, edgePoints
|
|
|
4181
5057
|
if (rb) placed.push(rb);
|
|
4182
5058
|
// The job's status: after the title on its line, else at the right of that line.
|
|
4183
5059
|
if (w.status && tb) {
|
|
4184
|
-
|
|
5060
|
+
// behold#631: a chant kiosk's wave words half again as big.
|
|
5061
|
+
const size = marks.waveFont || 12;
|
|
4185
5062
|
const cy = (tb.y + tb.y2) / 2;
|
|
4186
5063
|
// Right after the title, as "apply-wave-2 · held at the gate"; else alone at the right of the title's line.
|
|
4187
5064
|
const spots = [{ words: `· ${w.status.words}`, at: () => tb.x2 + 6 }, { words: w.status.words, at: (wd) => b.x2 - 16 - wd }];
|
|
5065
|
+
// behold#631: a chant kiosk's box titles grow with the fit (scaleBoxLabels), which would run into words set just after them: the right of the line first.
|
|
5066
|
+
if (marks.statusRight) spots.reverse();
|
|
4188
5067
|
// behold#693: a narrow box whose full words would cross an edge says the short form.
|
|
4189
5068
|
const short = tgStatusShort(w.status);
|
|
4190
5069
|
if (short && short !== w.status.words) spots.push({ words: `· ${short}`, at: () => tb.x2 + 6 }, { words: short, at: (wd) => b.x2 - 16 - wd });
|
|
@@ -4209,7 +5088,8 @@ function drawTgComponentMarks(svg, { drawnAnswer, focus, boxOf, make, edgePoints
|
|
|
4209
5088
|
if (fact) {
|
|
4210
5089
|
const size = 12.5;
|
|
4211
5090
|
const digest = /^approve plan (\S+)/.exec(fact);
|
|
4212
|
-
|
|
5091
|
+
// behold#631: a fact may carry shorter forms of itself (a failure's reason, cut), tried in turn.
|
|
5092
|
+
const say = digest ? [fact, `plan ${digest[1]}`, `plan ${digest[1].slice(0, 8)}`, digest[1].slice(0, 8)] : [fact, ...(Array.isArray(w.factShort) ? w.factShort : [])];
|
|
4213
5093
|
const fill = w.state === "waiting" ? tone(w.tone) : "var(--muted)";
|
|
4214
5094
|
let done = false;
|
|
4215
5095
|
for (const words of say) {
|
|
@@ -4514,7 +5394,8 @@ function kioskShotTarget(svg, shot) {
|
|
|
4514
5394
|
const boxes = [];
|
|
4515
5395
|
if (shot.whole) {
|
|
4516
5396
|
// The whole graph is what is drawn: the boxes, the cards and the reads, not pinhole's margins round them.
|
|
4517
|
-
|
|
5397
|
+
// behold#744: not the reads' pills, which show and go while the shot stays.
|
|
5398
|
+
for (const n of svg.querySelectorAll("rect[data-group-id], [data-node-id], [data-tg-reads] > g:not([data-tg-read-pill]), line[data-tg-read-from], text[data-tg-reads='caption']")) boxes.push(userBoxOf(svg, n));
|
|
4518
5399
|
return unionBox(boxes) || { x: vbInit[0], y: vbInit[1], x2: vbInit[0] + vbInit[2], y2: vbInit[1] + vbInit[3] };
|
|
4519
5400
|
}
|
|
4520
5401
|
const named = (tgComponentFacets && tgComponentFacets.roots) || {};
|
|
@@ -4546,15 +5427,86 @@ function kioskShotBox() {
|
|
|
4546
5427
|
const host = document.getElementById("graph");
|
|
4547
5428
|
if (!svg || !host || !kioskShot) return null;
|
|
4548
5429
|
const pane = host.getBoundingClientRect();
|
|
4549
|
-
const
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
5430
|
+
const insets = kioskPaneInsets(kioskShot);
|
|
5431
|
+
// One framing on a small stage (web/kiosk-shot.js): when the whole graph fits with its cards readable, every step's
|
|
5432
|
+
// shot is the whole graph, and the viewBox holds from step to step and cycle to cycle while the repo, the view and
|
|
5433
|
+
// the pane stay. Judged with the room the held framing keeps, so a caption's height never flips the rule.
|
|
5434
|
+
// heldInsets: the run's caption's room at the top and the caption under the stage; nothing a step shows sits at the side.
|
|
5435
|
+
const docked = heldInsets(insets, kioskShot.room || 0);
|
|
5436
|
+
const rects = [...svg.querySelectorAll("[data-node-id] > rect")];
|
|
5437
|
+
const graph = `${new URLSearchParams(location.search).get("repo") || ""}|${view.components ? "components" : "resources"}`;
|
|
5438
|
+
// The graph itself, its boxes and cards: the marks, the reads' labels and the caption on it change from step to step.
|
|
5439
|
+
// Only the boxes' and the cards' own rects: a card's group also spans its hidden text and tooltips, and anything
|
|
5440
|
+
// else on the page (the reads' labels, the caption, the marks) is drawn over the graph, not part of what it spans.
|
|
5441
|
+
// A card or box grown to hold a cone's lines counts at its own height: the lines grow into the room under the
|
|
5442
|
+
// graph that the framing keeps, so they come and go with no move.
|
|
5443
|
+
const own = (r) => {
|
|
5444
|
+
const b = userBoxOf(svg, r);
|
|
5445
|
+
const h0 = Number(r.getAttribute("data-tg-h0"));
|
|
5446
|
+
const h = Number(r.getAttribute("height"));
|
|
5447
|
+
return b && h0 > 0 && h > 0 ? { ...b, y2: b.y + ((b.y2 - b.y) * h0) / h } : b;
|
|
5448
|
+
};
|
|
5449
|
+
// Only what is drawn: a rect hidden, or with no size on screen, is not part of the graph.
|
|
5450
|
+
const drawn = (r) => {
|
|
5451
|
+
const c = r.getBoundingClientRect();
|
|
5452
|
+
return c.width > 0 && c.height > 0 && !r.closest("[visibility='hidden'], [display='none']") && getComputedStyle(r).visibility !== "hidden";
|
|
4555
5453
|
};
|
|
5454
|
+
const whole = heldTarget([...svg.querySelectorAll("rect[data-group-id]")].filter(drawn).map(own), rects.filter(drawn).map(own));
|
|
5455
|
+
const cardW = medianWidth(rects.map((r) => {
|
|
5456
|
+
const b = userBoxOf(svg, r);
|
|
5457
|
+
return b ? b.x2 - b.x : 0;
|
|
5458
|
+
}));
|
|
5459
|
+
// A frame the kiosk swapped in (a new pin each step) takes up the framing the last one held.
|
|
5460
|
+
if (!kioskHeld) kioskHeld = readHeld();
|
|
5461
|
+
const held = kioskHeld && kioskHeld.key === graph ? kioskHeld : null;
|
|
5462
|
+
// Only an estate on choudoufu's live backend (the cone scenario's) is held; every other keeps a shot per step, as on main.
|
|
5463
|
+
// behold#736: a story's stage (fan-out-choudoufu, a chapter-carrying scenario, behold#741) is never held: it keeps
|
|
5464
|
+
// the story's own look, its result card, #745's pills and #748's outside mark.
|
|
5465
|
+
if (whole && !tgStoryOn() && holdsStage(tgAnswer && !tgAnswer.error ? tgAnswer.binaries : null) && smallStage(whole, pane, held ? held.insets : docked, cardW)) {
|
|
5466
|
+
kioskHeld = heldFrame(kioskHeld, { key: graph, pane, insets: docked, target: whole });
|
|
5467
|
+
writeHeld(kioskHeld);
|
|
5468
|
+
document.documentElement.classList.add("kiosk-held");
|
|
5469
|
+
// What the framing was made of, for a check from outside: the inputs, and why it last framed again.
|
|
5470
|
+
window.__kioskHeld = () => ({ ...kioskHeld, inputs: { pane: { width: pane.width, height: pane.height }, insets: docked, shot: kioskShot.insets, room: kioskShot.room || 0, cards: rects.length, cardW, target: whole } });
|
|
5471
|
+
return kioskHeld.vb;
|
|
5472
|
+
}
|
|
5473
|
+
kioskHeld = null;
|
|
5474
|
+
document.documentElement.classList.remove("kiosk-held");
|
|
4556
5475
|
return shotViewBox(kioskShotTarget(svg, kioskShot), pane, insets);
|
|
4557
5476
|
}
|
|
5477
|
+
/** The whole-graph framing Watch holds on a small stage while the graph and the pane stay (web/kiosk-shot.js heldFrame); null on a bigger one. */
|
|
5478
|
+
var kioskHeld = null;
|
|
5479
|
+
/** Where the held framing is kept for the frame the kiosk swaps in next: this tab's session, same origin as every frame. */
|
|
5480
|
+
var HELD_STORE = "behold.kiosk.held.v3";
|
|
5481
|
+
function readHeld() {
|
|
5482
|
+
try {
|
|
5483
|
+
const h = JSON.parse(sessionStorage.getItem(HELD_STORE) || "null");
|
|
5484
|
+
return h && typeof h.key === "string" && Array.isArray(h.vb) && h.pane && h.insets && h.target ? h : null;
|
|
5485
|
+
} catch {
|
|
5486
|
+
return null;
|
|
5487
|
+
}
|
|
5488
|
+
}
|
|
5489
|
+
function writeHeld(h) {
|
|
5490
|
+
try {
|
|
5491
|
+
sessionStorage.setItem(HELD_STORE, JSON.stringify(h));
|
|
5492
|
+
} catch {
|
|
5493
|
+
/* no storage: this frame still holds its own framing */
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5496
|
+
|
|
5497
|
+
/** A shot's insets (the frame's window px) as the graph pane's own: the pane's offset in the window comes off them. */
|
|
5498
|
+
function kioskPaneInsets(shot) {
|
|
5499
|
+
const host = document.getElementById("graph");
|
|
5500
|
+
const i = (shot && shot.insets) || {};
|
|
5501
|
+
if (!host) return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
5502
|
+
const pane = host.getBoundingClientRect();
|
|
5503
|
+
return {
|
|
5504
|
+
top: Math.max(0, (i.top || 0) - pane.top),
|
|
5505
|
+
left: Math.max(0, (i.left || 0) - pane.left),
|
|
5506
|
+
bottom: Math.max(0, (i.bottom || 0) - (window.innerHeight - pane.bottom)),
|
|
5507
|
+
right: Math.max(0, (i.right || 0) - (window.innerWidth - pane.right)),
|
|
5508
|
+
};
|
|
5509
|
+
}
|
|
4558
5510
|
|
|
4559
5511
|
/** Move to the shot: a pan and zoom over its time, or at once (a re-render, a resize, reduced motion). */
|
|
4560
5512
|
function applyKioskShot(animate) {
|
|
@@ -4567,9 +5519,11 @@ function applyKioskShot(animate) {
|
|
|
4567
5519
|
return;
|
|
4568
5520
|
}
|
|
4569
5521
|
if (sameViewBox(vb, to)) return kioskTellBoxes();
|
|
5522
|
+
// A held small stage lands on its one framing at once: a frame the kiosk swapped in never moves into it on screen.
|
|
5523
|
+
const landing = !!kioskHeld && vbAtFit;
|
|
4570
5524
|
vbAtFit = false;
|
|
4571
5525
|
const ms = kioskShot.ms;
|
|
4572
|
-
if (!animate || reducedMotion() || !(ms > 0)) {
|
|
5526
|
+
if (!animate || landing || reducedMotion() || !(ms > 0)) {
|
|
4573
5527
|
if (shotAnim) cancelAnimationFrame(shotAnim.raf);
|
|
4574
5528
|
shotAnim = null;
|
|
4575
5529
|
vb = to;
|
|
@@ -4635,11 +5589,13 @@ function kioskTellBoxes() {
|
|
|
4635
5589
|
}
|
|
4636
5590
|
}
|
|
4637
5591
|
// The reads' labels too, which the kiosk's callouts keep clear of.
|
|
4638
|
-
|
|
5592
|
+
// behold#744: a read's pill only while it shows.
|
|
5593
|
+
const labels = [...svg.querySelectorAll("[data-tg-reads] > g:not([data-tg-read-pill]), [data-tg-reads] > g.tg-flash, [data-tg-reads] > g.tg-hot, [data-tg-reads] > g.tg-shown")].map((g) => rect(g.getBoundingClientRect())).filter((r) => r.w > 0);
|
|
4639
5594
|
const host = document.getElementById("graph");
|
|
4640
5595
|
const pane = host ? rect(host.getBoundingClientRect()) : null;
|
|
4641
5596
|
try {
|
|
4642
|
-
|
|
5597
|
+
// held: one framing holds the small stage.
|
|
5598
|
+
window.parent.postMessage({ type: "behold:boxes", waves, roots, labels, pane, moving: !!shotAnim, held: !!kioskHeld }, embedOpts.host);
|
|
4643
5599
|
} catch {
|
|
4644
5600
|
/* the parent went away */
|
|
4645
5601
|
}
|
|
@@ -4660,6 +5616,8 @@ function kioskTellDrawn() {
|
|
|
4660
5616
|
if (!failed && !(svg && svg.querySelector("[data-node-id]"))) return;
|
|
4661
5617
|
// The marks: terragucci's reports answered (or refused), or chant's loop has its own.
|
|
4662
5618
|
if (!failed && terragucciComponentsRepo && !tgAnswer && !chantPrDrawn()) return;
|
|
5619
|
+
// behold#631: a chant repo's loop: its first read of /api/chant/pr, answered or not.
|
|
5620
|
+
if (!failed && !terragucciComponentsRepo && view.components && chantFacets && !staticMode && !chantPrRead) return;
|
|
4663
5621
|
drawnTold = true;
|
|
4664
5622
|
try {
|
|
4665
5623
|
window.parent.postMessage({ type: "behold:drawn", failed }, embedOpts.host);
|
|
@@ -4678,6 +5636,7 @@ window.addEventListener("message", (e) => {
|
|
|
4678
5636
|
if (shotAnim) cancelAnimationFrame(shotAnim.raf);
|
|
4679
5637
|
shotAnim = null;
|
|
4680
5638
|
kioskShot = null;
|
|
5639
|
+
document.documentElement.classList.remove("kiosk-held"); // Inspect: the zoom rail is the viewer's again
|
|
4681
5640
|
fitGraph();
|
|
4682
5641
|
return;
|
|
4683
5642
|
}
|
|
@@ -4750,6 +5709,19 @@ function wireKioskFrame() {
|
|
|
4750
5709
|
if (e.data && e.data.type === "behold:unpin") return kioskPopEvent({ type: "outside" });
|
|
4751
5710
|
// behold#571: the kiosk's theme picker moved; follow it here without a reload.
|
|
4752
5711
|
if (e.data && e.data.type === "behold:theme" && typeof e.data.name === "string") return void setTheme(e.data.name, { persist: false });
|
|
5712
|
+
// behold#741: the scenario carries chapters (or stopped carrying them): the kiosk's look, and the wave blocks, follow.
|
|
5713
|
+
if (e.data && e.data.type === "behold:story") {
|
|
5714
|
+
const on = e.data.on === true;
|
|
5715
|
+
const cycle = Number.isInteger(e.data.cycle) ? e.data.cycle : null;
|
|
5716
|
+
const was = tgStoryOn();
|
|
5717
|
+
// behold#743: the step's apply made outside the pipeline, or null; a change redraws the marks.
|
|
5718
|
+
const outside = e.data.outside && typeof e.data.outside === "object" && typeof e.data.outside.estate === "string" ? e.data.outside : null;
|
|
5719
|
+
const outsideMoved = JSON.stringify(outside) !== JSON.stringify((tgStory && tgStory.outside) || null);
|
|
5720
|
+
tgStory = { on, cycle, outside };
|
|
5721
|
+
if (tgStoryOn() !== was && view.components && terragucciComponentsRepo) load({ quiet: true });
|
|
5722
|
+
else if (outsideMoved && tgStoryOn()) drawTgReads();
|
|
5723
|
+
return;
|
|
5724
|
+
}
|
|
4753
5725
|
const h = hoverFromMessage(e.data);
|
|
4754
5726
|
if (h === undefined) return;
|
|
4755
5727
|
kioskHostHover = h;
|
|
@@ -4971,6 +5943,320 @@ function approveFromLane(key, env, btn) {
|
|
|
4971
5943
|
}
|
|
4972
5944
|
initTrunkLane();
|
|
4973
5945
|
|
|
5946
|
+
// --- #683: feature flags, on or off per environment ---------------------------
|
|
5947
|
+
// The Flags tab reads /api/workspace/flags when it is opened: each flag of the
|
|
5948
|
+
// workspace with its owner, work item and value per environment, a flip
|
|
5949
|
+
// waiting at a gate as the link that opens that gate's change set (#681), and
|
|
5950
|
+
// otherwise the lines a person runs to turn it on. behold changes no flag. The
|
|
5951
|
+
// tab picks an environment, and every card of a flagged member gets a tag under
|
|
5952
|
+
// it, since chant names no node that reads a build parameter.
|
|
5953
|
+
let flAnswer = null;
|
|
5954
|
+
let flOn = true;
|
|
5955
|
+
let flEnv = null;
|
|
5956
|
+
let flHost = null;
|
|
5957
|
+
let flRead = false;
|
|
5958
|
+
async function initFlags() {
|
|
5959
|
+
if (staticMode || publicMode) return; // /api/workspace/* is refused in a public view
|
|
5960
|
+
const project = await apiFetch("/api/project").then((r) => r.json()).catch(() => ({}));
|
|
5961
|
+
if (!project.workspace) return;
|
|
5962
|
+
flHost = addPanelTab("flags", "Flags", "The workspace's feature flags, on or off per environment, with their owner and work item. Read from chant when you open the tab.");
|
|
5963
|
+
if (!flHost) return;
|
|
5964
|
+
flHost.id = "tab-flags";
|
|
5965
|
+
const tab = document.querySelector('#panel-tabs button[data-tab="flags"]');
|
|
5966
|
+
if (tab) tab.addEventListener("click", () => flRead || loadFlags());
|
|
5967
|
+
if (flHost.classList.contains("active")) loadFlags();
|
|
5968
|
+
}
|
|
5969
|
+
async function loadFlags() {
|
|
5970
|
+
flRead = true;
|
|
5971
|
+
const reading = document.createElement("div");
|
|
5972
|
+
reading.className = "tg-legend";
|
|
5973
|
+
reading.textContent = "reading the flags from chant";
|
|
5974
|
+
flHost.replaceChildren(reading);
|
|
5975
|
+
flAnswer = await apiFetch("/api/workspace/flags")
|
|
5976
|
+
.then((r) => r.json())
|
|
5977
|
+
.catch((e) => ({ error: String(e) }));
|
|
5978
|
+
flEnv = flPickEnv(flAnswer, flEnv || view.env);
|
|
5979
|
+
markFlagCards();
|
|
5980
|
+
}
|
|
5981
|
+
function markFlagCards() {
|
|
5982
|
+
const svg = document.querySelector("#graph svg");
|
|
5983
|
+
if (svg) {
|
|
5984
|
+
for (const old of svg.querySelectorAll("[data-fl-mark]")) old.remove();
|
|
5985
|
+
if (flAnswer && flOn) {
|
|
5986
|
+
const ids = [...svg.querySelectorAll("[data-node-id]")].map((g) => g.getAttribute("data-node-id"));
|
|
5987
|
+
for (const [id, m] of Object.entries(flFlagMarks(flAnswer, flEnv, ids, nodeMember))) {
|
|
5988
|
+
const g = svg.querySelector('[data-node-id="' + CSS.escape(id) + '"]');
|
|
5989
|
+
if (!g) continue;
|
|
5990
|
+
const rect = g.querySelector("rect");
|
|
5991
|
+
const box = rect && rect.getBBox ? rect.getBBox() : { x: 0, y: 0, width: 150, height: 60 };
|
|
5992
|
+
const tag = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
5993
|
+
tag.setAttribute("data-fl-mark", "tag");
|
|
5994
|
+
tag.setAttribute("x", String(box.x));
|
|
5995
|
+
tag.setAttribute("y", String(box.y + box.height + 13));
|
|
5996
|
+
tag.setAttribute("font-size", "11");
|
|
5997
|
+
tag.setAttribute("font-weight", "700");
|
|
5998
|
+
tag.setAttribute("fill", m.stale ? FL_STALE_COLOR : m.color);
|
|
5999
|
+
tag.textContent = m.tag;
|
|
6000
|
+
const title = document.createElementNS("http://www.w3.org/2000/svg", "title");
|
|
6001
|
+
title.setAttribute("data-fl-mark", "title");
|
|
6002
|
+
title.textContent = m.title;
|
|
6003
|
+
tag.appendChild(title);
|
|
6004
|
+
g.append(tag);
|
|
6005
|
+
}
|
|
6006
|
+
}
|
|
6007
|
+
}
|
|
6008
|
+
renderFlagsTab();
|
|
6009
|
+
}
|
|
6010
|
+
function renderFlagsTab() {
|
|
6011
|
+
if (!flHost) return;
|
|
6012
|
+
flHost.replaceChildren();
|
|
6013
|
+
const line = (cls, text, title, host = flHost) => {
|
|
6014
|
+
const d = document.createElement("div");
|
|
6015
|
+
d.className = cls;
|
|
6016
|
+
d.textContent = text;
|
|
6017
|
+
if (title) d.title = title;
|
|
6018
|
+
host.appendChild(d);
|
|
6019
|
+
return d;
|
|
6020
|
+
};
|
|
6021
|
+
const h = flHeader(flAnswer);
|
|
6022
|
+
line(h.tone === "refusal" ? "tg-refusal" : "fl-title", h.text, h.title);
|
|
6023
|
+
const refused = !flAnswer || flAnswer.error || flAnswer.refusal;
|
|
6024
|
+
if (refused && flAnswer && flAnswer.degraded) line("tg-legend", `Without it, ${flAnswer.degraded}.`);
|
|
6025
|
+
if (!refused) {
|
|
6026
|
+
line("tg-legend", FL_NODES_NOTE);
|
|
6027
|
+
if (flAnswer.environments.length) {
|
|
6028
|
+
const pick = document.createElement("div");
|
|
6029
|
+
pick.className = "fl-envs";
|
|
6030
|
+
const label = document.createElement("span");
|
|
6031
|
+
label.textContent = "on the graph in";
|
|
6032
|
+
pick.appendChild(label);
|
|
6033
|
+
for (const env of flAnswer.environments) {
|
|
6034
|
+
const b = button(env, env === flEnv ? "fl-env on" : "fl-env", () => {
|
|
6035
|
+
flEnv = env;
|
|
6036
|
+
markFlagCards();
|
|
6037
|
+
});
|
|
6038
|
+
b.setAttribute("aria-pressed", String(env === flEnv));
|
|
6039
|
+
b.title = `Mark each flagged card with its flags' values in ${env}.`;
|
|
6040
|
+
pick.appendChild(b);
|
|
6041
|
+
}
|
|
6042
|
+
flHost.appendChild(pick);
|
|
6043
|
+
}
|
|
6044
|
+
for (const g of flGapLines(flAnswer)) line("tg-refusal", g.text, g.title);
|
|
6045
|
+
const toggle = button(flOn ? "Turn off the marks" : "Turn on the marks", "", () => {
|
|
6046
|
+
flOn = !flOn;
|
|
6047
|
+
markFlagCards();
|
|
6048
|
+
});
|
|
6049
|
+
toggle.title = flOn ? "Remove the flag marks from the graph. The tab keeps the flags." : "Mark the flagged cards on the graph again.";
|
|
6050
|
+
flHost.appendChild(toggle);
|
|
6051
|
+
if (!flAnswer.flags.length) line("tg-legend", "no member has a feature flag");
|
|
6052
|
+
for (const f of flAnswer.flags) {
|
|
6053
|
+
const r = flFlagRow(f, flEnv);
|
|
6054
|
+
const box = document.createElement("div");
|
|
6055
|
+
box.className = "fl-flag";
|
|
6056
|
+
const title = line("fl-flag-title", r.title, r.path, box);
|
|
6057
|
+
if (r.stale) {
|
|
6058
|
+
const s = document.createElement("span");
|
|
6059
|
+
s.className = "fl-stale";
|
|
6060
|
+
s.textContent = ` · ${r.stale.text}`;
|
|
6061
|
+
s.title = r.stale.title;
|
|
6062
|
+
title.appendChild(s);
|
|
6063
|
+
}
|
|
6064
|
+
line("fl-facts", r.facts, "", box);
|
|
6065
|
+
const values = document.createElement("div");
|
|
6066
|
+
values.className = "fl-values";
|
|
6067
|
+
for (const v of r.values) {
|
|
6068
|
+
const span = document.createElement("span");
|
|
6069
|
+
span.className = v.current ? "fl-value current" : "fl-value";
|
|
6070
|
+
span.style.setProperty("--dot", v.color);
|
|
6071
|
+
span.textContent = v.text;
|
|
6072
|
+
values.appendChild(span);
|
|
6073
|
+
}
|
|
6074
|
+
box.appendChild(values);
|
|
6075
|
+
for (const w of r.waiting) {
|
|
6076
|
+
const d = line("fl-waiting", `${w.text} · `, "", box);
|
|
6077
|
+
const a = document.createElement("a");
|
|
6078
|
+
a.href = "#";
|
|
6079
|
+
a.className = "lane-change-set";
|
|
6080
|
+
a.textContent = w.link;
|
|
6081
|
+
a.title = w.title;
|
|
6082
|
+
a.addEventListener("click", (ev) => {
|
|
6083
|
+
ev.preventDefault();
|
|
6084
|
+
openChangeSet(w.gate, w.env);
|
|
6085
|
+
});
|
|
6086
|
+
d.appendChild(a);
|
|
6087
|
+
}
|
|
6088
|
+
for (const t of r.turnOn) {
|
|
6089
|
+
line("fl-turn-on", t.head, FL_TURN_ON_NOTE, box);
|
|
6090
|
+
const pre = document.createElement("pre");
|
|
6091
|
+
pre.className = "fl-lines";
|
|
6092
|
+
pre.textContent = t.lines.join("\n");
|
|
6093
|
+
pre.title = FL_TURN_ON_NOTE;
|
|
6094
|
+
box.appendChild(pre);
|
|
6095
|
+
}
|
|
6096
|
+
flHost.appendChild(box);
|
|
6097
|
+
}
|
|
6098
|
+
if (flAnswer.flags.some((f) => f.turnOn.length)) line("tg-legend", FL_TURN_ON_NOTE);
|
|
6099
|
+
}
|
|
6100
|
+
if (!staticMode) {
|
|
6101
|
+
const again = button("Read again", "", () => loadFlags());
|
|
6102
|
+
again.title = "Read the flags and every environment's gates from chant again.";
|
|
6103
|
+
flHost.appendChild(again);
|
|
6104
|
+
}
|
|
6105
|
+
}
|
|
6106
|
+
initFlags();
|
|
6107
|
+
|
|
6108
|
+
// --- #684: collision marks, nodes touched by two in-flight work items --------
|
|
6109
|
+
// The Collisions tab reads /api/workspace/collisions when it is opened: the
|
|
6110
|
+
// in-flight work items chant reports (workspace status overlap, chant#4025),
|
|
6111
|
+
// the nodes two of them reach through a waiting gate's change set (a ring and
|
|
6112
|
+
// a tag on each card), and on the side the files they both changed, which
|
|
6113
|
+
// have no node. The filter keeps only colliding work: the other cards and the
|
|
6114
|
+
// edges that touch them are hidden. behold records and locks nothing.
|
|
6115
|
+
let coAnswer = null;
|
|
6116
|
+
let coOn = true;
|
|
6117
|
+
let coOnly = false;
|
|
6118
|
+
let coHost = null;
|
|
6119
|
+
let coRead = false;
|
|
6120
|
+
async function initCollisions() {
|
|
6121
|
+
if (staticMode || publicMode) return; // /api/workspace/* is refused in a public view
|
|
6122
|
+
const project = await apiFetch("/api/project").then((r) => r.json()).catch(() => ({}));
|
|
6123
|
+
if (!project.workspace) return;
|
|
6124
|
+
coHost = addPanelTab("collisions", "Collisions", "In-flight work items that touch the same resource, marked on the graph. Read from chant when you open the tab.");
|
|
6125
|
+
if (!coHost) return;
|
|
6126
|
+
coHost.id = "tab-collisions";
|
|
6127
|
+
const tab = document.querySelector('#panel-tabs button[data-tab="collisions"]');
|
|
6128
|
+
if (tab) tab.addEventListener("click", () => coRead || loadCollisions());
|
|
6129
|
+
if (coHost.classList.contains("active")) loadCollisions();
|
|
6130
|
+
}
|
|
6131
|
+
async function loadCollisions() {
|
|
6132
|
+
coRead = true;
|
|
6133
|
+
const reading = document.createElement("div");
|
|
6134
|
+
reading.className = "tg-legend";
|
|
6135
|
+
reading.textContent = "reading the work overlap from chant";
|
|
6136
|
+
coHost.replaceChildren(reading);
|
|
6137
|
+
coAnswer = await apiFetch("/api/workspace/collisions")
|
|
6138
|
+
.then((r) => r.json())
|
|
6139
|
+
.catch((e) => ({ error: String(e) }));
|
|
6140
|
+
markCollisionCards();
|
|
6141
|
+
}
|
|
6142
|
+
function markCollisionCards() {
|
|
6143
|
+
const svg = document.querySelector("#graph svg");
|
|
6144
|
+
if (svg) {
|
|
6145
|
+
for (const old of svg.querySelectorAll("[data-co-mark]")) old.remove();
|
|
6146
|
+
for (const h of svg.querySelectorAll("[data-co-hidden]")) {
|
|
6147
|
+
h.removeAttribute("data-co-hidden");
|
|
6148
|
+
h.style.display = "";
|
|
6149
|
+
}
|
|
6150
|
+
if (coAnswer && coOn) {
|
|
6151
|
+
const ids = [...svg.querySelectorAll("[data-node-id]")].map((g) => g.getAttribute("data-node-id"));
|
|
6152
|
+
for (const [id, m] of Object.entries(coMarks(coAnswer, ids))) {
|
|
6153
|
+
const g = svg.querySelector('[data-node-id="' + CSS.escape(id) + '"]');
|
|
6154
|
+
if (!g) continue;
|
|
6155
|
+
const rect = g.querySelector("rect");
|
|
6156
|
+
const box = rect && rect.getBBox ? rect.getBBox() : { x: 0, y: 0, width: 150, height: 60 };
|
|
6157
|
+
const ring = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
6158
|
+
ring.setAttribute("data-co-mark", "ring");
|
|
6159
|
+
ring.setAttribute("x", String(box.x - 3));
|
|
6160
|
+
ring.setAttribute("y", String(box.y - 3));
|
|
6161
|
+
ring.setAttribute("width", String(box.width + 6));
|
|
6162
|
+
ring.setAttribute("height", String(box.height + 6));
|
|
6163
|
+
ring.setAttribute("rx", "8");
|
|
6164
|
+
ring.setAttribute("fill", "none");
|
|
6165
|
+
ring.setAttribute("stroke", m.color);
|
|
6166
|
+
ring.setAttribute("stroke-width", "2");
|
|
6167
|
+
ring.setAttribute("stroke-dasharray", "5 3");
|
|
6168
|
+
ring.setAttribute("pointer-events", "none");
|
|
6169
|
+
const tag = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
6170
|
+
tag.setAttribute("data-co-mark", "tag");
|
|
6171
|
+
tag.setAttribute("x", String(box.x));
|
|
6172
|
+
tag.setAttribute("y", String(box.y + box.height + 26));
|
|
6173
|
+
tag.setAttribute("font-size", "11");
|
|
6174
|
+
tag.setAttribute("font-weight", "700");
|
|
6175
|
+
tag.setAttribute("fill", m.color);
|
|
6176
|
+
tag.textContent = m.tag;
|
|
6177
|
+
const title = document.createElementNS("http://www.w3.org/2000/svg", "title");
|
|
6178
|
+
title.setAttribute("data-co-mark", "title");
|
|
6179
|
+
title.textContent = m.title;
|
|
6180
|
+
tag.appendChild(title);
|
|
6181
|
+
g.append(ring, tag);
|
|
6182
|
+
}
|
|
6183
|
+
if (coOnly) {
|
|
6184
|
+
for (const id of coFilter(coAnswer, ids, true).hide) {
|
|
6185
|
+
const g = svg.querySelector('[data-node-id="' + CSS.escape(id) + '"]');
|
|
6186
|
+
if (g) {
|
|
6187
|
+
g.setAttribute("data-co-hidden", "true");
|
|
6188
|
+
g.style.display = "none";
|
|
6189
|
+
}
|
|
6190
|
+
}
|
|
6191
|
+
for (const e of svg.querySelectorAll("g[data-edge-from]")) {
|
|
6192
|
+
if (!coHideEdge(coAnswer, e.getAttribute("data-edge-from"), e.getAttribute("data-edge-to"), true)) continue;
|
|
6193
|
+
e.setAttribute("data-co-hidden", "true");
|
|
6194
|
+
e.style.display = "none";
|
|
6195
|
+
}
|
|
6196
|
+
}
|
|
6197
|
+
}
|
|
6198
|
+
}
|
|
6199
|
+
renderCollisionsTab();
|
|
6200
|
+
}
|
|
6201
|
+
function renderCollisionsTab() {
|
|
6202
|
+
if (!coHost) return;
|
|
6203
|
+
coHost.replaceChildren();
|
|
6204
|
+
const line = (cls, text, title, host = coHost) => {
|
|
6205
|
+
const d = document.createElement("div");
|
|
6206
|
+
d.className = cls;
|
|
6207
|
+
d.textContent = text;
|
|
6208
|
+
if (title) d.title = title;
|
|
6209
|
+
host.appendChild(d);
|
|
6210
|
+
return d;
|
|
6211
|
+
};
|
|
6212
|
+
const h = coHeader(coAnswer);
|
|
6213
|
+
line(h.tone === "refusal" ? "tg-refusal" : "fl-title", h.text, h.title);
|
|
6214
|
+
const refused = !coAnswer || coAnswer.error || coAnswer.refusal;
|
|
6215
|
+
if (refused && coAnswer && coAnswer.degraded) line("tg-legend", `Without it, ${coAnswer.degraded}.`);
|
|
6216
|
+
if (!refused) {
|
|
6217
|
+
for (const g of coGapLines(coAnswer)) line("tg-legend", g.text, g.title);
|
|
6218
|
+
const filter = button(coOnly ? CO_FILTER_ON : CO_FILTER_OFF, "", () => {
|
|
6219
|
+
coOnly = !coOnly;
|
|
6220
|
+
markCollisionCards();
|
|
6221
|
+
});
|
|
6222
|
+
filter.setAttribute("aria-pressed", String(coOnly));
|
|
6223
|
+
filter.title = coOnly ? "Draw every card and every work item again." : "Hide the cards that no two work items touch, and the work items that collide with none.";
|
|
6224
|
+
coHost.appendChild(filter);
|
|
6225
|
+
const toggle = button(coOn ? "Turn off the marks" : "Turn on the marks", "", () => {
|
|
6226
|
+
coOn = !coOn;
|
|
6227
|
+
markCollisionCards();
|
|
6228
|
+
});
|
|
6229
|
+
toggle.title = coOn ? "Remove the collision marks from the graph. The tab keeps the work items." : "Mark the colliding cards on the graph again.";
|
|
6230
|
+
coHost.appendChild(toggle);
|
|
6231
|
+
const ids = [...document.querySelectorAll("#graph svg [data-node-id]")].map((g) => g.getAttribute("data-node-id"));
|
|
6232
|
+
const shown = coFilter(coAnswer, ids, coOnly);
|
|
6233
|
+
if (shown.nodes.length) {
|
|
6234
|
+
line("fl-title", "nodes touched by two or more work items", CO_NOTE);
|
|
6235
|
+
for (const n of shown.nodes.map(coNodeRow)) line("fl-facts", n.text, n.title);
|
|
6236
|
+
}
|
|
6237
|
+
const side = coSideLines(coAnswer);
|
|
6238
|
+
if (side.length) {
|
|
6239
|
+
line("fl-title", "no graph node", CO_FILES_NOTE);
|
|
6240
|
+
for (const s of side) line("fl-facts", s.text, s.title);
|
|
6241
|
+
}
|
|
6242
|
+
if (!shown.items.length) line("tg-legend", coOnly ? "no work item collides with another" : "no in-flight work item has a linked commit");
|
|
6243
|
+
for (const i of shown.items.map(coItemRow)) {
|
|
6244
|
+
const box = document.createElement("div");
|
|
6245
|
+
box.className = "fl-flag";
|
|
6246
|
+
line("fl-flag-title", i.title, "", box);
|
|
6247
|
+
line("fl-facts", i.facts, "", box);
|
|
6248
|
+
line(i.colliding ? "fl-stale" : "fl-facts", i.with, "", box);
|
|
6249
|
+
coHost.appendChild(box);
|
|
6250
|
+
}
|
|
6251
|
+
}
|
|
6252
|
+
if (!staticMode) {
|
|
6253
|
+
const again = button("Read again", "", () => loadCollisions());
|
|
6254
|
+
again.title = "Read the work overlap from chant again.";
|
|
6255
|
+
coHost.appendChild(again);
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
6258
|
+
initCollisions();
|
|
6259
|
+
|
|
4974
6260
|
// --- #681: a waiting gate's change set, on the graph -------------------------
|
|
4975
6261
|
// Opened from a gate card's "change set" link in the Trunk tab. The server
|
|
4976
6262
|
// reads the gate from status and the stored change set from chant change-set
|
|
@@ -5418,23 +6704,117 @@ let ciForge = null; // the forge the pipeline was generated for (#164) — heads
|
|
|
5418
6704
|
// (`meta.terragucciComponents`, see takeTerragucciFacets), which a public view
|
|
5419
6705
|
// can read, so the two facet fetches below are skipped.
|
|
5420
6706
|
let terragucciComponentsRepo = false;
|
|
6707
|
+
/**
|
|
6708
|
+
* behold#741: the kiosk's word that the scenario it shows carries chapters (demo.json's step `chapter`), with the
|
|
6709
|
+
* cycle: `{ on, cycle }` from a `behold:story` message, null until one comes. Only a kiosk frame (bare) of a
|
|
6710
|
+
* terragucci repo's components zoom acts on it; b-waves, failure and tg-planned-outputs send `on: false`.
|
|
6711
|
+
* behold#743: `outside` too, the step's apply made outside the pipeline (demo.json's), or null.
|
|
6712
|
+
*/
|
|
6713
|
+
let tgStory = null;
|
|
6714
|
+
function tgStoryOn() {
|
|
6715
|
+
return !!(embedOpts.bare && tgStory && tgStory.on && terragucciComponentsRepo);
|
|
6716
|
+
}
|
|
6717
|
+
// behold#741: what landed in this cycle's earlier apply, and what its failure left, for the next pull request's cards.
|
|
6718
|
+
let tgStoryEarlier = { cycle: null, earlier: new Set(), lastStates: {} };
|
|
6719
|
+
function tgStoryMarks() {
|
|
6720
|
+
if (!tgStoryOn() || !view.components) return null;
|
|
6721
|
+
if (tgStoryEarlier.cycle !== tgStory.cycle || view.run === "base") tgStoryEarlier = { cycle: tgStory.cycle, earlier: new Set(), lastStates: {} };
|
|
6722
|
+
return { kiosk: true, earlier: tgStoryEarlier.earlier, lastStates: tgStoryEarlier.lastStates };
|
|
6723
|
+
}
|
|
6724
|
+
/** Keep what an apply's cards say: applied roots land in `earlier`; a failed or blocked one keeps that state until it applies. */
|
|
6725
|
+
function tgStoryRemember(marks) {
|
|
6726
|
+
if (!marks || marks.stage !== "apply") return;
|
|
6727
|
+
for (const c of Object.values(marks.cards)) {
|
|
6728
|
+
if (c.state === "applied") {
|
|
6729
|
+
tgStoryEarlier.earlier.add(c.root);
|
|
6730
|
+
delete tgStoryEarlier.lastStates[c.root];
|
|
6731
|
+
} else if (c.state === "failed" || c.state === "blocked") tgStoryEarlier.lastStates[c.root] = { state: c.state, words: c.words, ...(c.blockedBy ? { blockedBy: c.blockedBy } : {}) };
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
// behold#741: the run view's waves at the pace chant's are played (web/terragucci-live-pace.js), while the story is on.
|
|
6735
|
+
const tgPacer = createProgressPacer();
|
|
6736
|
+
let tgPaceTimer = null;
|
|
6737
|
+
function tgPacedProgress() {
|
|
6738
|
+
const p = tgPacer.progress(tgProgress);
|
|
6739
|
+
if (tgPacer.pending && !tgPaceTimer) {
|
|
6740
|
+
let was = JSON.stringify(p && p.states);
|
|
6741
|
+
tgPaceTimer = setInterval(() => {
|
|
6742
|
+
const next = tgPacer.progress(tgProgress);
|
|
6743
|
+
const now = JSON.stringify(next && next.states);
|
|
6744
|
+
if (now !== was) {
|
|
6745
|
+
was = now;
|
|
6746
|
+
drawTgReads();
|
|
6747
|
+
}
|
|
6748
|
+
if (!tgPacer.pending) {
|
|
6749
|
+
clearInterval(tgPaceTimer);
|
|
6750
|
+
tgPaceTimer = null;
|
|
6751
|
+
}
|
|
6752
|
+
}, 400);
|
|
6753
|
+
}
|
|
6754
|
+
return p;
|
|
6755
|
+
}
|
|
5421
6756
|
// #571: the components graph's facets (jobs, component -> root), for the live marks drawTgReads puts on it.
|
|
5422
6757
|
let tgComponentFacets = null;
|
|
5423
6758
|
// behold#631: a chant repo's pull-request loop: the graph's `meta.chantPr` and /api/chant/pr's answer at the view's run pin.
|
|
5424
6759
|
let chantFacets = null;
|
|
5425
6760
|
let chantPrAnswer = null;
|
|
5426
6761
|
let chantPrTimer = null;
|
|
6762
|
+
/** Whether /api/chant/pr has answered (or failed) once since the components view drew, so a kiosk frame swaps in with its marks on. */
|
|
6763
|
+
let chantPrRead = false;
|
|
6764
|
+
// behold#631: a fast apply played at a pace a viewer can follow (web/chant-live-pace.js).
|
|
6765
|
+
const chantPacer = createLivePacer();
|
|
6766
|
+
let chantPaceTimer = null;
|
|
6767
|
+
let chantPacedWas = null;
|
|
6768
|
+
/** The answer as the pacer shows it now; while it is behind the stream, redraw as it plays. */
|
|
6769
|
+
function chantPaced() {
|
|
6770
|
+
const a = chantPacer.answer(chantPrAnswer);
|
|
6771
|
+
chantPacedWas = JSON.stringify(a && a.live ? a.live.apply : null);
|
|
6772
|
+
if (chantPacer.pending && !chantPaceTimer) {
|
|
6773
|
+
chantPaceTimer = setInterval(() => {
|
|
6774
|
+
const next = chantPacer.answer(chantPrAnswer);
|
|
6775
|
+
const was = chantPacedWas;
|
|
6776
|
+
if (JSON.stringify(next && next.live ? next.live.apply : null) !== was) drawTgReads();
|
|
6777
|
+
if (!chantPacer.pending) {
|
|
6778
|
+
clearInterval(chantPaceTimer);
|
|
6779
|
+
chantPaceTimer = null;
|
|
6780
|
+
}
|
|
6781
|
+
}, 400);
|
|
6782
|
+
}
|
|
6783
|
+
return a;
|
|
6784
|
+
}
|
|
5427
6785
|
function chantPrDrawn() {
|
|
5428
6786
|
return !!(view.components && chantFacets && !terragucciComponentsRepo && chantPrAnswer && !chantPrAnswer.error && chantPrAnswer.loop);
|
|
5429
6787
|
}
|
|
5430
6788
|
async function loadChantPr() {
|
|
5431
6789
|
const pin = view.run || "";
|
|
5432
6790
|
const was = JSON.stringify(chantPrAnswer);
|
|
5433
|
-
|
|
6791
|
+
let answer = await apiFetch(`/api/chant/pr${pin ? `?pin=${encodeURIComponent(pin)}` : ""}`)
|
|
5434
6792
|
.then((r) => (r.ok ? r.json() : null))
|
|
5435
6793
|
.catch(() => null);
|
|
5436
6794
|
if ((view.run || "") !== pin) return; // the pin moved while this read ran
|
|
6795
|
+
// behold#631: at the merge, before the apply's run is listed, the merge commit names no pull request yet and the
|
|
6796
|
+
// answer comes back empty: the cards keep the plan they had until the apply's own records replace it.
|
|
6797
|
+
const nothing = (a) => a && !a.error && !a.plan && !a.apply && !a.running && !(a.live && (a.live.apply || a.live.plan));
|
|
6798
|
+
if (nothing(answer) && chantPrAnswer && chantPrAnswer.plan && pin && pin !== "base" && pin !== "none" && !/^pull/.test(pin)) answer = { ...answer, pull: chantPrAnswer.pull, plan: chantPrAnswer.plan, gate: chantPrAnswer.gate, ...(chantPrAnswer.live ? { live: { ...chantPrAnswer.live, apply: null, plan: null } } : {}), carried: true };
|
|
6799
|
+
// behold#631: a new pull request of the cycle (the fix) that has no plan yet: its cards keep what they were.
|
|
6800
|
+
// What landed reads applied earlier; a failed or blocked card keeps that state until the fix's plan says otherwise.
|
|
6801
|
+
const noPlanYet = (a) => a && !a.error && !a.plan && !a.apply && !(a.live && (a.live.apply || a.live.plan));
|
|
6802
|
+
if (noPlanYet(answer) && /^pull/.test(pin) && chantPrAnswer && chantFacets) {
|
|
6803
|
+
const prev = chantPrAnswer;
|
|
6804
|
+
let lastStates = prev.lastStates && prev.pull === answer.pull ? prev.lastStates : null;
|
|
6805
|
+
let landed = new Set(prev.live && prev.live.earlier ? prev.live.earlier.applied : []);
|
|
6806
|
+
if (!lastStates && (prev.plan || (prev.live && prev.live.apply)) && prev.pull !== answer.pull) {
|
|
6807
|
+
const cards = chantComponentMarks(chantPacer.answer(prev), chantFacets).cards;
|
|
6808
|
+
lastStates = {};
|
|
6809
|
+
for (const [c, m] of Object.entries(cards)) {
|
|
6810
|
+
if (m.state === "failed" || m.state === "blocked") lastStates[c] = m.state;
|
|
6811
|
+
else if (m.state === "applied" || m.state === "already-applied" || m.state === "applied-earlier") landed.add(c);
|
|
6812
|
+
}
|
|
6813
|
+
}
|
|
6814
|
+
if (lastStates) answer = { ...answer, lastStates, live: { ...(answer.live || { reportUrl: null, via: "pipeline" }), plan: null, apply: null, earlier: { runs: (answer.live && answer.live.earlier && answer.live.earlier.runs) || [], applied: [...new Set([...landed, ...((answer.live && answer.live.earlier && answer.live.earlier.applied) || [])])] } } };
|
|
6815
|
+
}
|
|
5437
6816
|
chantPrAnswer = answer;
|
|
6817
|
+
chantPrRead = true;
|
|
5438
6818
|
if (JSON.stringify(answer) !== was) drawTgReads();
|
|
5439
6819
|
}
|
|
5440
6820
|
/** Read the loop every few seconds while a chant repo's components view is on screen. */
|
|
@@ -6146,7 +7526,8 @@ function wireEdgeHighlight(svgEl, ir) {
|
|
|
6146
7526
|
title.textContent = edgeTitle(from, to, { kind, via, cross });
|
|
6147
7527
|
g.insertBefore(title, g.firstChild);
|
|
6148
7528
|
}
|
|
6149
|
-
|
|
7529
|
+
// behold#744: raised under the terragucci reads' layer, whose lines and pills stay over every edge.
|
|
7530
|
+
const raise = (g) => g.parentNode && g.parentNode.insertBefore(g, g.parentNode.querySelector(":scope > [data-tg-reads]"));
|
|
6150
7531
|
// Delegated: raise whichever edge the pointer is over (its hit-path catches it).
|
|
6151
7532
|
svgEl.addEventListener("mouseover", (e) => {
|
|
6152
7533
|
const g = e.target.closest && e.target.closest("g[data-edge-from]");
|
|
@@ -6587,10 +7968,16 @@ function drawPipelineMarks(svgEl) {
|
|
|
6587
7968
|
const light = kioskLight();
|
|
6588
7969
|
const pin = view.run || null;
|
|
6589
7970
|
const commit = tgRunsCommit(pin, tgProgress);
|
|
7971
|
+
// behold#631: on a kiosk, a chant repo's forge and tool are named once, with their logos, in the kiosk's title line:
|
|
7972
|
+
// the wave boxes carry no marks of their own there. Inspect keeps them.
|
|
7973
|
+
const chantKiosk = !!(embedOpts.bare && view.components && chantFacets && !terragucciComponentsRepo);
|
|
7974
|
+
if (chantKiosk) return;
|
|
7975
|
+
const onlyWave = null;
|
|
6590
7976
|
for (const rect of svgEl.querySelectorAll("rect[data-group-id]")) {
|
|
6591
7977
|
const key = rect.getAttribute("data-group-id");
|
|
6592
7978
|
const n = tgWaveOfKey(key);
|
|
6593
7979
|
if (n === null) continue;
|
|
7980
|
+
if (onlyWave !== null && n !== onlyWave) continue;
|
|
6594
7981
|
const what = pipelineMarksFor(n);
|
|
6595
7982
|
if (!what) continue;
|
|
6596
7983
|
const forge = what.forge && FORGES[what.forge] ? what.forge : null;
|
|
@@ -6799,6 +8186,8 @@ function render(ir, svg, m) {
|
|
|
6799
8186
|
markTerragucciCards(); // #490: and what terragucci's reports found, dated
|
|
6800
8187
|
markYodelCards(); // #526: and SQL Yodeler's drift, dated
|
|
6801
8188
|
if (csAnswer) markChangeSetCards(); // #681: and the change set a gate binds, as a preview
|
|
8189
|
+
if (flAnswer) markFlagCards(); // #683: and the feature flags of each flagged member
|
|
8190
|
+
if (coAnswer) markCollisionCards(); // #684: and the nodes two in-flight work items touch
|
|
6802
8191
|
applyLayout(); // #228: last, so the hand-placed deltas ride on top of every other pass
|
|
6803
8192
|
drawTgReads(); // #568: after the layout, so the reads lines meet the cards where they now sit
|
|
6804
8193
|
renderDial();
|
|
@@ -7894,6 +9283,12 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
|
|
|
7894
9283
|
// cross-substrate entity overlay, which components never use.
|
|
7895
9284
|
q.set("components", "1");
|
|
7896
9285
|
if (view.env) q.set("env", view.env);
|
|
9286
|
+
// behold#741: a chapter-carrying scenario's fan-out wave as one block per parent, as chant's loop lays it out.
|
|
9287
|
+
if (tgStoryOn()) q.set("blocks", "1");
|
|
9288
|
+
// The kiosk's frame of a choudoufu estate (the held small stage): its waves in a row, wave 1 on the left, so
|
|
9289
|
+
// the graph's shape is the stage's and the held framing can zoom in as far as the width allows. A story's
|
|
9290
|
+
// fan-out (fan-out-choudoufu) keeps its blocks.
|
|
9291
|
+
else if (embedOpts.bare && projectInfo && projectInfo.terragucciChoudoufu) q.set("waves", "row");
|
|
7897
9292
|
} else if (view.stacks) {
|
|
7898
9293
|
// The apply-order lens (#426): chant's cross-stack ordering, built fresh
|
|
7899
9294
|
// for the same reason the ops lens is — it reads none of the entity
|