@intentius/behold 0.29.55 → 0.29.56
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/package.json +1 -1
- package/web/app.js +159 -4
- package/web/index.html +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/behold",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.56",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
|
package/web/app.js
CHANGED
|
@@ -325,8 +325,120 @@ function recolorNodesByCategory(ir) {
|
|
|
325
325
|
const bar = g.querySelector('rect[width="4"]');
|
|
326
326
|
if (bar) bar.setAttribute("fill", "var(--runtime)");
|
|
327
327
|
}
|
|
328
|
+
renderGraphLegend();
|
|
328
329
|
}
|
|
329
330
|
onThemeChange(() => (recolorNodesByCategory(), drawTgReads())); // behold#571: drawTgReads redraws the marks in the theme's colours
|
|
331
|
+
// behold#824: the legend on the graph itself. In drift mode a card's fill is
|
|
332
|
+
// its resource kind (one hue per kind, nothing more) and its state is the bar
|
|
333
|
+
// down its left side and its outline, but the only legend was in the Model
|
|
334
|
+
// tab, so the biggest colours on the canvas read as a code with no key. This
|
|
335
|
+
// corner says what each one is, with the counts the Model tab keeps, and the
|
|
336
|
+
// health marks when there are any. Closed once, it stays closed for this
|
|
337
|
+
// viewer (a "legend" button brings it back).
|
|
338
|
+
const LEGEND_KEY = "behold.graph.legend.hidden";
|
|
339
|
+
function legendHidden() {
|
|
340
|
+
try {
|
|
341
|
+
return localStorage.getItem(LEGEND_KEY) === "1";
|
|
342
|
+
} catch {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function renderGraphLegend() {
|
|
347
|
+
const host = document.getElementById("graph");
|
|
348
|
+
if (!host) return;
|
|
349
|
+
let el = document.getElementById("graph-legend");
|
|
350
|
+
const ir = lastGraphIr;
|
|
351
|
+
const onOverlay = !!(lastMeta && lastMeta.env);
|
|
352
|
+
if (!ir || !onOverlay || activeColourMode() !== "drift" || embedOpts.bare) {
|
|
353
|
+
if (el) el.remove();
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (!el) {
|
|
357
|
+
el = document.createElement("div");
|
|
358
|
+
el.id = "graph-legend";
|
|
359
|
+
host.appendChild(el);
|
|
360
|
+
}
|
|
361
|
+
el.innerHTML = "";
|
|
362
|
+
if (legendHidden()) {
|
|
363
|
+
el.className = "closed";
|
|
364
|
+
el.appendChild(button("legend", "act", () => {
|
|
365
|
+
try {
|
|
366
|
+
localStorage.removeItem(LEGEND_KEY);
|
|
367
|
+
} catch {}
|
|
368
|
+
renderGraphLegend();
|
|
369
|
+
}));
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
el.className = "";
|
|
373
|
+
const head = document.createElement("div");
|
|
374
|
+
head.className = "gl-head";
|
|
375
|
+
head.textContent = "legend";
|
|
376
|
+
const close = button("×", "gl-close", () => {
|
|
377
|
+
try {
|
|
378
|
+
localStorage.setItem(LEGEND_KEY, "1");
|
|
379
|
+
} catch {}
|
|
380
|
+
renderGraphLegend();
|
|
381
|
+
});
|
|
382
|
+
close.title = "Hide the legend (the Model tab keeps it)";
|
|
383
|
+
head.appendChild(close);
|
|
384
|
+
el.appendChild(head);
|
|
385
|
+
const line = (swatch, text, count, cls) => {
|
|
386
|
+
const row = document.createElement("div");
|
|
387
|
+
row.className = "gl-row" + (cls ? " " + cls : "");
|
|
388
|
+
row.appendChild(swatch);
|
|
389
|
+
const t = document.createElement("span");
|
|
390
|
+
t.className = "grow";
|
|
391
|
+
t.textContent = text;
|
|
392
|
+
row.appendChild(t);
|
|
393
|
+
if (count) {
|
|
394
|
+
const c = document.createElement("span");
|
|
395
|
+
c.className = "gl-count";
|
|
396
|
+
c.textContent = count;
|
|
397
|
+
row.appendChild(c);
|
|
398
|
+
}
|
|
399
|
+
el.appendChild(row);
|
|
400
|
+
};
|
|
401
|
+
const kinds = [...new Set(ir.nodes.map((n) => n.kind || n.lexicon || "node"))].slice(0, 3);
|
|
402
|
+
const fills = document.createElement("span");
|
|
403
|
+
fills.className = "gl-fills";
|
|
404
|
+
for (const k of kinds) {
|
|
405
|
+
const f = document.createElement("i");
|
|
406
|
+
f.style.background = colorForCategory(k);
|
|
407
|
+
fills.appendChild(f);
|
|
408
|
+
}
|
|
409
|
+
line(fills, "card colour: resource kind");
|
|
410
|
+
const sub = document.createElement("div");
|
|
411
|
+
sub.className = "gl-sub";
|
|
412
|
+
sub.textContent = "bar and outline: state";
|
|
413
|
+
el.appendChild(sub);
|
|
414
|
+
const words = statusLabels();
|
|
415
|
+
const counts = {};
|
|
416
|
+
for (const n of ir.nodes) {
|
|
417
|
+
const st = n.attrs && n.attrs._status;
|
|
418
|
+
if (st in words) counts[st] = (counts[st] || 0) + 1;
|
|
419
|
+
}
|
|
420
|
+
for (const [k, label] of Object.entries(words)) {
|
|
421
|
+
if (!counts[k]) continue;
|
|
422
|
+
const bar = document.createElement("span");
|
|
423
|
+
bar.className = "gl-bar";
|
|
424
|
+
bar.style.background = DRIFT_STATUS_VAR[k];
|
|
425
|
+
line(bar, label, String(counts[k]));
|
|
426
|
+
}
|
|
427
|
+
const health = hmLegendRows(hmAnswer);
|
|
428
|
+
if (health.length) {
|
|
429
|
+
const hs = document.createElement("div");
|
|
430
|
+
hs.className = "gl-sub";
|
|
431
|
+
hs.textContent = "health";
|
|
432
|
+
el.appendChild(hs);
|
|
433
|
+
for (const r of health) {
|
|
434
|
+
const dot = document.createElement("span");
|
|
435
|
+
dot.className = "gl-dot" + (r.dashed ? " dashed" : "");
|
|
436
|
+
dot.style.background = r.color;
|
|
437
|
+
line(dot, r.text, r.count);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
330
442
|
|
|
331
443
|
// #229, the one motion signature behold spends on data: a node whose drift
|
|
332
444
|
// `_status` CHANGED between two renders pulses once in the colour it just
|
|
@@ -1947,12 +2059,22 @@ function renderPanelView() {
|
|
|
1947
2059
|
// phase boxes).
|
|
1948
2060
|
if (!view.components && !view.logical && !view.ops) {
|
|
1949
2061
|
zoom.appendChild(panelHeading("layout"));
|
|
1950
|
-
|
|
1951
|
-
|
|
2062
|
+
// behold#824: an estate of several projects is laid out one box per
|
|
2063
|
+
// project, and the radial layout has no boxes, so the server draws the
|
|
2064
|
+
// same picture either way. Greyed out with the reason, like a colour mode
|
|
2065
|
+
// that can't apply.
|
|
2066
|
+
const estate = !!(lastMeta && lastMeta.estate > 1);
|
|
2067
|
+
const radial = panelOpt(
|
|
2068
|
+
"radial",
|
|
2069
|
+
view.radial && !estate,
|
|
2070
|
+
() => {
|
|
1952
2071
|
view.radial = !view.radial;
|
|
1953
2072
|
load();
|
|
1954
|
-
},
|
|
2073
|
+
},
|
|
2074
|
+
estate ? "Radial lays out one project; this is an estate of several, drawn one box per project" : "Curl the wide DAG onto concentric rings",
|
|
1955
2075
|
);
|
|
2076
|
+
if (estate) radial.disabled = true;
|
|
2077
|
+
zoom.appendChild(radial);
|
|
1956
2078
|
}
|
|
1957
2079
|
const tools = document.getElementById("panel-viewtools");
|
|
1958
2080
|
tools.innerHTML = "";
|
|
@@ -6531,6 +6653,7 @@ async function loadHealth(env, fresh) {
|
|
|
6531
6653
|
if (view.env === env) {
|
|
6532
6654
|
markHealthCards(hmAnswer);
|
|
6533
6655
|
renderPanel();
|
|
6656
|
+
renderGraphLegend();
|
|
6534
6657
|
}
|
|
6535
6658
|
}
|
|
6536
6659
|
function markHealthCards(a) {
|
|
@@ -8655,6 +8778,7 @@ function applyVB() {
|
|
|
8655
8778
|
const s = currentSvg();
|
|
8656
8779
|
if (s && vb) s.setAttribute("viewBox", vb.join(" "));
|
|
8657
8780
|
scaleBoxLabels(); // #396 item 7b: box titles/badges keep a legible size at every zoom
|
|
8781
|
+
scaleEdgeLabels(); // behold#824: an edge's label keeps a legible size too
|
|
8658
8782
|
dotsCamera(); // #712: a no-op unless the dots preview is mounted
|
|
8659
8783
|
kioskTellBoxes(); // behold#571: the kiosk's overlays ride the boxes they describe
|
|
8660
8784
|
}
|
|
@@ -8849,6 +8973,37 @@ function scaleBoxLabels() {
|
|
|
8849
8973
|
}
|
|
8850
8974
|
}
|
|
8851
8975
|
|
|
8976
|
+
// behold#824: an edge's label (`import`, `HealthCheckId`) is drawn at 10.5
|
|
8977
|
+
// units, which on a graph fitted at a quarter scale is under 3px — present but
|
|
8978
|
+
// unreadable. Each label's pill and text are scaled about the pill's own centre
|
|
8979
|
+
// until the text renders at EDGE_LABEL_MIN_PX on screen, up to EDGE_LABEL_MAX_K
|
|
8980
|
+
// times its drawn size, so it stays on its line and never swamps the cards.
|
|
8981
|
+
// Zoomed in far enough, the label is left exactly as pinhole drew it.
|
|
8982
|
+
const EDGE_LABEL_MIN_PX = 9;
|
|
8983
|
+
const EDGE_LABEL_MAX_K = 3;
|
|
8984
|
+
let edgeLabelState = { svg: null, scale: null };
|
|
8985
|
+
|
|
8986
|
+
function scaleEdgeLabels() {
|
|
8987
|
+
const svg = currentSvg();
|
|
8988
|
+
if (!svg || !vb) return;
|
|
8989
|
+
const pane = svg.getBoundingClientRect();
|
|
8990
|
+
if (!(pane.width > 0 && pane.height > 0)) return;
|
|
8991
|
+
const scale = Math.min(pane.width / vb[2], pane.height / vb[3]);
|
|
8992
|
+
if (!(scale > 0) || (edgeLabelState.svg === svg && edgeLabelState.scale === scale)) return;
|
|
8993
|
+
edgeLabelState = { svg, scale };
|
|
8994
|
+
for (const g of svg.querySelectorAll("g[data-edge-via]")) {
|
|
8995
|
+
const text = g.querySelector(":scope > text");
|
|
8996
|
+
const rect = g.querySelector(":scope > rect");
|
|
8997
|
+
if (!text || !rect) continue;
|
|
8998
|
+
const size = parseFloat(text.getAttribute("font-size")) || 10.5;
|
|
8999
|
+
const k = Math.min(EDGE_LABEL_MAX_K, Math.max(1, EDGE_LABEL_MIN_PX / (size * scale)));
|
|
9000
|
+
const cx = Number(rect.getAttribute("x")) + Number(rect.getAttribute("width")) / 2;
|
|
9001
|
+
const cy = Number(rect.getAttribute("y")) + Number(rect.getAttribute("height")) / 2;
|
|
9002
|
+
const t = k === 1 ? null : `translate(${cx} ${cy}) scale(${Math.round(k * 100) / 100}) translate(${-cx} ${-cy})`;
|
|
9003
|
+
for (const el of [rect, text]) t ? el.setAttribute("transform", t) : el.removeAttribute("transform");
|
|
9004
|
+
}
|
|
9005
|
+
}
|
|
9006
|
+
|
|
8852
9007
|
// How much of the viewBox one card should take when ⌘K lands on it (#393): the
|
|
8853
9008
|
// window is this many card-widths across, so a 301-card estate arrives readable
|
|
8854
9009
|
// rather than at whatever zoom the last gesture left. Never wider than the fit,
|
|
@@ -10844,7 +10999,7 @@ function paletteCommands() {
|
|
|
10844
10999
|
// Radial toggle — entity zooms only, same gate the removed checkbox had
|
|
10845
11000
|
// (components/logical/ops all lay themselves out: waves / nested arch boxes /
|
|
10846
11001
|
// phase boxes).
|
|
10847
|
-
if (!view.components && !view.logical && !view.ops) {
|
|
11002
|
+
if (!view.components && !view.logical && !view.ops && !(lastMeta && lastMeta.estate > 1)) {
|
|
10848
11003
|
c.push([(view.radial ? "Disable" : "Enable") + " radial layout", () => { view.radial = !view.radial; load(); }]);
|
|
10849
11004
|
}
|
|
10850
11005
|
// #393: 301 cards in one box read as a strip at any zoom. This shuts every
|
package/web/index.html
CHANGED
|
@@ -140,6 +140,26 @@
|
|
|
140
140
|
/* behold#824: an edge's label is read text, not a hint, so it takes the
|
|
141
141
|
full text colour, and its pill is outlined in the edge's own colour so
|
|
142
142
|
the label reads as part of its line. */
|
|
143
|
+
/* An edge is drawn the same width on screen at every zoom: in viewBox
|
|
144
|
+
units a fitted estate scaled its 1.4 down to a third of a pixel. */
|
|
145
|
+
#graph .pin-edge-line { vector-effect: non-scaling-stroke; stroke-width: 1.6px; }
|
|
146
|
+
/* behold#824: the legend on the graph — what a card's colour and its bar mean. */
|
|
147
|
+
#graph-legend { position: absolute; right: 12px; bottom: 12px; z-index: 5; min-width: 190px; max-width: 260px;
|
|
148
|
+
background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: var(--r-ctl);
|
|
149
|
+
padding: 8px 10px; font: var(--t-caption)/1.5 var(--font-ui); box-shadow: 0 2px 10px var(--shadow); }
|
|
150
|
+
#graph-legend.closed { min-width: 0; padding: 0; border: 0; background: none; box-shadow: none; }
|
|
151
|
+
#graph-legend .gl-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
|
|
152
|
+
#graph-legend .gl-close { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 2px; }
|
|
153
|
+
#graph-legend .gl-close:hover { color: var(--fg); }
|
|
154
|
+
#graph-legend .gl-row { display: flex; align-items: center; gap: 8px; }
|
|
155
|
+
#graph-legend .gl-row .grow { flex: 1; }
|
|
156
|
+
#graph-legend .gl-count { color: var(--muted); font-family: var(--font-mono); }
|
|
157
|
+
#graph-legend .gl-sub { color: var(--muted); margin-top: 6px; }
|
|
158
|
+
#graph-legend .gl-fills { display: inline-flex; gap: 2px; }
|
|
159
|
+
#graph-legend .gl-fills i { width: 8px; height: 12px; border-radius: 2px; display: inline-block; }
|
|
160
|
+
#graph-legend .gl-bar { width: 4px; height: 12px; border-radius: 1px; display: inline-block; margin: 0 9px 0 3px; }
|
|
161
|
+
#graph-legend .gl-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin: 0 6px 0 1px; }
|
|
162
|
+
#graph-legend .gl-dot.dashed { border-radius: 2px; }
|
|
143
163
|
#graph g[data-edge-via] > text { fill: var(--pin-text); }
|
|
144
164
|
#graph g[data-edge-via] > rect { stroke: var(--pin-edge); }
|
|
145
165
|
/* ---- Motion (#229) ---------------------------------------------------
|