@intentius/behold 0.29.29 → 0.29.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +8 -3
- package/package.json +1 -1
- package/web/app.js +261 -4
- package/web/index.html +42 -2
- package/web/kiosk-approval.js +1 -1
- package/web/kiosk-metrics.js +36 -7
- package/web/kiosk-metrics.test.js +52 -3
- package/web/kiosk-runs.js +12 -6
- package/web/kiosk-runs.test.js +11 -1
- package/web/kiosk-shot.js +103 -0
- package/web/kiosk-shot.test.js +79 -0
- package/web/kiosk-trace.js +29 -5
- package/web/kiosk-trace.test.js +29 -1
- package/web/kiosk-vendor.test.js +5 -3
- package/web/kiosk-watch.js +263 -0
- package/web/kiosk-watch.test.js +181 -0
- package/web/kiosk.html +227 -50
- package/web/kiosk.js +565 -71
- package/web/kiosk.test.js +31 -20
- package/web/operator.js +3 -0
- package/web/run-playhead.js +4 -0
- package/web/theme.js +49 -0
- package/web/theme.test.js +56 -1
package/web/kiosk.js
CHANGED
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
// Nothing here is all-or-nothing, and nothing says so.
|
|
15
15
|
|
|
16
16
|
import { CHANT_PANEL_STEPS, chantApprovalModel } from "./chant-pr-marks.js";
|
|
17
|
-
import { PICK_HOLD_MS, annMark, mergeRun, startRuns } from "./kiosk-runs.js";
|
|
17
|
+
import { PICK_HOLD_MS, annMark, mergeRun, startRuns, statusIcon } from "./kiosk-runs.js";
|
|
18
|
+
import { MODES, MODE_STORE, badges as waveBadges, badgeTitle, captionModel, doraLine, modeStored, placeBeside, resultModel, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
19
|
+
import { shotMessage } from "./kiosk-shot.js";
|
|
20
|
+
import { mountTrace } from "./kiosk-trace.js";
|
|
18
21
|
import { PANEL_STEPS, PANEL_TITLE, approvalModel, cycleRuns, digestHex, rowFacts } from "./kiosk-approval.js";
|
|
19
22
|
import { getThemeName, mountThemePicker, onThemeChange } from "./theme.js";
|
|
20
23
|
import { cssString, hoverCss, hoverFromMessage, hoverLinks, hoverMessage, isLightBg, rootSegments, rootText } from "./kiosk-roots.js";
|
|
@@ -633,6 +636,8 @@ export function holdModel(s, demo) {
|
|
|
633
636
|
|
|
634
637
|
function drawBar(bar, s, now) {
|
|
635
638
|
const vendor = vendorOf(s.vendor);
|
|
639
|
+
// behold#571: in Watch the header is one quiet line; the narration is the caption over the graph.
|
|
640
|
+
if (s.watchMode && s.demo && s.demo.demo && !(vendor && s.mode === "none")) return drawWatchHead(bar, s, now);
|
|
636
641
|
if (vendor && s.mode === "none") {
|
|
637
642
|
// behold#571: the tool's scenario has no cycle yet: its name, its link, and a calm line.
|
|
638
643
|
const words = notRunWords(vendor, { graph: !!s.notRunGraph });
|
|
@@ -663,78 +668,60 @@ function drawBar(bar, s, now) {
|
|
|
663
668
|
if (vendor && s.noReports && (s.mode === "live" || s.mode === "replay")) bar.appendChild(el("p", "k-nograph-note", NO_GRAPH_WORDS));
|
|
664
669
|
const intro = introText(demo);
|
|
665
670
|
|
|
666
|
-
// behold#571: the lead block,
|
|
671
|
+
// behold#571: the lead block, a grid of labelled rows: the title (its tool, kicker and the
|
|
672
|
+
// scenario's progress on a quiet line over it), then each beat on a row of its own, its label
|
|
673
|
+
// in a fixed column and its words in the next, each row a fixed box with a rail down its left.
|
|
667
674
|
const left = el("div", "k-left k-lead");
|
|
668
675
|
const titleBox = box("title", "k-box-title");
|
|
669
|
-
const
|
|
676
|
+
const over = el("div", "k-overline");
|
|
670
677
|
// behold#571: /kiosk names the tool each scenario runs on, as its own page does.
|
|
671
678
|
const shownTool = vendor || (demo.scenario !== "base" ? vendorOf(demo.tool) : null);
|
|
672
|
-
if (shownTool)
|
|
673
|
-
|
|
679
|
+
if (shownTool) over.appendChild(brandEl(shownTool));
|
|
680
|
+
over.appendChild(el("span", "k-kicker", head.kicker));
|
|
681
|
+
// The scenario's progress: the strip's stops, at the end of the line over the title.
|
|
682
|
+
const strip = el("ol", "k-strip");
|
|
683
|
+
for (const stop of stripStops(demo.step)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
684
|
+
over.appendChild(strip);
|
|
685
|
+
const title = el("h1", "k-title");
|
|
686
|
+
title.appendChild(el("span", "k-title-text", head.title));
|
|
674
687
|
if (title.setAttribute) title.setAttribute("title", `${head.kicker} · ${head.title || ""}`);
|
|
675
|
-
titleBox.
|
|
688
|
+
titleBox.append(over, title);
|
|
676
689
|
left.appendChild(titleBox);
|
|
677
690
|
|
|
678
691
|
// The first beat: what changes; between scenarios, what the demo is about.
|
|
679
692
|
const rows = aboutRows(demo);
|
|
680
693
|
const changes = rows.find((r) => r.label === BEAT_CHANGES);
|
|
681
|
-
|
|
682
|
-
if (
|
|
683
|
-
|
|
684
|
-
p.append(el("span", "k-intro-head", INTRO_HEAD), intro);
|
|
685
|
-
beatBox.appendChild(p);
|
|
686
|
-
} else if (changes) {
|
|
687
|
-
const p = el("p", "k-beat");
|
|
688
|
-
p.append(el("span", "k-beat-label", changes.label), elRoots("span", "k-beat-text", changes.text, s));
|
|
689
|
-
beatBox.appendChild(p);
|
|
690
|
-
}
|
|
691
|
-
left.appendChild(beatBox);
|
|
694
|
+
if (demo.step === "reset" && intro) left.appendChild(leadRow("changes", "k-row-beat", INTRO_HEAD, el("p", "k-intro", intro)));
|
|
695
|
+
else if (changes) left.appendChild(leadRow("changes", "k-row-beat", changes.label, elRoots("p", "k-beat", changes.text, s)));
|
|
696
|
+
else left.appendChild(leadRow("changes", "k-row-beat"));
|
|
692
697
|
|
|
693
|
-
// The second beat: the step, what just happened and why it stands where it does.
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
stepBox.appendChild(said);
|
|
698
|
-
left.appendChild(stepBox);
|
|
698
|
+
// The second beat: the step, what just happened and why it stands where it does. Its rail takes the step's state.
|
|
699
|
+
const stepRow = leadRow("step", `k-row-step k-step-${demo.step}`, STEP_WORDS[demo.step] || demo.step, elRoots("p", "k-step", demo.label, s));
|
|
700
|
+
if (stepRow.dataset) stepRow.dataset.kTone = stepTone(demo.step);
|
|
701
|
+
left.appendChild(stepRow);
|
|
699
702
|
|
|
700
|
-
//
|
|
701
|
-
const progress = el("div", "k-progress");
|
|
702
|
-
const strip = el("ol", "k-strip");
|
|
703
|
-
for (const stop of stripStops(demo.step)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
704
|
-
progress.appendChild(strip);
|
|
703
|
+
// Next: the driver's action, with its countdown.
|
|
705
704
|
const nx = nextWords(demo, now);
|
|
706
|
-
const next = el("
|
|
707
|
-
next.
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
//
|
|
711
|
-
if (next.setAttribute) next.setAttribute("title", `next, by the driver: ${nx.action}`);
|
|
712
|
-
progress.appendChild(next);
|
|
713
|
-
left.appendChild(progress);
|
|
714
|
-
|
|
715
|
-
// The rest of the card, quieter: watch for, and what the scenario shows.
|
|
716
|
-
const moreBox = box("card", "k-box-more");
|
|
705
|
+
const next = el("p", "k-next");
|
|
706
|
+
next.append(elRoots("span", "k-action", nx.action, s), " ", el("span", "k-when", nx.when), " ", el("span", "k-next-by", "by the driver"));
|
|
707
|
+
left.appendChild(leadRow("next", "k-row-next", "Next", next));
|
|
708
|
+
|
|
709
|
+
// The rest of the card, quieter: each field on its own row (watch for, then what the scenario shows).
|
|
717
710
|
const more = demo.step === "reset" && intro ? [] : rows.filter((r) => r !== changes);
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
for (const r of more) card.append(el("span", "k-about-label", r.label), elRoots("span", "k-about-text", r.text, s), " ");
|
|
722
|
-
moreBox.appendChild(card);
|
|
711
|
+
for (const [i, name] of ["watch", "shows"].entries()) {
|
|
712
|
+
const r = more[i];
|
|
713
|
+
left.appendChild(r ? leadRow(name, "k-row-more", r.label, elRoots("p", "k-about", r.text, s)) : leadRow(name, "k-row-more"));
|
|
723
714
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
factsBox.appendChild(p);
|
|
733
|
-
}
|
|
734
|
-
left.appendChild(factsBox);
|
|
715
|
+
|
|
716
|
+
// The pull request's facts, each a chip that wraps whole; never cut off. behold#571: no line on where the narration was read from.
|
|
717
|
+
const factParts = s.noReports ? [] : factLines(demo, s.answer, nounTool(s));
|
|
718
|
+
if (factParts.length) {
|
|
719
|
+
const p = el("p", "k-facts");
|
|
720
|
+
for (const part of factParts) p.appendChild(elRoots("span", "k-fact", part, s));
|
|
721
|
+
left.appendChild(leadRow("facts", "k-row-facts", FACTS_LABEL, p));
|
|
722
|
+
} else left.appendChild(leadRow("facts", "k-row-facts"));
|
|
735
723
|
// behold#571: a tool's page ends its lead block with who makes the tool, and that they don't endorse the demo.
|
|
736
724
|
if (vendor) drawCredit(left, s.vendor);
|
|
737
|
-
for (const b of [beatBox, moreBox, factsBox]) if (!b.children.length) b.className += " k-box-empty";
|
|
738
725
|
bar.appendChild(left);
|
|
739
726
|
|
|
740
727
|
// behold#571: the hold panel, headed with its wave and run, lit as its job row and its wave box are.
|
|
@@ -766,6 +753,168 @@ function drawBar(bar, s, now) {
|
|
|
766
753
|
bar.appendChild(right);
|
|
767
754
|
}
|
|
768
755
|
|
|
756
|
+
/** behold#571: the label of the lead block's row of the pull request's facts. */
|
|
757
|
+
export const FACTS_LABEL = "The change";
|
|
758
|
+
|
|
759
|
+
/** behold#571: the tone the step row's rail takes from the step: Watch's caption's (kiosk-watch.js), so both layouts light it alike. */
|
|
760
|
+
export { stepTone };
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* behold#571: a row of the lead block: its label in the fixed column, its
|
|
764
|
+
* words in a fixed box beside it (they scroll inside it, the page never
|
|
765
|
+
* moves). With no words, the row keeps its place and draws nothing.
|
|
766
|
+
*/
|
|
767
|
+
function leadRow(name, cls, label = null, content = null) {
|
|
768
|
+
const row = el("div", `k-row ${cls}${content ? "" : " k-row-empty"}`);
|
|
769
|
+
if (content) {
|
|
770
|
+
row.appendChild(el("span", "k-row-label", label));
|
|
771
|
+
const b = box(name, "k-row-box");
|
|
772
|
+
b.appendChild(content);
|
|
773
|
+
row.appendChild(b);
|
|
774
|
+
}
|
|
775
|
+
return row;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// ---------------------------------------------------------------------------
|
|
779
|
+
// behold#571: Watch, the kiosk's default. web/kiosk-watch.js decides what each
|
|
780
|
+
// piece says and where it goes; these draw it.
|
|
781
|
+
|
|
782
|
+
/** The mode toggle, "Watch | Inspect", in the header's tools. */
|
|
783
|
+
export function renderModeToggle(host, mode, onPick) {
|
|
784
|
+
if (!host) return;
|
|
785
|
+
host.replaceChildren();
|
|
786
|
+
for (const m of MODES) {
|
|
787
|
+
const b = el("button", `k-mode${m.id === mode ? " k-mode-on" : ""}`, m.words);
|
|
788
|
+
b.type = "button";
|
|
789
|
+
b.setAttribute("title", m.shows);
|
|
790
|
+
b.setAttribute("aria-pressed", String(m.id === mode));
|
|
791
|
+
b.addEventListener("click", () => onPick(m.id));
|
|
792
|
+
host.appendChild(b);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/** behold#571: the words over a held shot, and the button that follows the step again. */
|
|
797
|
+
export function heldWords(secs) {
|
|
798
|
+
return `Held where you left it · the steps lead again in ${secs} s`;
|
|
799
|
+
}
|
|
800
|
+
export const FOLLOW_WORDS = "Follow the steps";
|
|
801
|
+
|
|
802
|
+
/** Watch's header: the scenario's place and the strip on the left, the delivery numbers on the right. */
|
|
803
|
+
function drawWatchHead(bar, s, now) {
|
|
804
|
+
const demo = s.demo.demo;
|
|
805
|
+
const vendor = vendorOf(s.vendor);
|
|
806
|
+
const place = el("div", "k-w-place");
|
|
807
|
+
const shownTool = vendor || (demo.scenario !== "base" ? vendorOf(demo.tool) : null);
|
|
808
|
+
if (shownTool) place.appendChild(brandEl(shownTool));
|
|
809
|
+
place.appendChild(el("span", "k-cycle", cycleWords(demo, now)));
|
|
810
|
+
bar.appendChild(place);
|
|
811
|
+
const strip = el("ol", "k-strip");
|
|
812
|
+
for (const stop of stripStops(demo.step)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
813
|
+
bar.appendChild(strip);
|
|
814
|
+
if (s.watchHeld) {
|
|
815
|
+
const p = el("span", "k-w-held", heldWords(s.watchHeld.secs));
|
|
816
|
+
const b = el("button", null, FOLLOW_WORDS);
|
|
817
|
+
b.type = "button";
|
|
818
|
+
b.addEventListener("click", () => s.followSteps && s.followSteps());
|
|
819
|
+
p.appendChild(b);
|
|
820
|
+
bar.appendChild(p);
|
|
821
|
+
}
|
|
822
|
+
const dora = doraLine(s.metrics);
|
|
823
|
+
if (dora) {
|
|
824
|
+
const p = el("p", "k-w-dora", dora);
|
|
825
|
+
if (p.setAttribute) p.setAttribute("title", s.metrics && s.metrics.note ? `${dora}. ${s.metrics.note}` : dora);
|
|
826
|
+
bar.appendChild(p);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/** The caption along the bottom: the title, what changes, the step; one of the two beats leads. */
|
|
831
|
+
function drawCaption(host, s, now) {
|
|
832
|
+
host.replaceChildren();
|
|
833
|
+
const demo = s.demo && s.demo.demo;
|
|
834
|
+
const cap = captionModel(demo, { vendor: s.vendor || null, now });
|
|
835
|
+
if (!cap) return;
|
|
836
|
+
const top = el("div", "k-cap-top");
|
|
837
|
+
const title = el("h1", "k-cap-title");
|
|
838
|
+
title.append(el("span", "k-kicker", cap.kicker), el("span", "k-title-text", cap.title));
|
|
839
|
+
if (title.setAttribute) title.setAttribute("title", `${cap.kicker} · ${cap.title}`);
|
|
840
|
+
top.appendChild(title);
|
|
841
|
+
if (cap.next) {
|
|
842
|
+
const nx = el("p", "k-cap-next");
|
|
843
|
+
nx.append("next, by the driver: ", elRoots("span", "k-action", cap.next.action, s), " ", el("span", "k-when", cap.next.when));
|
|
844
|
+
if (nx.setAttribute) nx.setAttribute("title", `next, by the driver: ${cap.next.action}`);
|
|
845
|
+
top.appendChild(nx);
|
|
846
|
+
}
|
|
847
|
+
host.appendChild(top);
|
|
848
|
+
const beat = cap.intro || cap.changes;
|
|
849
|
+
const changes = el("p", `k-cap-row k-cap-changes${cap.lead === "changes" ? " k-cap-lead" : ""}`);
|
|
850
|
+
if (beat) {
|
|
851
|
+
changes.append(el("span", "k-cap-label", beat.label), elRoots("span", "k-cap-text", beat.text, s));
|
|
852
|
+
if (changes.setAttribute) changes.setAttribute("title", beat.text);
|
|
853
|
+
}
|
|
854
|
+
host.appendChild(changes);
|
|
855
|
+
const step = el("p", `k-cap-row k-cap-step k-tone-${cap.step.tone}${cap.lead === "step" ? " k-cap-lead" : ""}`);
|
|
856
|
+
step.append(el("span", "k-cap-label", cap.step.word), elRoots("span", "k-cap-text", cap.step.text, s));
|
|
857
|
+
if (step.setAttribute) step.setAttribute("title", cap.step.text);
|
|
858
|
+
host.appendChild(step);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/** The approval on the held wave's box: the step's word, the wave, its numbers, and how the hold ends. */
|
|
862
|
+
function drawCallout(host, s, hold, nums) {
|
|
863
|
+
const keep = host.scrollTop;
|
|
864
|
+
host.replaceChildren();
|
|
865
|
+
host.appendChild(el("span", "k-notch"));
|
|
866
|
+
host.appendChild(el("p", "k-call-word", STEP_WORDS.waiting));
|
|
867
|
+
if (hold.head) host.appendChild(el("p", "k-call-head", hold.head));
|
|
868
|
+
if (nums) host.appendChild(el("p", "k-call-nums", nums));
|
|
869
|
+
if (hold.kind === "approval") host.appendChild(approvalPanel(hold.model, s));
|
|
870
|
+
else {
|
|
871
|
+
const appr = hold.appr;
|
|
872
|
+
const a = el("div", "k-approve");
|
|
873
|
+
a.appendChild(elRoots("p", "k-approve-gloss", approveGloss(appr), s));
|
|
874
|
+
a.appendChild(el("code", "k-command", appr.approve));
|
|
875
|
+
const then = el("p", "k-approve-then");
|
|
876
|
+
then.append(`then comments `, el("code", "k-inline", appr.comment), ` on ${appr.on}, and the waves run again.`);
|
|
877
|
+
a.appendChild(then);
|
|
878
|
+
host.appendChild(a);
|
|
879
|
+
}
|
|
880
|
+
host.scrollTop = keep;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/** The drawer's head and folded lines: the job the run is on, its numbers, and the last lines its step wrote. */
|
|
884
|
+
function drawDrawer(host, tail, nums, open) {
|
|
885
|
+
const head = host.querySelector(".k-drawer-head");
|
|
886
|
+
const lines = host.querySelector(".k-drawer-tail");
|
|
887
|
+
head.replaceChildren();
|
|
888
|
+
if (!host.querySelector(".k-notch")) host.insertBefore(el("span", "k-notch"), head);
|
|
889
|
+
head.setAttribute("aria-expanded", String(open));
|
|
890
|
+
if (tail) head.append(statusIcon(tail.status), el("span", "k-drawer-job", tail.job));
|
|
891
|
+
if (nums) head.appendChild(el("span", "k-drawer-nums", nums));
|
|
892
|
+
head.appendChild(el("span", "k-drawer-more", open ? DRAWER_LESS : DRAWER_MORE));
|
|
893
|
+
lines.replaceChildren();
|
|
894
|
+
for (const l of tail ? tail.lines : []) lines.appendChild(el("div", "k-drawer-line", l));
|
|
895
|
+
if (!lines.children.length) lines.appendChild(el("div", "k-drawer-line k-drawer-quiet", DRAWER_EMPTY));
|
|
896
|
+
}
|
|
897
|
+
/** behold#571: the folded drawer before the job writes a line. */
|
|
898
|
+
export const DRAWER_EMPTY = "The job's lines show here as it writes them.";
|
|
899
|
+
/** behold#571: the drawer's two states, said on its head. */
|
|
900
|
+
export const DRAWER_MORE = "Open the log";
|
|
901
|
+
export const DRAWER_LESS = "Fold it back";
|
|
902
|
+
|
|
903
|
+
/** The result card at the end of the run: the result line, the counts, and each wave's numbers. */
|
|
904
|
+
function drawResult(host, model, s) {
|
|
905
|
+
host.replaceChildren();
|
|
906
|
+
host.appendChild(el("p", "k-result-head", model.head));
|
|
907
|
+
if (model.line) host.appendChild(elRoots("p", "k-result-line", model.line, s));
|
|
908
|
+
const counts = el("ul", "k-result-counts");
|
|
909
|
+
for (const c of model.counts) counts.appendChild(el("li", null, c));
|
|
910
|
+
host.appendChild(counts);
|
|
911
|
+
if (model.waves.length) {
|
|
912
|
+
const list = el("dl", "k-result-waves");
|
|
913
|
+
for (const w of model.waves) list.append(el("dt", null, `Wave ${w.wave}`), el("dd", null, w.words));
|
|
914
|
+
host.appendChild(list);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
769
918
|
/** behold#571: the head over the intro, in the card's box between scenarios, and the title of "What is this?". */
|
|
770
919
|
export const INTRO_HEAD = "What this demo is about";
|
|
771
920
|
|
|
@@ -853,11 +1002,11 @@ function drawCredit(host, tool) {
|
|
|
853
1002
|
host.appendChild(wrap);
|
|
854
1003
|
}
|
|
855
1004
|
|
|
856
|
-
/** behold#571: how a hovered root's name and wave's job row light
|
|
1005
|
+
/** behold#571: how a hovered root's name and wave's job row light: a background and, on the row, its left bar twice as wide. Nothing moves. */
|
|
857
1006
|
export const HOVER_ROOT_RULE = "background: color-mix(in srgb, var(--focus) 32%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 32%, transparent); border-radius: 3px;";
|
|
858
|
-
export const HOVER_JOB_RULE = "background: color-mix(in srgb, var(--focus) 24%, transparent);
|
|
1007
|
+
export const HOVER_JOB_RULE = "background: color-mix(in srgb, var(--focus) 24%, transparent); --bar-w: 6px;";
|
|
859
1008
|
/** behold#571: how the held wave's job row lights while the hold panel shows it: the waiting tone its wave box and the panel carry. */
|
|
860
|
-
export const HELD_JOB_RULE = "background: color-mix(in srgb, var(--foreign) 14%, transparent);
|
|
1009
|
+
export const HELD_JOB_RULE = "background: color-mix(in srgb, var(--foreign) 14%, transparent); --bar: var(--bar-foreign); --bar-w: 6px;";
|
|
861
1010
|
|
|
862
1011
|
/** behold#571: how often the approval panel reads the cycle's runs, and the gate ledger (which the server caches 30 s). */
|
|
863
1012
|
export const APPROVAL_POLL_MS = 4_000;
|
|
@@ -876,6 +1025,11 @@ function fade(b) {
|
|
|
876
1025
|
b.classList.toggle("k-more-above", b.scrollTop > 1);
|
|
877
1026
|
}
|
|
878
1027
|
|
|
1028
|
+
/** behold#571: the longest a reloaded frame loads out of sight before it swaps in anyway. */
|
|
1029
|
+
export const FRAME_SWAP_MS = 30_000;
|
|
1030
|
+
/** behold#571: how long the first frame load waits for demo.json, so it opens on the step's checkout. */
|
|
1031
|
+
export const FRAME_BOOT_WAIT_MS = 4_000;
|
|
1032
|
+
|
|
879
1033
|
/** How often the kiosk asks for demo.json. The server shares one read between kiosks. */
|
|
880
1034
|
export const DEMO_POLL_MS = 3_000;
|
|
881
1035
|
|
|
@@ -886,8 +1040,26 @@ export const DEMO_POLL_MS = 3_000;
|
|
|
886
1040
|
* countdown. When the roots the step is about change, move the framed view
|
|
887
1041
|
* with a `behold:view` message; the frame takes them only from this origin.
|
|
888
1042
|
*/
|
|
889
|
-
export function startKiosk({ bar, frame, side, main, views, read = null, tools = null }, { fetchJson = defaultFetch, now = () => new Date(), origin = location.origin, tool = null } = {}) {
|
|
1043
|
+
export function startKiosk({ bar, frame, side, main, views, read = null, tools = null, watch = null }, { fetchJson = defaultFetch, now = () => new Date(), origin = location.origin, tool = null } = {}) {
|
|
890
1044
|
const s = { demo: null, answer: null, progress: null, components: false, pick: null, view: "resources", roots: [], waves: [], light: false, hover: null, frameHover: null, held: null };
|
|
1045
|
+
// behold#571: Watch or Inspect, the viewer's pick kept in their browser; Watch until they pick Inspect.
|
|
1046
|
+
const shelf = typeof localStorage !== "undefined" ? (() => { try { return localStorage; } catch { return null; } })() : null;
|
|
1047
|
+
s.metrics = null;
|
|
1048
|
+
s.watchMode = !!watch && modeStored(shelf) === "watch";
|
|
1049
|
+
s.watchHeld = null;
|
|
1050
|
+
s.boxes = null;
|
|
1051
|
+
s.shot = null;
|
|
1052
|
+
// behold#571: the frame loading out of sight while the shown one stays up (openFrame), and a message to both.
|
|
1053
|
+
let buffer = null;
|
|
1054
|
+
const post = (msg) => {
|
|
1055
|
+
for (const f of [frame, buffer]) {
|
|
1056
|
+
try {
|
|
1057
|
+
if (f && f.contentWindow) f.contentWindow.postMessage(msg, origin);
|
|
1058
|
+
} catch {
|
|
1059
|
+
/* the frame went away */
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
891
1063
|
// behold#571: on a tool's page, `live` while its scenario runs, `replay` of its latest cycle otherwise, `none` before it has one.
|
|
892
1064
|
const vendor = vendorOf(tool);
|
|
893
1065
|
s.vendor = vendor ? tool : null;
|
|
@@ -943,7 +1115,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
943
1115
|
const key = `${focus}|${run}|${zoom}`;
|
|
944
1116
|
if (!force && key === lastFocus) return;
|
|
945
1117
|
lastFocus = key;
|
|
946
|
-
|
|
1118
|
+
post({ type: "behold:view", member: null, focus, run, zoom });
|
|
947
1119
|
tellHover(s.hover);
|
|
948
1120
|
};
|
|
949
1121
|
const pickView = (view) => {
|
|
@@ -972,7 +1144,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
972
1144
|
// behold#571: with nothing pointed at, the frame lights the held wave's box, as the hold panel and its job row are lit.
|
|
973
1145
|
const tellHover = (h) => {
|
|
974
1146
|
const lit = h || (Number.isInteger(s.held) ? { wave: s.held } : null);
|
|
975
|
-
|
|
1147
|
+
post(hoverMessage(lit));
|
|
976
1148
|
};
|
|
977
1149
|
const hoverAt = (target) => {
|
|
978
1150
|
const t = target && target.closest ? target.closest("[data-k-root],[data-k-wave]") : null;
|
|
@@ -991,7 +1163,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
991
1163
|
document.addEventListener("pointerover", (e) => setHover(hoverAt(e.target)));
|
|
992
1164
|
document.documentElement.addEventListener("pointerleave", () => setHover(null));
|
|
993
1165
|
// A click or Escape anywhere here is a click elsewhere for the frame's pinned popover.
|
|
994
|
-
const unpin = () =>
|
|
1166
|
+
const unpin = () => post({ type: "behold:unpin" });
|
|
995
1167
|
document.addEventListener("pointerdown", unpin);
|
|
996
1168
|
document.addEventListener("keydown", (e) => {
|
|
997
1169
|
if (e.key === "Escape") unpin();
|
|
@@ -1092,6 +1264,9 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1092
1264
|
tellHover(s.hover);
|
|
1093
1265
|
}
|
|
1094
1266
|
whatText();
|
|
1267
|
+
// behold#571: Watch's overlays, then the shot they leave room for.
|
|
1268
|
+
holdTick();
|
|
1269
|
+
drawWatch(shownNow());
|
|
1095
1270
|
renderViewToggle(views, shown, { components: s.components && ok, onPick: pickView });
|
|
1096
1271
|
drawReading(shown.view, ok);
|
|
1097
1272
|
// behold#571: with no graph to show, the graph pane folds away and the runs and the log take its width.
|
|
@@ -1101,6 +1276,259 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1101
1276
|
document.body.classList.toggle("k-notyet", !!vendor && s.mode === "none");
|
|
1102
1277
|
}
|
|
1103
1278
|
tellFrame(false);
|
|
1279
|
+
tellShot(false);
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
// ---------------------------------------------------------------------------
|
|
1283
|
+
// behold#571: Watch. The graph is the stage; the caption, the callout, the
|
|
1284
|
+
// drawer, the badges and the result card ride on it, and the shot moves
|
|
1285
|
+
// with the step. A viewer's click or pan holds the shot for PICK_HOLD_MS.
|
|
1286
|
+
let watchHoldAt = null;
|
|
1287
|
+
let lastShot = null;
|
|
1288
|
+
let drawerOpen = false;
|
|
1289
|
+
let drawerHover = false;
|
|
1290
|
+
const isPhone = () => typeof matchMedia === "function" && matchMedia("(max-width: 600px)").matches;
|
|
1291
|
+
const runsParent = main ? main.parentNode : null;
|
|
1292
|
+
const runsNext = main ? main.nextSibling : null;
|
|
1293
|
+
const applyMode = () => {
|
|
1294
|
+
if (typeof document === "undefined" || !document.body || !document.body.classList) return;
|
|
1295
|
+
document.body.classList.toggle("k-watch", s.watchMode);
|
|
1296
|
+
if (watch && watch.drawer && main) {
|
|
1297
|
+
const body = watch.drawer.querySelector(".k-drawer-body");
|
|
1298
|
+
// The runs pane is the drawer's open state in Watch, and back in its column in Inspect.
|
|
1299
|
+
if (s.watchMode && body && main.parentNode !== body) body.appendChild(main);
|
|
1300
|
+
if (!s.watchMode && runsParent && main.parentNode !== runsParent) runsParent.insertBefore(main, runsNext);
|
|
1301
|
+
}
|
|
1302
|
+
if (watch) renderModeToggle(tools && tools.mode, s.watchMode ? "watch" : "inspect", setMode);
|
|
1303
|
+
};
|
|
1304
|
+
const setMode = (m) => {
|
|
1305
|
+
const next = m === "watch";
|
|
1306
|
+
if (next === s.watchMode) return;
|
|
1307
|
+
s.watchMode = next;
|
|
1308
|
+
try {
|
|
1309
|
+
if (shelf) shelf.setItem(MODE_STORE, m);
|
|
1310
|
+
} catch {
|
|
1311
|
+
/* private mode: the pick lasts this visit */
|
|
1312
|
+
}
|
|
1313
|
+
if (next) s.pick = null; // Watch frames the components: a Resources pick from Inspect ends here
|
|
1314
|
+
watchHoldAt = null;
|
|
1315
|
+
s.watchHeld = null;
|
|
1316
|
+
lastShot = null;
|
|
1317
|
+
applyMode();
|
|
1318
|
+
draw();
|
|
1319
|
+
// The layout moved under the frame: the shot goes again once it has settled.
|
|
1320
|
+
if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => tellShot(true));
|
|
1321
|
+
};
|
|
1322
|
+
const holdShot = () => {
|
|
1323
|
+
if (!s.watchMode) return;
|
|
1324
|
+
watchHoldAt = now().getTime();
|
|
1325
|
+
draw();
|
|
1326
|
+
};
|
|
1327
|
+
s.followSteps = () => {
|
|
1328
|
+
watchHoldAt = null;
|
|
1329
|
+
s.watchHeld = null;
|
|
1330
|
+
lastShot = null;
|
|
1331
|
+
draw();
|
|
1332
|
+
};
|
|
1333
|
+
function holdTick() {
|
|
1334
|
+
if (watchHoldAt === null) return void (s.watchHeld = null);
|
|
1335
|
+
const left = watchHoldAt + PICK_HOLD_MS - now().getTime();
|
|
1336
|
+
if (left <= 0) {
|
|
1337
|
+
watchHoldAt = null;
|
|
1338
|
+
s.watchHeld = null;
|
|
1339
|
+
lastShot = null;
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
s.watchHeld = { secs: Math.ceil(left / 1000) };
|
|
1343
|
+
}
|
|
1344
|
+
/** How much of the frame the overlays cover, in the frame's pixels: the caption below, and the callout, drawer or card beside the shot. */
|
|
1345
|
+
const shotInsets = (shot) => {
|
|
1346
|
+
if (!watch || !frame || isPhone() || !frame.getBoundingClientRect) return {};
|
|
1347
|
+
const f = frame.getBoundingClientRect();
|
|
1348
|
+
const cap = watch.caption.getBoundingClientRect();
|
|
1349
|
+
const bottom = Math.max(0, f.bottom - cap.top) + 16;
|
|
1350
|
+
const side = shot.kind === "held" ? watch.callout : shot.kind === "active" ? watch.drawer : shot.kind === "result" ? watch.result : null;
|
|
1351
|
+
// The result card sits right beside the graph (placeBeside's gap): an inset of its width and that gap centres the two together.
|
|
1352
|
+
const right = side && !side.hidden && side.offsetWidth ? side.offsetWidth + (shot.kind === "result" ? 18 : 44) : 0;
|
|
1353
|
+
return { top: 20, right, bottom, left: 20 };
|
|
1354
|
+
};
|
|
1355
|
+
function tellShot(force) {
|
|
1356
|
+
if (!frame || !frame.contentWindow || !watch) return;
|
|
1357
|
+
if (!s.watchMode) {
|
|
1358
|
+
if (lastShot !== "release") {
|
|
1359
|
+
lastShot = "release";
|
|
1360
|
+
post({ type: "behold:shot", release: true });
|
|
1361
|
+
}
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
if (s.watchHeld || !s.shot) return;
|
|
1365
|
+
const insets = shotInsets(s.shot);
|
|
1366
|
+
const key = `${s.shot.id}|${insets.right || 0}|${Math.round((insets.bottom || 0) / 12)}|${s.shot.roots.join(",")}`;
|
|
1367
|
+
if (!force && key === lastShot) return;
|
|
1368
|
+
lastShot = key;
|
|
1369
|
+
post(shotMessage({ roots: s.shot.roots, waves: s.shot.waves, whole: s.shot.whole, insets, id: s.shot.id }));
|
|
1370
|
+
}
|
|
1371
|
+
function drawWatch(at) {
|
|
1372
|
+
if (!watch || !s.watchMode) return;
|
|
1373
|
+
const d = s.demo && s.demo.demo;
|
|
1374
|
+
drawCaption(watch.caption, s, at);
|
|
1375
|
+
const hold = d ? holdModel(s, d) : null;
|
|
1376
|
+
const gate = !!hold && (hold.kind === "approval" || hold.kind === "driver");
|
|
1377
|
+
const shot = shotFor(d, { answer: s.answer, progress: s.progress, held: s.held, gate, runDoc: runsApi && runsApi.run ? runsApi.run.doc : null, waves: s.waves });
|
|
1378
|
+
s.shot = shot;
|
|
1379
|
+
const nums = waveBadges(s.metrics);
|
|
1380
|
+
const call = shot.kind === "held" && gate;
|
|
1381
|
+
watch.callout.hidden = !call;
|
|
1382
|
+
if (call) drawCallout(watch.callout, s, hold, badgeTitle(nums[hold.wave]));
|
|
1383
|
+
const drawer = shot.kind === "active";
|
|
1384
|
+
const open = drawer && (drawerOpen || drawerHover);
|
|
1385
|
+
watch.drawer.hidden = !drawer;
|
|
1386
|
+
watch.drawer.classList.toggle("k-open", open);
|
|
1387
|
+
if (drawer) drawDrawer(watch.drawer, tailLines(runsApi && runsApi.run ? runsApi.run.doc : null), badgeTitle(nums[shot.waves[0]]), open);
|
|
1388
|
+
if (drawer) traceDrawer(d, shot.waves[0]);
|
|
1389
|
+
const result = shot.kind === "result" ? resultModel(d, s.metrics, s.progress) : null;
|
|
1390
|
+
watch.result.hidden = !result;
|
|
1391
|
+
if (result) drawResult(watch.result, result, s);
|
|
1392
|
+
// On a phone the delivery numbers stack under the rest, where the header has no room for them.
|
|
1393
|
+
let foot = watch.layer.querySelector(":scope > .k-w-dora-foot");
|
|
1394
|
+
if (!foot) {
|
|
1395
|
+
foot = el("p", "k-w-dora-foot");
|
|
1396
|
+
watch.layer.appendChild(foot);
|
|
1397
|
+
}
|
|
1398
|
+
foot.textContent = doraLine(s.metrics) || "";
|
|
1399
|
+
watch.badges.replaceChildren();
|
|
1400
|
+
const skip = call ? hold.wave : drawer ? shot.waves[0] : null;
|
|
1401
|
+
// At applied the result card lists every wave's numbers, so the boxes carry none.
|
|
1402
|
+
for (const [n, words] of shot.kind === "result" && result ? [] : Object.entries(nums)) {
|
|
1403
|
+
if (Number(n) === skip) continue;
|
|
1404
|
+
const b = el("span", "k-badge", words);
|
|
1405
|
+
b.dataset.kWave = n;
|
|
1406
|
+
b.title = `Wave ${n}: ${badgeTitle(words)}`;
|
|
1407
|
+
watch.badges.appendChild(b);
|
|
1408
|
+
}
|
|
1409
|
+
placeWatch();
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* behold#571: the active wave's job's trace waterfall (web/kiosk-trace.js),
|
|
1413
|
+
* in the drawer's mount point: the job that applies the wave, in the run
|
|
1414
|
+
* the drawer shows. It draws nothing until Tempo has a trace for that job.
|
|
1415
|
+
*/
|
|
1416
|
+
let trace = null;
|
|
1417
|
+
function traceDrawer(d, wave) {
|
|
1418
|
+
const host = watch.drawer.querySelector("#k-traces");
|
|
1419
|
+
const runDoc = runsApi && runsApi.run ? runsApi.run.doc : null;
|
|
1420
|
+
const w = (s.waves || []).find((x) => x.wave === wave);
|
|
1421
|
+
if (!host || !d || !d.repo || !runDoc || !w) return;
|
|
1422
|
+
const target = { project: d.repo, run: String(runDoc.id), job: w.job };
|
|
1423
|
+
const key = `${target.project}|${target.run}|${target.job}`;
|
|
1424
|
+
if (trace && trace.key === key) return;
|
|
1425
|
+
if (trace) trace.api.update(target);
|
|
1426
|
+
else trace = { api: mountTrace(host, { ...target, fetchJson: fetchServed }) };
|
|
1427
|
+
trace.key = key;
|
|
1428
|
+
}
|
|
1429
|
+
/** Put each overlay by its box, as the frame last said they sit. */
|
|
1430
|
+
function placeWatch() {
|
|
1431
|
+
if (!watch || !s.watchMode || !frame || !frame.getBoundingClientRect) return;
|
|
1432
|
+
const all = [watch.callout, watch.drawer, watch.result, ...watch.badges.children];
|
|
1433
|
+
if (isPhone()) {
|
|
1434
|
+
for (const n of all) n.style.transform = "";
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
const L = watch.layer.getBoundingClientRect();
|
|
1438
|
+
const F = frame.getBoundingClientRect();
|
|
1439
|
+
const capTop = watch.caption.getBoundingClientRect().top - L.top;
|
|
1440
|
+
const view = { x: F.left - L.left, y: F.top - L.top, w: F.width, h: capTop - (F.top - L.top) };
|
|
1441
|
+
const boxOf = (n) => {
|
|
1442
|
+
const waves = (s.boxes && s.boxes.waves) || {};
|
|
1443
|
+
// No wave named: every wave's box, for a gate on the whole change.
|
|
1444
|
+
const list = n === null || n === undefined ? Object.values(waves) : [waves[n]];
|
|
1445
|
+
const ok = list.filter((b) => b && b.w > 0);
|
|
1446
|
+
if (!ok.length) return null;
|
|
1447
|
+
const x = Math.min(...ok.map((b) => b.x));
|
|
1448
|
+
const y = Math.min(...ok.map((b) => b.y));
|
|
1449
|
+
return { x: x + view.x, y: y + view.y, w: Math.max(...ok.map((b) => b.x + b.w)) - x, h: Math.max(...ok.map((b) => b.y + b.h)) - y };
|
|
1450
|
+
};
|
|
1451
|
+
const taken = [];
|
|
1452
|
+
const put = (node, n) => {
|
|
1453
|
+
if (node.hidden) return;
|
|
1454
|
+
const size = { w: node.offsetWidth, h: node.offsetHeight };
|
|
1455
|
+
const box = boxOf(n);
|
|
1456
|
+
// Before the frame says where the box is: the right of the view, under its top.
|
|
1457
|
+
const labels = ((s.boxes && s.boxes.labels) || []).map((r) => ({ x: r.x + view.x, y: r.y + view.y, w: r.w, h: r.h }));
|
|
1458
|
+
const p = box ? placeBeside(box, size, view, 18, labels) : { x: view.x + view.w - size.w - 20, y: view.y + 20, side: "below" };
|
|
1459
|
+
// The result card stands level with the middle of the graph it sums up.
|
|
1460
|
+
if (box && node === watch.result) p.y = Math.max(view.y + 8, Math.min(box.y + box.h / 2 - size.h / 2, view.y + view.h - size.h - 8));
|
|
1461
|
+
node.style.transform = `translate(${Math.round(p.x)}px, ${Math.round(p.y)}px)`;
|
|
1462
|
+
for (const k of ["right", "left", "below"]) node.classList.toggle(`k-side-${k}`, p.side === k);
|
|
1463
|
+
node.classList.add("k-placed");
|
|
1464
|
+
const notch = node.querySelector(":scope > .k-notch");
|
|
1465
|
+
if (notch && box) notch.style.top = `${Math.round(Math.max(12, Math.min(size.h - 26, box.y + 22 - p.y)))}px`;
|
|
1466
|
+
taken.push({ x: p.x, y: p.y, x2: p.x + size.w, y2: p.y + size.h });
|
|
1467
|
+
};
|
|
1468
|
+
put(watch.callout, s.held);
|
|
1469
|
+
put(watch.drawer, s.shot && s.shot.waves[0]);
|
|
1470
|
+
put(watch.result, null); // beside the whole graph
|
|
1471
|
+
const hits = (r) => taken.some((t) => r.x < t.x2 && r.x2 > t.x && r.y < t.y2 && r.y2 > t.y);
|
|
1472
|
+
for (const b of watch.badges.children) {
|
|
1473
|
+
const box = boxOf(Number(b.dataset.kWave));
|
|
1474
|
+
b.classList.remove("k-placed");
|
|
1475
|
+
if (!box) continue;
|
|
1476
|
+
const w = b.offsetWidth;
|
|
1477
|
+
const h = b.offsetHeight;
|
|
1478
|
+
const spots = [
|
|
1479
|
+
{ x: box.x + box.w + 10, y: box.y + 8 },
|
|
1480
|
+
{ x: box.x - 10 - w, y: box.y + 8 },
|
|
1481
|
+
{ x: box.x + box.w - w - 10, y: box.y - h - 6 },
|
|
1482
|
+
];
|
|
1483
|
+
const spot = spots.find((p) => p.x >= view.x + 6 && p.x + w <= view.x + view.w - 6 && p.y >= view.y + 4 && p.y + h <= view.y + view.h - 4 && !hits({ x: p.x, y: p.y, x2: p.x + w, y2: p.y + h }));
|
|
1484
|
+
if (!spot) continue;
|
|
1485
|
+
b.style.transform = `translate(${Math.round(spot.x)}px, ${Math.round(spot.y)}px)`;
|
|
1486
|
+
b.classList.add("k-placed");
|
|
1487
|
+
taken.push({ x: spot.x, y: spot.y, x2: spot.x + w, y2: spot.y + h });
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
if (watch && typeof window !== "undefined" && window.addEventListener) {
|
|
1491
|
+
let queued = false;
|
|
1492
|
+
window.addEventListener("message", (e) => {
|
|
1493
|
+
if (e.origin !== origin || !frame || e.source !== frame.contentWindow || !e.data) return;
|
|
1494
|
+
if (e.data.type === "behold:viewer") return holdShot();
|
|
1495
|
+
if (e.data.type !== "behold:boxes") return;
|
|
1496
|
+
s.boxes = e.data;
|
|
1497
|
+
if (queued) return;
|
|
1498
|
+
queued = true;
|
|
1499
|
+
requestAnimationFrame(() => {
|
|
1500
|
+
queued = false;
|
|
1501
|
+
placeWatch();
|
|
1502
|
+
});
|
|
1503
|
+
});
|
|
1504
|
+
window.addEventListener("resize", () => {
|
|
1505
|
+
placeWatch();
|
|
1506
|
+
tellShot(true);
|
|
1507
|
+
});
|
|
1508
|
+
// A click on the approval or the log is a viewer reading it: the shot holds.
|
|
1509
|
+
if (watch.callout) watch.callout.addEventListener("pointerdown", holdShot);
|
|
1510
|
+
const head = watch.drawer && watch.drawer.querySelector(".k-drawer-head");
|
|
1511
|
+
if (head) {
|
|
1512
|
+
head.addEventListener("click", () => {
|
|
1513
|
+
drawerOpen = !drawerOpen;
|
|
1514
|
+
holdShot();
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
if (watch.drawer) {
|
|
1518
|
+
watch.drawer.addEventListener("pointerenter", (e) => {
|
|
1519
|
+
if (e.pointerType === "touch") return;
|
|
1520
|
+
drawerHover = true;
|
|
1521
|
+
draw();
|
|
1522
|
+
});
|
|
1523
|
+
watch.drawer.addEventListener("pointerleave", () => {
|
|
1524
|
+
drawerHover = false;
|
|
1525
|
+
draw();
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
s.setMetrics = (m) => {
|
|
1530
|
+
s.metrics = m;
|
|
1531
|
+
draw();
|
|
1104
1532
|
};
|
|
1105
1533
|
|
|
1106
1534
|
// behold#571: on a tool's page the runs pane shows the tool's repo alone; in the replay, the cycle's runs as they stood.
|
|
@@ -1226,7 +1654,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1226
1654
|
// behold#571: the theme picker, persisted per viewer as the app does; the frame follows without a reload.
|
|
1227
1655
|
if (tools && tools.theme) mountThemePicker(tools.theme);
|
|
1228
1656
|
onThemeChange((th) => {
|
|
1229
|
-
|
|
1657
|
+
post({ type: "behold:theme", name: th.name });
|
|
1230
1658
|
draw();
|
|
1231
1659
|
});
|
|
1232
1660
|
|
|
@@ -1254,19 +1682,84 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1254
1682
|
}
|
|
1255
1683
|
// #571: whether the repo offers the components zoom (a terragucci.components.json), read before the frame opens so it opens on the step's view.
|
|
1256
1684
|
let frameSrcNow = null;
|
|
1685
|
+
// behold#571: a frame that has drawn its graph stays up while the next one
|
|
1686
|
+
// loads out of sight; the next one swaps in once it says it has drawn
|
|
1687
|
+
// (`behold:drawn`), so the graph pane is never an empty frame: not at the
|
|
1688
|
+
// merge, not at applied, not at a new cycle, in Watch and in Inspect.
|
|
1689
|
+
let frameDrawn = false;
|
|
1690
|
+
let bufferTimer = null;
|
|
1691
|
+
const bootAt = now().getTime();
|
|
1692
|
+
let bootRetry = null;
|
|
1693
|
+
const wireLoad = (el) => {
|
|
1694
|
+
el.addEventListener("load", () => {
|
|
1695
|
+
// A new frame takes Watch's shot before it draws, so it opens on it and never on the fit.
|
|
1696
|
+
tellShot(true);
|
|
1697
|
+
tellFrame(true);
|
|
1698
|
+
// The frame reads its graph after load; tell it again once it has had the time.
|
|
1699
|
+
for (const ms of [1500, 4000, 8000]) setTimeout(() => (tellFrame(true), tellShot(true)), ms);
|
|
1700
|
+
});
|
|
1701
|
+
};
|
|
1702
|
+
const swapFrame = () => {
|
|
1703
|
+
if (!buffer) return;
|
|
1704
|
+
clearTimeout(bufferTimer);
|
|
1705
|
+
const old = frame;
|
|
1706
|
+
buffer.id = old.id;
|
|
1707
|
+
buffer.className = old.className;
|
|
1708
|
+
buffer.removeAttribute("style");
|
|
1709
|
+
buffer.removeAttribute("aria-hidden");
|
|
1710
|
+
buffer.removeAttribute("tabindex");
|
|
1711
|
+
old.remove();
|
|
1712
|
+
frame = buffer;
|
|
1713
|
+
buffer = null;
|
|
1714
|
+
frameDrawn = true;
|
|
1715
|
+
s.boxes = null;
|
|
1716
|
+
lastFocus = undefined;
|
|
1717
|
+
tellFrame(true);
|
|
1718
|
+
tellShot(true);
|
|
1719
|
+
draw();
|
|
1720
|
+
};
|
|
1257
1721
|
const openFrame = () => {
|
|
1258
1722
|
if (!frame) return;
|
|
1723
|
+
// The first load waits (a few seconds at most) for the narration, which names the checkout the step is on: one load, not two.
|
|
1724
|
+
if (frameSrcNow === null && !(s.demo && s.demo.demo) && now().getTime() - bootAt < FRAME_BOOT_WAIT_MS) {
|
|
1725
|
+
if (!bootRetry) bootRetry = setTimeout(() => ((bootRetry = null), openFrame()), 400);
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1259
1728
|
const src = frameSrc(origin, viewZoom(shownView().view), wantRepo(), getThemeName());
|
|
1260
1729
|
if (src === frameSrcNow) return;
|
|
1261
|
-
|
|
1262
|
-
// The frame reads its graph after load; tell it again once it has had the time.
|
|
1263
|
-
frame.addEventListener("load", () => {
|
|
1264
|
-
for (const ms of [1500, 4000, 8000]) setTimeout(() => tellFrame(true), ms);
|
|
1265
|
-
});
|
|
1266
|
-
}
|
|
1730
|
+
const first = frameSrcNow === null;
|
|
1267
1731
|
frameSrcNow = src;
|
|
1268
|
-
|
|
1732
|
+
if (first) wireLoad(frame);
|
|
1733
|
+
// Nothing drawn yet to keep up (the first load, or a load before the last one drew): load in place.
|
|
1734
|
+
if (first || !frameDrawn || typeof document === "undefined" || !frame.parentNode) {
|
|
1735
|
+
frameDrawn = false;
|
|
1736
|
+
frame.src = src;
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
if (buffer) {
|
|
1740
|
+
clearTimeout(bufferTimer);
|
|
1741
|
+
buffer.remove();
|
|
1742
|
+
}
|
|
1743
|
+
buffer = document.createElement("iframe");
|
|
1744
|
+
buffer.title = frame.title;
|
|
1745
|
+
buffer.className = "k-frame-next";
|
|
1746
|
+
buffer.setAttribute("aria-hidden", "true");
|
|
1747
|
+
buffer.setAttribute("tabindex", "-1");
|
|
1748
|
+
// Over the shown frame, its size, out of sight: it lays out as the shown one does, so it opens on the same fit and shot.
|
|
1749
|
+
Object.assign(buffer.style, { position: "absolute", left: `${frame.offsetLeft}px`, top: `${frame.offsetTop}px`, width: `${frame.offsetWidth}px`, height: `${frame.offsetHeight}px`, opacity: "0", pointerEvents: "none", border: "0" });
|
|
1750
|
+
wireLoad(buffer);
|
|
1751
|
+
buffer.src = src;
|
|
1752
|
+
frame.parentNode.insertBefore(buffer, frame.nextSibling);
|
|
1753
|
+
// A frame that never says it drew still swaps in, late, rather than never.
|
|
1754
|
+
bufferTimer = setTimeout(swapFrame, FRAME_SWAP_MS);
|
|
1269
1755
|
};
|
|
1756
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
1757
|
+
window.addEventListener("message", (e) => {
|
|
1758
|
+
if (e.origin !== origin || !e.data || e.data.type !== "behold:drawn") return;
|
|
1759
|
+
if (buffer && e.source === buffer.contentWindow) swapFrame();
|
|
1760
|
+
else if (frame && e.source === frame.contentWindow) frameDrawn = true;
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1270
1763
|
/** behold#571: the commit each served checkout holds, read again when a step names a new one. */
|
|
1271
1764
|
const readCommits = () => fetchJson("/api/project").then((p) => {
|
|
1272
1765
|
if (p && !p.error && Array.isArray(p.viewRepos)) {
|
|
@@ -1365,6 +1858,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1365
1858
|
draw();
|
|
1366
1859
|
};
|
|
1367
1860
|
|
|
1861
|
+
applyMode();
|
|
1368
1862
|
void demo();
|
|
1369
1863
|
void reports(false);
|
|
1370
1864
|
void progress(false);
|