@intentius/behold 0.29.40 → 0.29.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +148 -10
- package/README.md +6 -2
- package/dist/cli.js +15965 -13076
- package/example-writes/README.md +1 -1
- package/example-writes/chant.config.ts +0 -6
- package/package.json +5 -2
- package/web/app.js +327 -21
- package/web/carve-export.js +142 -0
- package/web/carve-narration.js +268 -0
- package/web/carve-narration.test.js +18 -0
- package/web/change-set-overlay.js +147 -0
- package/web/change-set-overlay.test.js +83 -0
- package/web/dots-border.js +66 -0
- package/web/dots-border.test.js +27 -0
- package/web/dots-kiosk.js +279 -0
- package/web/dots-kiosk.test.js +60 -0
- package/web/dots-layout.d.ts +10 -0
- package/web/dots-layout.js +201 -0
- package/web/dots-live.js +316 -0
- package/web/dots-live.test.js +220 -0
- package/web/dots-lod.js +122 -0
- package/web/dots-lod.test.js +78 -0
- package/web/dots-recording.d.ts +7 -0
- package/web/dots-recording.js +247 -0
- package/web/dots-recording.test.js +71 -0
- package/web/dots-scene.js +294 -0
- package/web/dots-scene.test.js +118 -0
- package/web/dots-timeline.js +128 -0
- package/web/dots-timeline.test.js +83 -0
- package/web/dots-tour.js +153 -0
- package/web/dots.js +2124 -0
- package/web/dots.test.js +15 -0
- package/web/index.html +29 -0
- package/web/kiosk-carve.js +219 -0
- package/web/kiosk-carve.test.js +26 -0
- package/web/kiosk-event-help-ui.js +6 -0
- package/web/kiosk.js +21 -6
- package/web/operator.js +1 -1
- package/web/run-playhead.js +102 -19
- package/web/run-playhead.test.js +81 -11
- package/web/tour-player.js +204 -0
- package/web/tour-player.test.js +115 -0
- package/web/tours/behold.tour.v1.schema.json +182 -0
- package/web/tours/terralith.json +330 -0
- package/web/trunk-lane.js +254 -0
- package/web/trunk-lane.test.js +117 -0
- package/web/workspace-gates.js +29 -4
- package/web/workspace-gates.test.js +23 -2
package/web/dots-tour.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// The tour on the dots layer (behold.tour/v1): the chapter's visuals mapped
|
|
2
|
+
// onto the scene's boxes and dots, and what the kiosk's caption says about
|
|
3
|
+
// them. Pure: the tour's state (web/tour-player.js), the scene's names and
|
|
4
|
+
// the dots' owners in, plain data out. web/dots.js draws it.
|
|
5
|
+
//
|
|
6
|
+
// Each visual stands on what the server read for it (src/terragucci-tour.ts):
|
|
7
|
+
// a light is a resource a run's plan.json planned, a pulse is a root a wave's
|
|
8
|
+
// plan named, a travel is a plan's read threads and the output's planned
|
|
9
|
+
// value, the state object is a migration record's source version, and a check
|
|
10
|
+
// is a root whose post-write plan changes nothing.
|
|
11
|
+
|
|
12
|
+
import { chapterAt, shownAt, railOf, chapterLines, cardRows, firedBy } from "./tour-player.js";
|
|
13
|
+
|
|
14
|
+
const fmt = (n) => Number(n).toLocaleString("en-US");
|
|
15
|
+
|
|
16
|
+
/** The tour's chapter and its visuals now, from the answer's events; null with no tour. */
|
|
17
|
+
export function tourNow(answer) {
|
|
18
|
+
const tour = answer && answer.tour;
|
|
19
|
+
if (!tour) return null;
|
|
20
|
+
const at = chapterAt(tour, tour.events, Infinity, tour.step);
|
|
21
|
+
return { tour, at, shown: at ? shownAt(at.chapter, tour.events) : [] };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The box an estate is drawn in: an adopted estate is drawn in its stock root's box (the answer's `adopted`). */
|
|
25
|
+
export function boxOfEstates(estates, names, adopted = []) {
|
|
26
|
+
const alias = new Map((adopted || []).map((a) => [a.to, a.from]));
|
|
27
|
+
const set = names instanceof Set ? names : new Set(names);
|
|
28
|
+
for (const e of estates || []) {
|
|
29
|
+
const b = alias.get(e) ?? e;
|
|
30
|
+
if (set.has(b)) return b;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** What the chapter frames: the source box, all of them, or the box its lights are in. */
|
|
36
|
+
export function tourFocus(tn, names, adopted) {
|
|
37
|
+
const f = tn && tn.at && tn.at.chapter.focus ? tn.at.chapter.focus.boxes : "all";
|
|
38
|
+
if (f === "source") return { kind: "source" };
|
|
39
|
+
if (f === "lit") {
|
|
40
|
+
const light = tn.shown.find((x) => x.kind === "light");
|
|
41
|
+
const b = light && light.lit.length ? boxOfEstates(light.lit[0].estates, names, adopted) : null;
|
|
42
|
+
if (b) return { kind: "box", estate: b };
|
|
43
|
+
}
|
|
44
|
+
return { kind: "all" };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The chapter's visuals mapped onto the scene. `ids`: the dots' ids (an
|
|
49
|
+
* address, or an address with `#n` when two estates name it); `owners`: each
|
|
50
|
+
* dot's box now; `source`: the source box.
|
|
51
|
+
*/
|
|
52
|
+
export function tourFx(tn, { ids, owners, names, adopted, source }) {
|
|
53
|
+
const fx = { lights: new Map(), pulses: [], travel: null, state: null, checks: new Map() };
|
|
54
|
+
if (!tn || !tn.at) return fx;
|
|
55
|
+
const byAddr = new Map();
|
|
56
|
+
for (const id of ids) {
|
|
57
|
+
const base = id.replace(/#\d+$/, "");
|
|
58
|
+
if (!byAddr.has(base)) byAddr.set(base, []);
|
|
59
|
+
byAddr.get(base).push(id);
|
|
60
|
+
}
|
|
61
|
+
const box = (es) => boxOfEstates(es, names, adopted);
|
|
62
|
+
const timed = tn.shown.filter((x) => x.at !== null);
|
|
63
|
+
for (const s of tn.shown) {
|
|
64
|
+
if (s.kind === "light") {
|
|
65
|
+
for (const l of s.lit) {
|
|
66
|
+
const b = box(l.estates);
|
|
67
|
+
const cands = byAddr.get(l.address) || [];
|
|
68
|
+
const id = cands.find((x) => (owners.get(x) ?? source) === b) ?? (cands.length === 1 ? cands[0] : null);
|
|
69
|
+
if (id) fx.lights.set(id, { changed: l.changed, at: s.at });
|
|
70
|
+
}
|
|
71
|
+
} else if (s.kind === "pulse") {
|
|
72
|
+
// A wave's pulse runs until the chapter's next visual fires.
|
|
73
|
+
const later = timed.some((x) => x !== s && x.at > (s.at ?? -Infinity));
|
|
74
|
+
if (!later) for (const es of s.estates) {
|
|
75
|
+
const b = box(es);
|
|
76
|
+
if (b && !fx.pulses.includes(b)) fx.pulses.push(b);
|
|
77
|
+
}
|
|
78
|
+
} else if (s.kind === "travel") {
|
|
79
|
+
const threads = [];
|
|
80
|
+
for (const th of s.threads) {
|
|
81
|
+
const from = box(th.from);
|
|
82
|
+
const to = box(th.to);
|
|
83
|
+
if (from && to && from !== to && !threads.some((x) => x.from === from && x.to === to)) threads.push({ from, to });
|
|
84
|
+
}
|
|
85
|
+
if (threads.length) fx.travel = { threads, value: s.value ?? null, output: s.output, at: s.at };
|
|
86
|
+
} else if (s.kind === "state") {
|
|
87
|
+
const last = firedBy({ migration: s.migration, line: "last" }, tn.tour.events);
|
|
88
|
+
fx.state = { box: box(s.estates) ?? source, version: s.version_id, unchanged: !!(last && s.finished) };
|
|
89
|
+
} else if (s.kind === "checks") {
|
|
90
|
+
for (const c of s.checks) {
|
|
91
|
+
const b = box(c.estates);
|
|
92
|
+
if (b) fx.checks.set(b, c.noChange);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return fx;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The key of what tourFx draws, so it is rebuilt only when that changes. */
|
|
100
|
+
export function fxKey(tn, extra = "") {
|
|
101
|
+
if (!tn || !tn.at) return "";
|
|
102
|
+
return `${tn.at.chapter.id}|${tn.shown.map((x) => `${x.kind}@${x.at}`).join(",")}|${extra}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The tour as the kiosk's caption says it: the rail, the chapter's heading
|
|
107
|
+
* and lines, a note for each visual naming the record it stands on, the
|
|
108
|
+
* epilogue's card and the follow-along links. `counts`: each box's dots now;
|
|
109
|
+
* `short(e)`: a box's name as the boxes show it.
|
|
110
|
+
*/
|
|
111
|
+
export function tourMessage(tn, { counts, names, adopted, source, short = (e) => e }) {
|
|
112
|
+
const tour = tn.tour;
|
|
113
|
+
const ch = tn.at.chapter;
|
|
114
|
+
const facts = tour.facts || {};
|
|
115
|
+
const notes = [];
|
|
116
|
+
const box = (es) => boxOfEstates(es, names, adopted);
|
|
117
|
+
for (const s of tn.shown) {
|
|
118
|
+
const job = s.job ? `job #${s.job}` : null;
|
|
119
|
+
if (s.kind === "light") {
|
|
120
|
+
const what = s.stage === "tf-plan" ? (s.pull ? `pull request ${s.pull}'s plan` : "the plan") : s.wave ? `wave ${s.wave}'s plan` : "the plan";
|
|
121
|
+
notes.push(`lit: the ${fmt(s.lit.length)} resources in ${what}${s.changed && s.changed < s.lit.length ? `, ${fmt(s.changed)} of them changed` : ""}${job ? ` · ${job}` : ""}`);
|
|
122
|
+
} else if (s.kind === "state") {
|
|
123
|
+
const last = firedBy({ migration: s.migration, line: "last" }, tour.events);
|
|
124
|
+
notes.push(`state file version ${String(s.version_id).slice(0, 8)}${last && s.finished ? ", unchanged" : ""}`);
|
|
125
|
+
} else if (s.kind === "counts") {
|
|
126
|
+
const parts = [...counts].filter(([e, n]) => e !== source && n > 0).sort((a, b) => (a[0] < b[0] ? -1 : 1)).map(([e, n]) => `${short(e)} ${fmt(n)}`);
|
|
127
|
+
if (parts.length) notes.push(parts.join(" · "));
|
|
128
|
+
} else if (s.kind === "checks") {
|
|
129
|
+
const name = (c) => (c.root === "." ? short(box(c.estates) || "root") : c.root);
|
|
130
|
+
const ok = s.checks.filter((c) => c.noChange).map(name);
|
|
131
|
+
const not = s.checks.filter((c) => !c.noChange).map(name);
|
|
132
|
+
if (ok.length) notes.push(`after the write, ${ok.join(", ")} plan${ok.length === 1 ? "s" : ""} no change${job ? ` · ${job}` : ""}`);
|
|
133
|
+
if (not.length) notes.push(`${not.join(", ")} still plan${not.length === 1 ? "s" : ""} a change`);
|
|
134
|
+
} else if (s.kind === "travel" && s.value !== undefined) {
|
|
135
|
+
const readers = [...new Set(s.threads.map((t) => box(t.to)).filter(Boolean).map(short))];
|
|
136
|
+
notes.push(`${s.output} = ${s.value}, as the plan has it, read by ${readers.join(", ")}`);
|
|
137
|
+
} else if (s.kind === "pulse") notes.push(`wave ${s.wave || 1} plans ${s.estates.map((es) => short(box(es) || es[0] || "")).filter(Boolean).join(", ")}${job ? ` · ${job}` : ""}`);
|
|
138
|
+
}
|
|
139
|
+
const card = tn.shown.find((x) => x.kind === "card");
|
|
140
|
+
return {
|
|
141
|
+
name: tour.name,
|
|
142
|
+
title: tour.title,
|
|
143
|
+
rail: railOf(tour, tn.at),
|
|
144
|
+
n: tn.at.index + 1,
|
|
145
|
+
of: tour.chapters.length,
|
|
146
|
+
id: ch.id,
|
|
147
|
+
heading: ch.title,
|
|
148
|
+
lines: chapterLines(ch, facts),
|
|
149
|
+
notes,
|
|
150
|
+
card: card ? cardRows(card.card, facts) : null,
|
|
151
|
+
links: tour.links || { pull: null, job: null },
|
|
152
|
+
};
|
|
153
|
+
}
|