@loadmap/react 0.4.0 → 0.5.0
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/README.md +14 -5
- package/dist/index.d.ts +55 -15
- package/dist/index.js +958 -217
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2,8 +2,9 @@ import { compare, headroom, reach } from "@loadmap/core";
|
|
|
2
2
|
import { fitLinear } from "@loadmap/core/calibrate";
|
|
3
3
|
import { compact, compact as compact$1, fmt, fmt as fmt$1, monthOf, multiple, multiple as multiple$1, multiples, pct, pct as pct$1, secs, secs as secs$1 } from "@loadmap/core/format";
|
|
4
4
|
import { anchor, cluster, defineView, edge, labelsAt, layout, legPath, localElk, node, pointAt, pool, structureKey } from "@loadmap/layout";
|
|
5
|
-
import { memo, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { memo, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { morph } from "@loadmap/layout/internal";
|
|
7
8
|
import { createSim } from "@loadmap/sim";
|
|
8
9
|
export * from "@loadmap/core";
|
|
9
10
|
// src/scenarios.tsx
|
|
@@ -154,21 +155,40 @@ function Compare({ lm, title = "Scenarios compared" }) {
|
|
|
154
155
|
]
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
|
-
/** The
|
|
158
|
-
function
|
|
158
|
+
/** The size of an element in CSS pixels, kept current: a chart draws at its own size so text stays legible. */
|
|
159
|
+
function useSize(fallback) {
|
|
159
160
|
const ref = useRef(null);
|
|
160
|
-
const [
|
|
161
|
+
const [size, setSize] = useState({
|
|
162
|
+
width: fallback,
|
|
163
|
+
height: 0
|
|
164
|
+
});
|
|
161
165
|
useEffect(() => {
|
|
162
166
|
const el = ref.current;
|
|
163
167
|
if (!el) return;
|
|
164
168
|
const ro = new ResizeObserver(([e]) => {
|
|
165
|
-
const
|
|
166
|
-
|
|
169
|
+
const width = Math.round(e?.contentRect.width ?? el.clientWidth);
|
|
170
|
+
const height = Math.round(e?.contentRect.height ?? el.clientHeight);
|
|
171
|
+
if (width > 0) setSize((s) => s.width === width && s.height === height ? s : {
|
|
172
|
+
width,
|
|
173
|
+
height
|
|
174
|
+
});
|
|
167
175
|
});
|
|
168
176
|
ro.observe(el);
|
|
169
177
|
return () => ro.disconnect();
|
|
170
178
|
}, []);
|
|
171
|
-
return [ref,
|
|
179
|
+
return [ref, size];
|
|
180
|
+
}
|
|
181
|
+
/** Every scenario's line over the load: it depends on every value but the load, which is only the marker. */
|
|
182
|
+
function useHeadroom(lm) {
|
|
183
|
+
const { model, values } = lm;
|
|
184
|
+
const rest = JSON.stringify({
|
|
185
|
+
...values,
|
|
186
|
+
load: null
|
|
187
|
+
});
|
|
188
|
+
return useMemo(() => headroom(model, {
|
|
189
|
+
...values,
|
|
190
|
+
load: model.load.default
|
|
191
|
+
}), [model, rest]);
|
|
172
192
|
}
|
|
173
193
|
/** 1, 2, 5, 10, 20, 50, … inside [from, to]; decades only when there is little room. */
|
|
174
194
|
function ticks(from, to, roomy) {
|
|
@@ -192,15 +212,8 @@ function ticks(from, to, roomy) {
|
|
|
192
212
|
*/
|
|
193
213
|
function HeadroomChart({ lm, title = "Headroom" }) {
|
|
194
214
|
const { model, values } = lm;
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
load: null
|
|
198
|
-
});
|
|
199
|
-
const h = useMemo(() => headroom(model, {
|
|
200
|
-
...values,
|
|
201
|
-
load: model.load.default
|
|
202
|
-
}), [model, rest]);
|
|
203
|
-
const [wrap, width] = useWidth(640);
|
|
215
|
+
const h = useHeadroom(lm);
|
|
216
|
+
const [wrap, { width }] = useSize(640);
|
|
204
217
|
const [hover, setHover] = useState(null);
|
|
205
218
|
const clip = useId().replace(/:/g, "");
|
|
206
219
|
const dated = !!model.growth;
|
|
@@ -528,8 +541,6 @@ const STATE_STROKE = {
|
|
|
528
541
|
warn: "var(--lm-warn)",
|
|
529
542
|
over: "var(--lm-drop)"
|
|
530
543
|
};
|
|
531
|
-
/** Room kept under the board in full screen for the first lines of the verdict, so the page shows it goes on. */
|
|
532
|
-
const VERDICT_PEEK = 72;
|
|
533
544
|
const tokenColor = (c) => [
|
|
534
545
|
"accent",
|
|
535
546
|
"alt",
|
|
@@ -549,24 +560,36 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
|
|
|
549
560
|
const barRef = useRef(null);
|
|
550
561
|
const boardRef = useRef(null);
|
|
551
562
|
const buttonRef = useRef(null);
|
|
552
|
-
const
|
|
553
|
-
const [overlay, setOverlay] = useState(false);
|
|
554
|
-
const full = screen || overlay;
|
|
563
|
+
const full = lm.fullScreen;
|
|
555
564
|
const [tip, setTip] = useState(null);
|
|
556
565
|
const detailId = useId();
|
|
566
|
+
useLayoutEffect(() => {
|
|
567
|
+
if (scene) engine.setScene(scene, { cut: reducedMotion });
|
|
568
|
+
}, [
|
|
569
|
+
engine,
|
|
570
|
+
scene,
|
|
571
|
+
reducedMotion
|
|
572
|
+
]);
|
|
573
|
+
const frameId = useSyncExternalStore(engine.subscribe, () => engine.frameId);
|
|
574
|
+
const frame = engine.frame;
|
|
557
575
|
useEffect(() => {
|
|
558
|
-
if (scene) engine.setScene(scene);
|
|
559
576
|
engine.bind(svgRef.current, canvasRef.current);
|
|
577
|
+
}, [
|
|
578
|
+
engine,
|
|
579
|
+
frame,
|
|
580
|
+
reducedMotion
|
|
581
|
+
]);
|
|
582
|
+
useEffect(() => {
|
|
560
583
|
if (lm.root) engine.readColors(lm.root);
|
|
561
584
|
}, [
|
|
562
585
|
engine,
|
|
563
586
|
scene,
|
|
564
|
-
reducedMotion,
|
|
565
587
|
lm.root
|
|
566
588
|
]);
|
|
567
589
|
useEffect(() => {
|
|
568
590
|
engine.drawnValues = JSON.stringify(lm.values);
|
|
569
591
|
engine.drawnFocus = lm.focus;
|
|
592
|
+
engine.drawnFrame = frameId;
|
|
570
593
|
});
|
|
571
594
|
useEffect(() => {
|
|
572
595
|
const board = boardRef.current;
|
|
@@ -590,39 +613,6 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
|
|
|
590
613
|
raf = requestAnimationFrame(frame);
|
|
591
614
|
return () => cancelAnimationFrame(raf);
|
|
592
615
|
}, [engine, reducedMotion]);
|
|
593
|
-
useEffect(() => {
|
|
594
|
-
const el = lm.root ?? wrapRef.current;
|
|
595
|
-
const f = () => setScreen(!!el && document.fullscreenElement === el);
|
|
596
|
-
document.addEventListener("fullscreenchange", f);
|
|
597
|
-
return () => document.removeEventListener("fullscreenchange", f);
|
|
598
|
-
}, [lm.root]);
|
|
599
|
-
useEffect(() => {
|
|
600
|
-
const el = lm.root ?? wrapRef.current;
|
|
601
|
-
if (!el || !full) return;
|
|
602
|
-
el.setAttribute("data-full", overlay ? "overlay" : "screen");
|
|
603
|
-
const top = overlay && typeof el.showPopover === "function";
|
|
604
|
-
if (top) {
|
|
605
|
-
el.popover = "manual";
|
|
606
|
-
el.showPopover();
|
|
607
|
-
}
|
|
608
|
-
return () => {
|
|
609
|
-
el.removeAttribute("data-full");
|
|
610
|
-
if (top) {
|
|
611
|
-
el.hidePopover();
|
|
612
|
-
el.removeAttribute("popover");
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
}, [
|
|
616
|
-
lm.root,
|
|
617
|
-
full,
|
|
618
|
-
overlay
|
|
619
|
-
]);
|
|
620
|
-
useEffect(() => {
|
|
621
|
-
if (!overlay) return;
|
|
622
|
-
const f = (e) => e.key === "Escape" && setOverlay(false);
|
|
623
|
-
document.addEventListener("keydown", f);
|
|
624
|
-
return () => document.removeEventListener("keydown", f);
|
|
625
|
-
}, [overlay]);
|
|
626
616
|
const was = useRef(false);
|
|
627
617
|
useEffect(() => {
|
|
628
618
|
if (was.current && !full) buttonRef.current?.focus();
|
|
@@ -632,23 +622,41 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
|
|
|
632
622
|
const wrap = wrapRef.current;
|
|
633
623
|
const bar = barRef.current;
|
|
634
624
|
const root = lm.root;
|
|
635
|
-
if (!full || !scene || !wrap || !bar) return;
|
|
625
|
+
if (!full || !scene || !wrap || !bar || !root) return;
|
|
626
|
+
const px = (x) => Number.parseFloat(x) || 0;
|
|
636
627
|
const fit = () => {
|
|
637
|
-
const
|
|
638
|
-
let
|
|
639
|
-
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
|
|
628
|
+
const rs = getComputedStyle(root);
|
|
629
|
+
let around = px(rs.paddingTop) + px(rs.paddingBottom);
|
|
630
|
+
const add = (el) => {
|
|
631
|
+
const cs = getComputedStyle(el);
|
|
632
|
+
if (cs.display === "none" || cs.position === "absolute" || cs.position === "fixed") return;
|
|
633
|
+
around += px(rs.rowGap) + (px(cs.flexGrow) > 0 ? px(cs.minHeight) : el.offsetHeight);
|
|
634
|
+
};
|
|
635
|
+
for (const el of root.children) if (el !== wrap) add(el);
|
|
636
|
+
if (getComputedStyle(root, "::after").content !== "none") around += px(rs.rowGap);
|
|
637
|
+
const h = root.clientHeight - around - bar.offsetHeight - px(getComputedStyle(wrap).rowGap);
|
|
643
638
|
const w = Math.min(wrap.clientWidth, h * scene.width / scene.height);
|
|
644
639
|
wrap.style.setProperty("--lm-fit", `${Math.max(0, Math.floor(w))}px`);
|
|
645
640
|
};
|
|
646
641
|
const ro = new ResizeObserver(fit);
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
642
|
+
const watch = () => {
|
|
643
|
+
ro.disconnect();
|
|
644
|
+
ro.observe(bar);
|
|
645
|
+
ro.observe(root);
|
|
646
|
+
for (const el of root.children) ro.observe(el);
|
|
647
|
+
};
|
|
648
|
+
watch();
|
|
649
|
+
const mo = new MutationObserver(() => {
|
|
650
|
+
watch();
|
|
651
|
+
fit();
|
|
652
|
+
});
|
|
653
|
+
mo.observe(root, {
|
|
654
|
+
childList: true,
|
|
655
|
+
attributeFilter: ["data-mode"]
|
|
656
|
+
});
|
|
650
657
|
return () => {
|
|
651
658
|
ro.disconnect();
|
|
659
|
+
mo.disconnect();
|
|
652
660
|
wrap.style.removeProperty("--lm-fit");
|
|
653
661
|
};
|
|
654
662
|
}, [
|
|
@@ -656,24 +664,28 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
|
|
|
656
664
|
scene,
|
|
657
665
|
lm.root
|
|
658
666
|
]);
|
|
659
|
-
const
|
|
667
|
+
const { setFullScreenMode, fullScreenMode } = lm;
|
|
668
|
+
const modesRef = useRef(null);
|
|
660
669
|
useEffect(() => {
|
|
661
|
-
const
|
|
662
|
-
if (!full || !
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
670
|
+
const root = lm.root;
|
|
671
|
+
if (!full || !root) return;
|
|
672
|
+
const f = (e) => {
|
|
673
|
+
if (e.key !== "f" && e.key !== "F" || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
674
|
+
if (typing(e.composedPath()[0] ?? null) || root.querySelector(":scope > [data-drawer]")) return;
|
|
675
|
+
e.preventDefault();
|
|
676
|
+
if (e.repeat) return;
|
|
677
|
+
const next = fullScreenMode === "focus" ? "panels" : "focus";
|
|
678
|
+
if (document.activeElement?.closest(".lm-dock, .lm-line")) modesRef.current?.querySelector(`[data-mode="${next}"]`)?.focus();
|
|
679
|
+
setFullScreenMode(next);
|
|
668
680
|
};
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
681
|
+
document.addEventListener("keydown", f);
|
|
682
|
+
return () => document.removeEventListener("keydown", f);
|
|
683
|
+
}, [
|
|
684
|
+
full,
|
|
685
|
+
fullScreenMode,
|
|
686
|
+
setFullScreenMode,
|
|
687
|
+
lm.root
|
|
688
|
+
]);
|
|
677
689
|
return /* @__PURE__ */ jsxs("div", {
|
|
678
690
|
className: "lm-wrap",
|
|
679
691
|
ref: wrapRef,
|
|
@@ -681,28 +693,37 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
|
|
|
681
693
|
/* @__PURE__ */ jsxs("div", {
|
|
682
694
|
className: "lm-bar",
|
|
683
695
|
ref: barRef,
|
|
684
|
-
children: [legend ? /* @__PURE__ */ jsx(Legend, { lm }) : /* @__PURE__ */ jsx("span", {}), /* @__PURE__ */
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
696
|
+
children: [legend ? /* @__PURE__ */ jsx(Legend, { lm }) : /* @__PURE__ */ jsx("span", {}), /* @__PURE__ */ jsxs("span", {
|
|
697
|
+
className: "lm-tools",
|
|
698
|
+
children: [full && /* @__PURE__ */ jsx("fieldset", {
|
|
699
|
+
className: "lm-modes",
|
|
700
|
+
"aria-label": "Full screen shows (F)",
|
|
701
|
+
ref: modesRef,
|
|
702
|
+
children: ["panels", "focus"].map((m) => /* @__PURE__ */ jsx("button", {
|
|
703
|
+
type: "button",
|
|
704
|
+
"data-mode": m,
|
|
705
|
+
"aria-pressed": fullScreenMode === m,
|
|
706
|
+
"aria-keyshortcuts": "F",
|
|
707
|
+
onClick: () => setFullScreenMode(m),
|
|
708
|
+
children: m === "panels" ? "Panels" : "Focus"
|
|
709
|
+
}, m))
|
|
710
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
711
|
+
type: "button",
|
|
712
|
+
className: "lm-btn",
|
|
713
|
+
onClick: lm.toggleFullScreen,
|
|
714
|
+
"aria-pressed": full,
|
|
715
|
+
ref: buttonRef,
|
|
716
|
+
children: full ? "✕ Close" : "⤢ Full screen"
|
|
717
|
+
})]
|
|
691
718
|
})]
|
|
692
719
|
}),
|
|
693
|
-
full && away && /* @__PURE__ */ jsx("button", {
|
|
694
|
-
type: "button",
|
|
695
|
-
className: "lm-btn lm-corner",
|
|
696
|
-
onClick: toggle,
|
|
697
|
-
children: "✕ Close"
|
|
698
|
-
}),
|
|
699
720
|
/* @__PURE__ */ jsxs("div", {
|
|
700
721
|
className: "lm-board",
|
|
701
722
|
ref: boardRef,
|
|
702
|
-
style:
|
|
703
|
-
children: [
|
|
723
|
+
style: frame ? { aspectRatio: `${frame.width} / ${frame.height}` } : { minHeight: 240 },
|
|
724
|
+
children: [frame && /* @__PURE__ */ jsx(Structure, {
|
|
704
725
|
lm,
|
|
705
|
-
scene,
|
|
726
|
+
scene: frame,
|
|
706
727
|
svgRef,
|
|
707
728
|
rates: reducedMotion,
|
|
708
729
|
setTip,
|
|
@@ -723,6 +744,22 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
|
|
|
723
744
|
]
|
|
724
745
|
});
|
|
725
746
|
}
|
|
747
|
+
/** The keyboard is in a field that takes letters: the first target of the key, inside a web component too. */
|
|
748
|
+
function typing(t) {
|
|
749
|
+
if (!(t instanceof HTMLElement)) return false;
|
|
750
|
+
if (t.isContentEditable || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement) return true;
|
|
751
|
+
return t instanceof HTMLInputElement && ![
|
|
752
|
+
"range",
|
|
753
|
+
"checkbox",
|
|
754
|
+
"radio",
|
|
755
|
+
"button",
|
|
756
|
+
"submit",
|
|
757
|
+
"reset",
|
|
758
|
+
"image",
|
|
759
|
+
"file",
|
|
760
|
+
"color"
|
|
761
|
+
].includes(t.type);
|
|
762
|
+
}
|
|
726
763
|
function Legend({ lm }) {
|
|
727
764
|
const flows = lm.view.def.flows;
|
|
728
765
|
const grey = Object.values(lm.ev.overload).some((o) => o.merge) || Object.values(lm.ev.stages).some((s) => s.kind === "fanout");
|
|
@@ -847,20 +884,29 @@ const Structure = memo(function Structure({ lm, scene, svgRef, rates, setTip, on
|
|
|
847
884
|
});
|
|
848
885
|
const pathOf = (pts) => pts.map(([x, y], i) => `${i ? "L" : "M"}${x} ${y}`).join(" ");
|
|
849
886
|
function Edge({ e, text, marker }) {
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
887
|
+
const drawing = e.draw != null && e.draw < 1;
|
|
888
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
889
|
+
opacity: e.fade,
|
|
890
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
891
|
+
d: pathOf(e.points),
|
|
892
|
+
fill: "none",
|
|
893
|
+
stroke: "var(--lm-muted)",
|
|
894
|
+
strokeOpacity: ".7",
|
|
895
|
+
markerEnd: drawing ? void 0 : `url(#${marker})`,
|
|
896
|
+
...drawing ? {
|
|
897
|
+
pathLength: 1,
|
|
898
|
+
strokeDasharray: 1,
|
|
899
|
+
strokeDashoffset: 1 - e.draw
|
|
900
|
+
} : {}
|
|
901
|
+
}), e.label && text && /* @__PURE__ */ jsx("text", {
|
|
902
|
+
x: e.label.x + e.label.w / 2,
|
|
903
|
+
y: e.label.y + e.label.h / 2 + 4,
|
|
904
|
+
textAnchor: "middle",
|
|
905
|
+
fontSize: "11",
|
|
906
|
+
fill: "var(--lm-muted)",
|
|
907
|
+
children: text
|
|
908
|
+
})]
|
|
909
|
+
});
|
|
864
910
|
}
|
|
865
911
|
/** With reduced motion, each flow is a static stroke along its edges, its width scaled by its rate. */
|
|
866
912
|
function RateStrokes({ lm, scene }) {
|
|
@@ -896,7 +942,7 @@ function RateStrokes({ lm, scene }) {
|
|
|
896
942
|
}
|
|
897
943
|
return /* @__PURE__ */ jsx("g", { children: out });
|
|
898
944
|
}
|
|
899
|
-
function Txt({ s, children, anchor = "middle", fill = "currentColor" }) {
|
|
945
|
+
function Txt({ s, children, anchor = "middle", fill = "currentColor", opacity }) {
|
|
900
946
|
return /* @__PURE__ */ jsx("text", {
|
|
901
947
|
x: s.x,
|
|
902
948
|
y: s.y,
|
|
@@ -904,6 +950,7 @@ function Txt({ s, children, anchor = "middle", fill = "currentColor" }) {
|
|
|
904
950
|
fontWeight: s.weight,
|
|
905
951
|
textAnchor: anchor,
|
|
906
952
|
fill,
|
|
953
|
+
opacity,
|
|
907
954
|
children
|
|
908
955
|
});
|
|
909
956
|
}
|
|
@@ -912,9 +959,13 @@ function Node({ n, state, title, sub, lm, focused, selected, handlers }) {
|
|
|
912
959
|
const flows = lm.view.def.flows;
|
|
913
960
|
const st = n.kind === "pool" ? lm.ev.stages[n.stages[0] ?? ""] : void 0;
|
|
914
961
|
const running = st?.kind === "workers" ? st.running : n.members.length;
|
|
962
|
+
const idle = (i) => i >= running && i < (st?.kind === "workers" ? st.pods : n.members.length);
|
|
915
963
|
const e = 6;
|
|
964
|
+
const grow = n.fade == null ? void 0 : `translate(${n.x + n.w / 2} ${n.y + n.h / 2}) scale(${.92 + .08 * n.fade}) translate(${-n.x - n.w / 2} ${-n.y - n.h / 2})`;
|
|
916
965
|
return /* @__PURE__ */ jsxs("g", {
|
|
917
966
|
style: { color: "var(--lm-fg)" },
|
|
967
|
+
opacity: n.fade,
|
|
968
|
+
transform: grow,
|
|
918
969
|
"data-node": n.id,
|
|
919
970
|
"data-focus": focused || void 0,
|
|
920
971
|
"data-selected": selected || void 0,
|
|
@@ -950,8 +1001,8 @@ function Node({ n, state, title, sub, lm, focused, selected, handlers }) {
|
|
|
950
1001
|
children: sub
|
|
951
1002
|
}),
|
|
952
1003
|
n.members.map((m, i) => /* @__PURE__ */ jsxs("g", {
|
|
953
|
-
"data-idle": i
|
|
954
|
-
opacity: i
|
|
1004
|
+
"data-idle": idle(i) || void 0,
|
|
1005
|
+
opacity: idle(i) ? .45 * (m.fade ?? 1) : m.fade,
|
|
955
1006
|
children: [/* @__PURE__ */ jsx("rect", {
|
|
956
1007
|
x: m.x,
|
|
957
1008
|
y: m.y,
|
|
@@ -960,7 +1011,7 @@ function Node({ n, state, title, sub, lm, focused, selected, handlers }) {
|
|
|
960
1011
|
rx: "4",
|
|
961
1012
|
fill: "none",
|
|
962
1013
|
stroke: "var(--lm-line)",
|
|
963
|
-
strokeDasharray: i
|
|
1014
|
+
strokeDasharray: idle(i) ? "3 3" : void 0
|
|
964
1015
|
}), /* @__PURE__ */ jsx(Txt, {
|
|
965
1016
|
s: m.spot,
|
|
966
1017
|
anchor: "start",
|
|
@@ -968,43 +1019,48 @@ function Node({ n, state, title, sub, lm, focused, selected, handlers }) {
|
|
|
968
1019
|
children: m.label
|
|
969
1020
|
})]
|
|
970
1021
|
}, m.label)),
|
|
971
|
-
n.groups.map((g) => /* @__PURE__ */ jsx(Txt, {
|
|
1022
|
+
n.groups.map((g, i) => /* @__PURE__ */ jsx(Txt, {
|
|
972
1023
|
s: g.spot,
|
|
973
1024
|
anchor: "start",
|
|
974
1025
|
fill: tokenColor(flows[g.flow]?.color ?? "muted"),
|
|
1026
|
+
opacity: g.fade,
|
|
975
1027
|
children: g.text
|
|
976
|
-
}, `${g.flow}
|
|
1028
|
+
}, `${g.flow}#${i}`)),
|
|
977
1029
|
n.cells.map((c) => /* @__PURE__ */ jsx("rect", {
|
|
978
1030
|
x: c.x,
|
|
979
1031
|
y: c.y,
|
|
980
1032
|
width: c.w,
|
|
981
1033
|
height: c.h,
|
|
982
1034
|
rx: "1.5",
|
|
1035
|
+
opacity: c.fade,
|
|
983
1036
|
fill: "var(--lm-lane)",
|
|
984
1037
|
stroke: tokenColor(flows[c.flow]?.color ?? "muted"),
|
|
985
1038
|
strokeOpacity: ".6"
|
|
986
1039
|
}, `${c.stage}/${c.flow}/${c.index}`)),
|
|
987
|
-
n.slots.map((s) => /* @__PURE__ */ jsxs("g", {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
"
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1040
|
+
n.slots.map((s) => /* @__PURE__ */ jsxs("g", {
|
|
1041
|
+
opacity: s.fade,
|
|
1042
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
1043
|
+
x: s.x,
|
|
1044
|
+
y: s.y,
|
|
1045
|
+
width: s.w,
|
|
1046
|
+
height: s.h,
|
|
1047
|
+
rx: "2",
|
|
1048
|
+
fill: "var(--lm-surface)",
|
|
1049
|
+
stroke: "currentColor",
|
|
1050
|
+
strokeOpacity: ".45"
|
|
1051
|
+
}), /* @__PURE__ */ jsx("rect", {
|
|
1052
|
+
"data-slot": s.index,
|
|
1053
|
+
"data-stage": n.stages[0],
|
|
1054
|
+
"data-y": s.y,
|
|
1055
|
+
"data-s": s.w,
|
|
1056
|
+
x: s.x + 1,
|
|
1057
|
+
y: s.y + s.h - 1,
|
|
1058
|
+
width: s.w - 2,
|
|
1059
|
+
height: 0,
|
|
1060
|
+
rx: "1",
|
|
1061
|
+
fill: "var(--lm-accent)"
|
|
1062
|
+
})]
|
|
1063
|
+
}, s.index)),
|
|
1008
1064
|
selected && /* @__PURE__ */ jsx("rect", {
|
|
1009
1065
|
className: "lm-selected",
|
|
1010
1066
|
x: n.x - 3,
|
|
@@ -1358,34 +1414,42 @@ function Meters({ lm }) {
|
|
|
1358
1414
|
children: items.map((m) => /* @__PURE__ */ jsxs("div", {
|
|
1359
1415
|
className: "lm-meter",
|
|
1360
1416
|
"data-state": m.state,
|
|
1361
|
-
children: [/* @__PURE__ */ jsx("b", { children: m.value }), /* @__PURE__ */ jsx("span", {
|
|
1417
|
+
children: [/* @__PURE__ */ jsx("b", { children: m.value }), /* @__PURE__ */ jsx("span", {
|
|
1418
|
+
title: m.label,
|
|
1419
|
+
children: m.label
|
|
1420
|
+
})]
|
|
1362
1421
|
}, m.key))
|
|
1363
1422
|
})] });
|
|
1364
1423
|
}
|
|
1424
|
+
/** The load slider with its label and value. */
|
|
1425
|
+
function LoadRange({ lm }) {
|
|
1426
|
+
const load = lm.model.load;
|
|
1427
|
+
const x = lm.values.load;
|
|
1428
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
1429
|
+
className: "lm-range",
|
|
1430
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
1431
|
+
load.label,
|
|
1432
|
+
" ",
|
|
1433
|
+
/* @__PURE__ */ jsxs("output", { children: [fmt$1(x), "×"] })
|
|
1434
|
+
] }), /* @__PURE__ */ jsx("input", {
|
|
1435
|
+
type: "range",
|
|
1436
|
+
min: load.min,
|
|
1437
|
+
max: load.max,
|
|
1438
|
+
step: load.step,
|
|
1439
|
+
value: x,
|
|
1440
|
+
onChange: (e) => lm.setValues({ load: Number(e.target.value) })
|
|
1441
|
+
})]
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1365
1444
|
/** The load slider, the presets and every parameter, greyed out where it does not apply. */
|
|
1366
1445
|
function Controls({ lm }) {
|
|
1367
1446
|
const { model, values, setValues, ev } = lm;
|
|
1368
1447
|
const v = values;
|
|
1369
|
-
const load = model.load;
|
|
1370
1448
|
return /* @__PURE__ */ jsxs("div", {
|
|
1371
1449
|
className: "lm-card lm-controls",
|
|
1372
1450
|
children: [
|
|
1373
1451
|
/* @__PURE__ */ jsx("h3", { children: "Load" }),
|
|
1374
|
-
/* @__PURE__ */
|
|
1375
|
-
className: "lm-range",
|
|
1376
|
-
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
1377
|
-
load.label,
|
|
1378
|
-
" ",
|
|
1379
|
-
/* @__PURE__ */ jsxs("output", { children: [fmt$1(v.load), "×"] })
|
|
1380
|
-
] }), /* @__PURE__ */ jsx("input", {
|
|
1381
|
-
type: "range",
|
|
1382
|
-
min: load.min,
|
|
1383
|
-
max: load.max,
|
|
1384
|
-
step: load.step,
|
|
1385
|
-
value: v.load,
|
|
1386
|
-
onChange: (e) => setValues({ load: Number(e.target.value) })
|
|
1387
|
-
})]
|
|
1388
|
-
}),
|
|
1452
|
+
/* @__PURE__ */ jsx(LoadRange, { lm }),
|
|
1389
1453
|
/* @__PURE__ */ jsx("div", {
|
|
1390
1454
|
className: "lm-presets",
|
|
1391
1455
|
children: ev.presets.map((p) => {
|
|
@@ -1524,17 +1588,329 @@ function describe(a) {
|
|
|
1524
1588
|
/** Exact below 1,000 (3.9 cores), compact above (12k req/s). */
|
|
1525
1589
|
const num = (x) => Math.abs(x) >= 1e3 ? compact$1(x) : fmt$1(x);
|
|
1526
1590
|
const sig = (x) => Number(x.toPrecision(3)).toString();
|
|
1591
|
+
// src/compact.tsx
|
|
1592
|
+
/** The names a reader sees for the panels, on the tabs and the buttons that open them. */
|
|
1593
|
+
const NAMES = {
|
|
1594
|
+
verdict: "Verdict",
|
|
1595
|
+
live: "Live",
|
|
1596
|
+
limits: "Limits",
|
|
1597
|
+
controls: "Load",
|
|
1598
|
+
headroom: "Headroom",
|
|
1599
|
+
compare: "Compare",
|
|
1600
|
+
assumptions: "Assumptions"
|
|
1601
|
+
};
|
|
1602
|
+
/**
|
|
1603
|
+
* The verdict in one line, from the same evaluation as the sentence: the load, how far the target holds, the first
|
|
1604
|
+
* limit and how sure its capacity is, what is past capacity. The sentence is its tooltip and opens under "Why".
|
|
1605
|
+
*/
|
|
1606
|
+
function VerdictLine({ lm, verdict = true, extra = 0, open, assumptions }) {
|
|
1607
|
+
const { ev, model, values } = lm;
|
|
1608
|
+
const first = ev.firstLimit;
|
|
1609
|
+
const range = ev.target;
|
|
1610
|
+
const target = `${pct$1(model.thresholds.target)} target`;
|
|
1611
|
+
const c = first?.capacity;
|
|
1612
|
+
const sure = !c ? "" : c.provenance === "estimated" ? `est${c.within ? ` ${plusMinus(c)}` : ""}` : plusMinus(c);
|
|
1613
|
+
const over = ev.ranked.filter((x) => (x.util ?? 0) > model.thresholds.full);
|
|
1614
|
+
const when = range ? whenRange(model, range) : "";
|
|
1615
|
+
const estimated = ev.assumptions.filter((a) => a.kind === "capacity" && a.capacity.provenance === "estimated").length;
|
|
1616
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1617
|
+
verdict && /* @__PURE__ */ jsx("p", {
|
|
1618
|
+
className: "lm-headline",
|
|
1619
|
+
title: ev.verdict.text,
|
|
1620
|
+
"aria-live": "polite",
|
|
1621
|
+
children: !first || !range ? ev.verdict.text : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1622
|
+
/* @__PURE__ */ jsxs("b", {
|
|
1623
|
+
className: "lm-num",
|
|
1624
|
+
children: [fmt$1(values.load), "×"]
|
|
1625
|
+
}),
|
|
1626
|
+
" ·",
|
|
1627
|
+
" ",
|
|
1628
|
+
values.load < range.low ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1629
|
+
"the ",
|
|
1630
|
+
target,
|
|
1631
|
+
" holds to ",
|
|
1632
|
+
/* @__PURE__ */ jsx("b", {
|
|
1633
|
+
className: "lm-num",
|
|
1634
|
+
children: multiples(range, model.searchMax, true)
|
|
1635
|
+
}),
|
|
1636
|
+
when && ` (${when})`
|
|
1637
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1638
|
+
"past the ",
|
|
1639
|
+
target,
|
|
1640
|
+
" from ",
|
|
1641
|
+
/* @__PURE__ */ jsx("b", {
|
|
1642
|
+
className: "lm-num",
|
|
1643
|
+
children: multiple$1(range.low, model.searchMax)
|
|
1644
|
+
})
|
|
1645
|
+
] }),
|
|
1646
|
+
" ",
|
|
1647
|
+
"· first limit ",
|
|
1648
|
+
/* @__PURE__ */ jsx("b", { children: first.name }),
|
|
1649
|
+
sure && /* @__PURE__ */ jsx("span", {
|
|
1650
|
+
className: "lm-tag",
|
|
1651
|
+
"data-kind": c?.provenance === "estimated" ? "estimated" : "range",
|
|
1652
|
+
children: sure
|
|
1653
|
+
}),
|
|
1654
|
+
over.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1655
|
+
" ",
|
|
1656
|
+
"· ",
|
|
1657
|
+
/* @__PURE__ */ jsx("b", { children: over.map((x) => x.name).join(", ") }),
|
|
1658
|
+
" past capacity"
|
|
1659
|
+
] })
|
|
1660
|
+
] })
|
|
1661
|
+
}),
|
|
1662
|
+
open && verdict && /* @__PURE__ */ jsx("button", {
|
|
1663
|
+
type: "button",
|
|
1664
|
+
className: "lm-link",
|
|
1665
|
+
onClick: (e) => open("verdict", e.currentTarget),
|
|
1666
|
+
children: "Why ›"
|
|
1667
|
+
}),
|
|
1668
|
+
open && assumptions && /* @__PURE__ */ jsxs("button", {
|
|
1669
|
+
type: "button",
|
|
1670
|
+
className: "lm-link",
|
|
1671
|
+
onClick: (e) => open("assumptions", e.currentTarget),
|
|
1672
|
+
children: [
|
|
1673
|
+
"What this assumes · ",
|
|
1674
|
+
ev.assumptions.length + extra,
|
|
1675
|
+
estimated > 0 && ` (${estimated} estimated)`,
|
|
1676
|
+
" ›"
|
|
1677
|
+
]
|
|
1678
|
+
})
|
|
1679
|
+
] });
|
|
1680
|
+
}
|
|
1681
|
+
/** The order of the cards in the dock: what the reader changes first, what it changes next to it. */
|
|
1682
|
+
const DOCK = [
|
|
1683
|
+
"controls",
|
|
1684
|
+
"live",
|
|
1685
|
+
"limits",
|
|
1686
|
+
"headroom",
|
|
1687
|
+
"compare"
|
|
1688
|
+
];
|
|
1689
|
+
/**
|
|
1690
|
+
* Full screen's panels, compact, side by side in a box the screen sizes: what does not fit is left out whole, and
|
|
1691
|
+
* each card opens its panel whole. A phone shows one at a time, under tabs.
|
|
1692
|
+
*/
|
|
1693
|
+
function Dock({ lm, panels, open }) {
|
|
1694
|
+
const shown = DOCK.filter((p) => panels.includes(p));
|
|
1695
|
+
const [tab, setTab] = useState(null);
|
|
1696
|
+
if (!shown.length) return null;
|
|
1697
|
+
const active = tab && shown.includes(tab) ? tab : shown[0];
|
|
1698
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1699
|
+
className: "lm-dock",
|
|
1700
|
+
children: [/* @__PURE__ */ jsx("fieldset", {
|
|
1701
|
+
className: "lm-tabs",
|
|
1702
|
+
"aria-label": "Panels",
|
|
1703
|
+
children: shown.map((p) => /* @__PURE__ */ jsx("button", {
|
|
1704
|
+
type: "button",
|
|
1705
|
+
"aria-pressed": p === active,
|
|
1706
|
+
onClick: () => setTab(p),
|
|
1707
|
+
children: NAMES[p]
|
|
1708
|
+
}, p))
|
|
1709
|
+
}), shown.map((p) => /* @__PURE__ */ jsx(Card, {
|
|
1710
|
+
lm,
|
|
1711
|
+
panel: p,
|
|
1712
|
+
open,
|
|
1713
|
+
active: p === active
|
|
1714
|
+
}, p))]
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
function Card({ lm, panel, open, active }) {
|
|
1718
|
+
const box = useRef(null);
|
|
1719
|
+
const more = useRef(null);
|
|
1720
|
+
useClip(box, more);
|
|
1721
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1722
|
+
className: "lm-mini",
|
|
1723
|
+
"data-mini": panel,
|
|
1724
|
+
"data-active": active || void 0,
|
|
1725
|
+
ref: box,
|
|
1726
|
+
children: [panel === "controls" ? /* @__PURE__ */ jsx(Controls, { lm }) : panel === "compare" ? /* @__PURE__ */ jsx(Compare, { lm }) : /* @__PURE__ */ jsx("div", {
|
|
1727
|
+
className: "lm-card",
|
|
1728
|
+
children: panel === "live" ? /* @__PURE__ */ jsx(Meters, { lm }) : panel === "limits" ? /* @__PURE__ */ jsx(MiniLimits, { lm }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("h3", { children: "Headroom" }), /* @__PURE__ */ jsx(Sparkline, { lm })] })
|
|
1729
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1730
|
+
type: "button",
|
|
1731
|
+
className: "lm-more",
|
|
1732
|
+
ref: more,
|
|
1733
|
+
"aria-label": `${NAMES[panel]}, all of it`,
|
|
1734
|
+
onClick: (e) => open(panel, e.currentTarget),
|
|
1735
|
+
children: "›"
|
|
1736
|
+
})]
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
/** The rows a card leaves out whole when they do not fit. */
|
|
1740
|
+
const ROWS = ".lm-meter, .lm-mini-lim, .lm-controls > *, .lm-table tbody tr";
|
|
1741
|
+
/**
|
|
1742
|
+
* Hides the rows that cross the bottom of the card, and counts them on its button. Runs again when the card's size
|
|
1743
|
+
* or its rows change: the meters come and go with the load, and the order of the limits with it.
|
|
1744
|
+
*/
|
|
1745
|
+
function useClip(box, more) {
|
|
1746
|
+
useEffect(() => {
|
|
1747
|
+
const card = box.current?.querySelector(".lm-card");
|
|
1748
|
+
if (!card) return;
|
|
1749
|
+
const clip = () => {
|
|
1750
|
+
const r = card.getBoundingClientRect();
|
|
1751
|
+
const bottom = r.bottom - Number.parseFloat(getComputedStyle(card).paddingBottom || "0");
|
|
1752
|
+
let n = 0;
|
|
1753
|
+
for (const row of card.querySelectorAll(ROWS)) {
|
|
1754
|
+
const out = r.height > 0 && row.getBoundingClientRect().bottom > bottom + .5;
|
|
1755
|
+
row.toggleAttribute("data-clip", out);
|
|
1756
|
+
if (out && !row.matches("h3")) n++;
|
|
1757
|
+
}
|
|
1758
|
+
if (more.current) more.current.dataset.more = n ? `+${n}` : "";
|
|
1759
|
+
};
|
|
1760
|
+
const ro = new ResizeObserver(clip);
|
|
1761
|
+
ro.observe(card);
|
|
1762
|
+
const mo = new MutationObserver(clip);
|
|
1763
|
+
mo.observe(card, {
|
|
1764
|
+
childList: true,
|
|
1765
|
+
subtree: true
|
|
1766
|
+
});
|
|
1767
|
+
clip();
|
|
1768
|
+
return () => {
|
|
1769
|
+
ro.disconnect();
|
|
1770
|
+
mo.disconnect();
|
|
1771
|
+
};
|
|
1772
|
+
}, [box, more]);
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* The limits in their order, a line each: the name and how sure its capacity is, the bar, the utilization, where it
|
|
1776
|
+
* is full. The first is the first limit: the verdict line names it.
|
|
1777
|
+
*/
|
|
1778
|
+
function MiniLimits({ lm }) {
|
|
1779
|
+
const { ev, model } = lm;
|
|
1780
|
+
const top = Math.max(1.5, model.thresholds.full * 1.5);
|
|
1781
|
+
const at = (u) => `${u / top * 100}%`;
|
|
1782
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("h3", { children: "Where it runs out" }), /* @__PURE__ */ jsx("div", {
|
|
1783
|
+
className: "lm-mini-limits",
|
|
1784
|
+
children: ev.ranked.map((c) => /* @__PURE__ */ jsxs("div", {
|
|
1785
|
+
className: "lm-mini-lim",
|
|
1786
|
+
"data-component": c.id,
|
|
1787
|
+
children: [
|
|
1788
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1789
|
+
className: "lm-name",
|
|
1790
|
+
title: c.name,
|
|
1791
|
+
children: [c.name, c.capacity?.provenance === "estimated" ? /* @__PURE__ */ jsx("span", {
|
|
1792
|
+
className: "lm-tag",
|
|
1793
|
+
"data-kind": "estimated",
|
|
1794
|
+
children: "est"
|
|
1795
|
+
}) : !!c.capacity?.within && /* @__PURE__ */ jsx("span", {
|
|
1796
|
+
className: "lm-tag",
|
|
1797
|
+
"data-kind": "range",
|
|
1798
|
+
children: "±"
|
|
1799
|
+
})]
|
|
1800
|
+
}),
|
|
1801
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1802
|
+
className: "lm-track",
|
|
1803
|
+
role: "img",
|
|
1804
|
+
"aria-label": `${c.name} at ${c.util == null ? "off" : pct$1(c.util)}`,
|
|
1805
|
+
children: [
|
|
1806
|
+
/* @__PURE__ */ jsx("span", {
|
|
1807
|
+
className: "lm-fill",
|
|
1808
|
+
"data-state": c.state,
|
|
1809
|
+
style: { width: `${Math.min(100, (c.util ?? 0) / top * 100)}%` }
|
|
1810
|
+
}),
|
|
1811
|
+
/* @__PURE__ */ jsx("span", {
|
|
1812
|
+
className: "lm-tick",
|
|
1813
|
+
style: { left: at(model.thresholds.target) }
|
|
1814
|
+
}),
|
|
1815
|
+
/* @__PURE__ */ jsx("span", {
|
|
1816
|
+
className: "lm-tick",
|
|
1817
|
+
style: { left: at(model.thresholds.full) }
|
|
1818
|
+
})
|
|
1819
|
+
]
|
|
1820
|
+
}),
|
|
1821
|
+
/* @__PURE__ */ jsx("span", {
|
|
1822
|
+
className: "lm-val",
|
|
1823
|
+
children: c.util == null ? "—" : pct$1(c.util)
|
|
1824
|
+
}),
|
|
1825
|
+
/* @__PURE__ */ jsx("span", {
|
|
1826
|
+
className: "lm-val lm-sub",
|
|
1827
|
+
children: c.util == null ? "off" : c.full != null && !Number.isFinite(c.full) ? `full > ${fmt$1(model.searchMax)}×` : `full ${c.fullRange ? multiples(c.fullRange, model.searchMax, true) : multiple$1(c.full, model.searchMax)}`
|
|
1828
|
+
})
|
|
1829
|
+
]
|
|
1830
|
+
}, c.id))
|
|
1831
|
+
})] });
|
|
1832
|
+
}
|
|
1833
|
+
/** The headroom chart as a sparkline: each scenario's line, the target, the load; where the shown one crosses it. */
|
|
1834
|
+
function Sparkline({ lm }) {
|
|
1835
|
+
const { model, values } = lm;
|
|
1836
|
+
const h = useHeadroom(lm);
|
|
1837
|
+
const [box, { width: W, height: H }] = useSize(240);
|
|
1838
|
+
const top = Math.max(1.5, model.thresholds.full * 1.5);
|
|
1839
|
+
const lx = (x) => W * Math.log(x / h.from) / Math.log(h.to / h.from);
|
|
1840
|
+
const ly = (u) => 2 + (H - 4) * (1 - Math.min(u, top) / top);
|
|
1841
|
+
const path = (s) => {
|
|
1842
|
+
let d = "";
|
|
1843
|
+
let pen = false;
|
|
1844
|
+
for (const [x, u] of s) {
|
|
1845
|
+
if (u == null) {
|
|
1846
|
+
pen = false;
|
|
1847
|
+
continue;
|
|
1848
|
+
}
|
|
1849
|
+
d += `${pen ? "L" : "M"}${lx(x).toFixed(1)} ${ly(u).toFixed(1)}`;
|
|
1850
|
+
pen = true;
|
|
1851
|
+
}
|
|
1852
|
+
return d;
|
|
1853
|
+
};
|
|
1854
|
+
const line = h.lines.find((l) => l.selected) ?? h.lines[0];
|
|
1855
|
+
const target = pct$1(model.thresholds.target);
|
|
1856
|
+
const reaches = line ? `${line.targetRange ? multiples(line.targetRange, model.searchMax, true) : multiple$1(line.target, model.searchMax)}` : "";
|
|
1857
|
+
const when = line ? whenRange(model, line.targetRange) : "";
|
|
1858
|
+
const loadX = lx(Math.min(h.to, Math.max(h.from, values.load)));
|
|
1859
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
1860
|
+
className: "lm-spark",
|
|
1861
|
+
ref: box,
|
|
1862
|
+
children: H > 0 && /* @__PURE__ */ jsxs("svg", {
|
|
1863
|
+
width: W,
|
|
1864
|
+
height: H,
|
|
1865
|
+
"aria-hidden": "true",
|
|
1866
|
+
children: [
|
|
1867
|
+
/* @__PURE__ */ jsx("line", {
|
|
1868
|
+
className: "lm-spark-th",
|
|
1869
|
+
x1: 0,
|
|
1870
|
+
x2: W,
|
|
1871
|
+
y1: ly(model.thresholds.target),
|
|
1872
|
+
y2: ly(model.thresholds.target)
|
|
1873
|
+
}),
|
|
1874
|
+
h.lines.map((l) => /* @__PURE__ */ jsx("path", {
|
|
1875
|
+
d: path(l.envelope),
|
|
1876
|
+
fill: "none",
|
|
1877
|
+
stroke: scenarioColor(model, l.label),
|
|
1878
|
+
strokeWidth: l.selected ? 2 : 1.25
|
|
1879
|
+
}, l.label ?? "")),
|
|
1880
|
+
/* @__PURE__ */ jsx("line", {
|
|
1881
|
+
className: "lm-spark-load",
|
|
1882
|
+
x1: loadX,
|
|
1883
|
+
x2: loadX,
|
|
1884
|
+
y1: 0,
|
|
1885
|
+
y2: H
|
|
1886
|
+
})
|
|
1887
|
+
]
|
|
1888
|
+
})
|
|
1889
|
+
}), line && /* @__PURE__ */ jsxs("p", {
|
|
1890
|
+
className: "lm-spark-text",
|
|
1891
|
+
title: `${line.label ?? "It"} reaches the ${target} target at ${reaches}`,
|
|
1892
|
+
children: [
|
|
1893
|
+
line.label ?? "It",
|
|
1894
|
+
" reaches the ",
|
|
1895
|
+
target,
|
|
1896
|
+
" target at ",
|
|
1897
|
+
reaches,
|
|
1898
|
+
when && ` (${when})`,
|
|
1899
|
+
"."
|
|
1900
|
+
]
|
|
1901
|
+
})] });
|
|
1902
|
+
}
|
|
1527
1903
|
// src/story.tsx
|
|
1528
1904
|
/**
|
|
1529
|
-
* The model's story, a step at a time: the step's text, where it is, back and next. ← and → move through it
|
|
1530
|
-
* the bar has the keyboard focus (the sliders keep their own arrows).
|
|
1905
|
+
* The model's story, a step at a time: the step's text, where it is, play, back and next. ← and → move through it
|
|
1906
|
+
* while the bar has the keyboard focus (the sliders keep their own arrows). The text keeps the room of the longest
|
|
1907
|
+
* step, so stepping through it never moves what is below.
|
|
1531
1908
|
*/
|
|
1532
1909
|
function Story({ lm }) {
|
|
1533
1910
|
const bar = useRef(null);
|
|
1534
1911
|
const { story } = lm.model;
|
|
1535
1912
|
if (!story.length) return null;
|
|
1536
1913
|
const i = lm.step;
|
|
1537
|
-
const step = i == null ? null : story[i];
|
|
1538
1914
|
const last = story.length - 1;
|
|
1539
1915
|
const go = (to) => {
|
|
1540
1916
|
const next = Math.max(0, Math.min(last, to));
|
|
@@ -1546,29 +1922,63 @@ function Story({ lm }) {
|
|
|
1546
1922
|
else return;
|
|
1547
1923
|
e.preventDefault();
|
|
1548
1924
|
};
|
|
1925
|
+
const playing = lm.storyPlaying;
|
|
1549
1926
|
return /* @__PURE__ */ jsxs("fieldset", {
|
|
1550
1927
|
className: "lm-story",
|
|
1551
1928
|
onKeyDown: keys,
|
|
1552
1929
|
ref: bar,
|
|
1553
1930
|
tabIndex: -1,
|
|
1931
|
+
"data-playing": playing || void 0,
|
|
1554
1932
|
children: [
|
|
1555
1933
|
/* @__PURE__ */ jsx("legend", { children: "Story" }),
|
|
1556
|
-
/* @__PURE__ */ jsx("
|
|
1934
|
+
/* @__PURE__ */ jsx("span", {
|
|
1935
|
+
className: "lm-sr",
|
|
1557
1936
|
"aria-live": "polite",
|
|
1558
|
-
children:
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1937
|
+
children: i == null ? `A walk through this model in ${story.length} steps.` : `${i + 1} of ${story.length}. ${story[i].text}${lm.stepChanged ? " You changed the values since." : ""}`
|
|
1938
|
+
}),
|
|
1939
|
+
/* @__PURE__ */ jsxs("p", {
|
|
1940
|
+
"aria-hidden": "true",
|
|
1941
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
1942
|
+
"data-shown": i == null || void 0,
|
|
1943
|
+
children: [
|
|
1944
|
+
"A walk through this model in ",
|
|
1945
|
+
story.length,
|
|
1946
|
+
" steps."
|
|
1947
|
+
]
|
|
1948
|
+
}), story.map((st, k) => /* @__PURE__ */ jsxs("span", {
|
|
1949
|
+
"data-shown": k === i || void 0,
|
|
1950
|
+
children: [
|
|
1951
|
+
/* @__PURE__ */ jsxs("b", { children: [
|
|
1952
|
+
k + 1,
|
|
1953
|
+
" of ",
|
|
1954
|
+
story.length
|
|
1955
|
+
] }),
|
|
1956
|
+
" ",
|
|
1957
|
+
st.text,
|
|
1958
|
+
/* @__PURE__ */ jsx("em", {
|
|
1959
|
+
"data-shown": k === i && lm.stepChanged || void 0,
|
|
1960
|
+
children: " You changed the values since."
|
|
1961
|
+
})
|
|
1962
|
+
]
|
|
1963
|
+
}, k))]
|
|
1964
|
+
}),
|
|
1965
|
+
i != null && /* @__PURE__ */ jsx("span", {
|
|
1966
|
+
className: "lm-story-progress",
|
|
1967
|
+
"aria-hidden": "true",
|
|
1968
|
+
children: story.map((st, k) => /* @__PURE__ */ jsx("i", {
|
|
1969
|
+
"data-state": k < i ? "done" : k === i ? "now" : void 0,
|
|
1970
|
+
style: k === i ? { "--lm-step": `${st.seconds}s` } : void 0
|
|
1971
|
+
}, k === i ? `${k}-${playing}` : k))
|
|
1568
1972
|
}),
|
|
1569
1973
|
/* @__PURE__ */ jsxs("span", {
|
|
1570
1974
|
className: "lm-story-nav",
|
|
1571
1975
|
children: [
|
|
1976
|
+
/* @__PURE__ */ jsx("button", {
|
|
1977
|
+
type: "button",
|
|
1978
|
+
onClick: () => lm.setStoryPlaying(!playing),
|
|
1979
|
+
"aria-pressed": playing,
|
|
1980
|
+
children: playing ? "❚❚ Pause" : "▶ Play"
|
|
1981
|
+
}),
|
|
1572
1982
|
i != null && /* @__PURE__ */ jsx("button", {
|
|
1573
1983
|
type: "button",
|
|
1574
1984
|
onClick: () => go(i - 1),
|
|
@@ -1635,39 +2045,128 @@ const LOADMAP_CSS = `
|
|
|
1635
2045
|
.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }
|
|
1636
2046
|
.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }
|
|
1637
2047
|
|
|
1638
|
-
/* full screen (the browser's, or a fixed overlay):
|
|
1639
|
-
|
|
2048
|
+
/* full screen (the browser's, or a fixed overlay): a column that never scrolls. The diagram as wide as the screen on
|
|
2049
|
+
top; under it the verdict in a line and the panels, compact, in a dock the screen sizes. The load changes what is
|
|
2050
|
+
in them, never their size, so it never moves the board. Focus: the diagram, the story, the verdict and the load */
|
|
1640
2051
|
.lm-side, .lm-card > .lm-panel { display: contents; }
|
|
1641
2052
|
.lm-panel { display: grid; gap: 14px; min-width: 0; }
|
|
1642
|
-
.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; overflow:
|
|
2053
|
+
.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; overflow: hidden; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; position: relative; }
|
|
1643
2054
|
.lm[data-full="overlay"] { position: fixed; inset: 0; z-index: 2147483000; width: auto; max-width: none; max-height: none; margin: 0; border: 0; }
|
|
1644
|
-
|
|
1645
|
-
.lm[data-full]:has(> .lm-side) { grid-auto-rows: max-content; }
|
|
2055
|
+
.lm[data-full] > * { flex: none; }
|
|
1646
2056
|
/* a page of its own keeps the rest outside full screen, as <Loadmap> does */
|
|
1647
|
-
.lm[data-full]:
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
.lm[data-full] .lm-wrap {
|
|
1651
|
-
|
|
2057
|
+
.lm[data-full] > :not(.lm-head, h2, .lm-scenarios, .lm-story, .lm-wrap, .lm-line, .lm-dock, .lm-side) { display: none; }
|
|
2058
|
+
.lm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; min-width: 0; }
|
|
2059
|
+
.lm-head h2 { font-size: 1.1rem; }
|
|
2060
|
+
.lm[data-full] .lm-wrap { gap: 6px; }
|
|
2061
|
+
/* the board as large as fits (--lm-fit, from Diagram), left under the bar, so the legend starts where the board does */
|
|
1652
2062
|
.lm[data-full] .lm-board { width: var(--lm-fit, 100%); margin: 0; align-self: start; justify-self: start; }
|
|
1653
|
-
.lm-
|
|
1654
|
-
.lm
|
|
2063
|
+
.lm-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
|
|
2064
|
+
.lm-modes { display: inline-flex; margin: 0; padding: 0; min-width: 0; border: 1px solid var(--lm-line); border-radius: 6px; overflow: hidden; }
|
|
2065
|
+
.lm-modes button { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 0; padding: 6px 12px; cursor: pointer; }
|
|
2066
|
+
.lm-modes button[aria-pressed="true"] { background: var(--lm-fg); color: var(--lm-surface); }
|
|
2067
|
+
.lm[data-full] .lm-story { padding: 6px 12px; }
|
|
1655
2068
|
.lm[data-full] [data-out] { display: none; }
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
.lm[data-
|
|
1659
|
-
.lm[data-
|
|
1660
|
-
.lm
|
|
2069
|
+
|
|
2070
|
+
.lm-line { display: flex; align-items: center; gap: 6px 14px; min-width: 0; padding: 6px 12px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }
|
|
2071
|
+
.lm-line[data-tier="warn"] { border-color: var(--lm-warn); }
|
|
2072
|
+
.lm-line[data-tier="over"] { border-color: var(--lm-drop); }
|
|
2073
|
+
.lm-headline { flex: 1 1 auto; min-width: 0; margin: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
2074
|
+
.lm-num { font: 600 .95em var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
2075
|
+
.lm-link { font: 500 .8rem var(--lm-font); color: var(--lm-accent); background: none; border: 0; padding: 2px 4px; cursor: pointer; white-space: nowrap; }
|
|
2076
|
+
.lm-line .lm-range { flex: 0 1 380px; display: grid; grid-template-columns: auto minmax(100px, 1fr); align-items: center; gap: 10px; font-size: .84rem; }
|
|
2077
|
+
.lm-line output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
2078
|
+
.lm-line input[type=range] { width: 100%; accent-color: var(--lm-accent); }
|
|
2079
|
+
|
|
2080
|
+
.lm-dock { display: flex; gap: 10px; min-width: 0; }
|
|
2081
|
+
.lm[data-full] > .lm-dock { flex: 1 1 0; min-height: clamp(200px, 26dvh, 340px); }
|
|
2082
|
+
.lm-tabs { display: none; margin: 0; padding: 0; border: 0; min-width: 0; }
|
|
2083
|
+
.lm-mini { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; display: grid; container-type: inline-size; }
|
|
2084
|
+
.lm-mini[data-mini="controls"] { flex-grow: 1.25; }
|
|
2085
|
+
.lm-mini[data-mini="limits"] { flex-grow: 1.45; }
|
|
2086
|
+
.lm-mini[data-mini="live"] { flex-grow: .8; }
|
|
2087
|
+
.lm-mini[data-mini="headroom"] { flex-grow: .9; }
|
|
2088
|
+
.lm-mini[data-mini="compare"] { flex-grow: 1.3; }
|
|
2089
|
+
.lm-mini > .lm-card { min-height: 0; overflow: hidden; padding: 10px 12px; gap: 6px; align-content: start; }
|
|
2090
|
+
.lm-mini [data-clip] { visibility: hidden; }
|
|
2091
|
+
.lm-more { position: absolute; top: 6px; right: 6px; font: 500 .8rem var(--lm-font); color: var(--lm-accent); background: var(--lm-surface); border: 0; border-radius: 4px; padding: 2px 6px; cursor: pointer; }
|
|
2092
|
+
.lm-more[data-more]:not([data-more=""])::before { content: attr(data-more) " "; }
|
|
2093
|
+
.lm-mini .lm-meters { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; }
|
|
2094
|
+
.lm-mini .lm-meter { display: flex; align-items: baseline; gap: 8px; padding: 3px 8px; }
|
|
2095
|
+
.lm-mini .lm-meter b { flex: none; font-size: .9rem; }
|
|
2096
|
+
.lm-mini .lm-meter span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2097
|
+
/* one grid for every row, so the bars line up whatever the names */
|
|
2098
|
+
.lm-mini-limits { display: grid; grid-template-columns: minmax(0, max-content) minmax(48px, 1fr) auto auto; gap: 6px 10px; }
|
|
2099
|
+
.lm-mini-lim { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; font-size: .8rem; }
|
|
2100
|
+
.lm-mini-lim .lm-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
2101
|
+
.lm-mini-lim .lm-tag { margin-left: 5px; }
|
|
2102
|
+
.lm-mini-lim .lm-track { height: 9px; }
|
|
2103
|
+
.lm-mini-lim .lm-val { white-space: nowrap; }
|
|
2104
|
+
.lm-mini-lim .lm-sub { font: 400 .74rem var(--lm-mono); color: var(--lm-muted); }
|
|
2105
|
+
.lm-mini .lm-controls { gap: 6px; column-gap: 16px; }
|
|
2106
|
+
.lm-mini .lm-controls small, .lm-mini .lm-controls > h3:not(:first-child) { display: none; }
|
|
2107
|
+
.lm-mini .lm-controls label.lm-range { grid-template-columns: minmax(0, 1fr) minmax(90px, 1.2fr); align-items: center; gap: 10px; font-size: .8rem; }
|
|
2108
|
+
.lm-mini .lm-select { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: .8rem; }
|
|
2109
|
+
.lm-mini .lm-select select { width: auto; padding: 1px 6px; font-size: .78rem; }
|
|
2110
|
+
.lm-mini .lm-switch { font-size: .8rem; }
|
|
2111
|
+
.lm-mini .lm-switch input { margin-top: 2px; }
|
|
2112
|
+
.lm-mini .lm-presets { gap: 4px; }
|
|
2113
|
+
.lm-mini .lm-presets button { padding: 2px 8px; font-size: .72rem; }
|
|
2114
|
+
@container (min-width: 420px) {
|
|
2115
|
+
.lm-mini .lm-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
2116
|
+
.lm-mini .lm-controls > :is(h3, .lm-presets), .lm-mini .lm-controls > h3 + .lm-range { grid-column: 1 / -1; }
|
|
2117
|
+
}
|
|
2118
|
+
.lm-mini .lm-compare > :not(h3:first-child, .lm-table-wrap:nth-child(3)) { display: none; }
|
|
2119
|
+
.lm-mini .lm-table { font-size: .76rem; }
|
|
2120
|
+
.lm-mini .lm-table th, .lm-mini .lm-table td { padding: 3px 8px 3px 0; }
|
|
2121
|
+
.lm-mini .lm-table small { display: none; }
|
|
2122
|
+
.lm-mini .lm-table thead th { white-space: nowrap; font-size: .6rem; }
|
|
2123
|
+
.lm-mini > .lm-card:has(> .lm-spark) { grid-template-rows: auto minmax(0, 1fr) auto; align-content: stretch; }
|
|
2124
|
+
.lm-spark { position: relative; min-height: 0; }
|
|
2125
|
+
.lm-spark svg { position: absolute; inset: 0; display: block; overflow: visible; }
|
|
2126
|
+
.lm-spark-th { stroke: var(--lm-muted); stroke-dasharray: 4 3; }
|
|
2127
|
+
.lm-spark-load { stroke: var(--lm-fg); opacity: .45; }
|
|
2128
|
+
.lm-spark-text { margin: 0; font-size: .76rem; color: var(--lm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
2129
|
+
|
|
2130
|
+
/* the drawer: the page's own panel, alone, over the right of the board */
|
|
2131
|
+
.lm[data-full] > .lm-drawer:not([data-drawer]) { display: none; }
|
|
2132
|
+
.lm[data-full] > .lm-drawer[data-drawer] { display: grid; gap: 14px; align-content: start; position: absolute; top: 16px; right: 16px; bottom: 16px; z-index: 4; width: min(640px, calc(100% - 32px)); overflow: auto; overscroll-behavior: contain; padding: 14px; background: var(--lm-bg); border: 1px solid var(--lm-line); border-radius: 10px; box-shadow: -8px 0 30px rgb(0 0 0 / .2); container-type: inline-size; }
|
|
2133
|
+
.lm-side[data-drawer] :is(.lm-panel, .lm-strip, .lm-charts, .lm-card):not([data-drawn]):not(.lm-panel *) { display: none; }
|
|
2134
|
+
.lm-side[data-drawer] .lm-strip { grid-template-columns: minmax(0, 1fr); }
|
|
2135
|
+
.lm-drawer-bar { display: flex; justify-content: flex-end; }
|
|
2136
|
+
|
|
2137
|
+
/* a page of its own: its .lm-side is a box under the board that scrolls on its own, the board as large as leaves it a
|
|
2138
|
+
third of the screen */
|
|
2139
|
+
.lm[data-full] > .lm-side:not(.lm-drawer) { display: grid; gap: 14px; align-content: start; flex: 1 1 0; min-height: 33dvh; overflow: auto; overscroll-behavior: contain; container-type: inline-size; }
|
|
2140
|
+
|
|
2141
|
+
/* focus: the board and what runs on it in the middle of the screen */
|
|
2142
|
+
.lm[data-mode="focus"] .lm-scenarios, .lm[data-mode="focus"] > .lm-side:not(.lm-drawer) { display: none; }
|
|
2143
|
+
.lm[data-mode="focus"] > .lm-wrap { margin-top: auto; }
|
|
2144
|
+
.lm[data-mode="focus"] > :is(.lm-story, .lm-line) { order: 1; }
|
|
2145
|
+
.lm[data-mode="focus"]::after { content: ""; order: 2; margin-top: auto; }
|
|
2146
|
+
.lm[data-mode="focus"] > .lm-story { border-left-width: 4px; padding: 10px 14px; }
|
|
2147
|
+
.lm[data-mode="focus"] > .lm-story p { font-size: 1.1rem; }
|
|
2148
|
+
|
|
1661
2149
|
@media (max-width: 760px) {
|
|
1662
|
-
.lm[data-full]
|
|
1663
|
-
/*
|
|
1664
|
-
|
|
2150
|
+
.lm[data-full] { padding: 10px; gap: 8px; }
|
|
2151
|
+
/* the page has the title, and the legend: here they would leave the diagram no room */
|
|
2152
|
+
.lm[data-full] > h2, .lm[data-full] :is(.lm-head h2, .lm-legend, .lm-story legend) { display: none; }
|
|
2153
|
+
/* the one exception: here the diagram runs top to bottom, and shrunk to the screen it is too small to read, so it
|
|
2154
|
+
pans in a box of its own with the bar on top. The page never scrolls */
|
|
1665
2155
|
.lm[data-full] .lm-board { width: 100%; }
|
|
1666
|
-
.lm[data-full]
|
|
1667
|
-
.lm[data-
|
|
1668
|
-
|
|
1669
|
-
.lm[data-full] .lm-
|
|
1670
|
-
.lm[data-full] .lm-
|
|
2156
|
+
.lm[data-full] > .lm-wrap { height: 40dvh; overflow: auto; row-gap: 0; overscroll-behavior: contain; }
|
|
2157
|
+
.lm[data-mode="focus"] > .lm-wrap { height: auto; flex: 1 1 0; min-height: 0; margin-top: 0; }
|
|
2158
|
+
.lm[data-full] .lm-bar { position: sticky; top: 0; z-index: 1; padding-bottom: 8px; background: var(--lm-bg); }
|
|
2159
|
+
.lm[data-full] .lm-line { flex-wrap: wrap; }
|
|
2160
|
+
.lm[data-full] > .lm-story { padding: 6px 10px; gap: 6px 10px; }
|
|
2161
|
+
.lm[data-full] > .lm-story p { font-size: .84rem; }
|
|
2162
|
+
.lm[data-full] .lm-story button { padding: 4px 10px; }
|
|
2163
|
+
.lm[data-full] .lm-headline { flex-basis: 100%; }
|
|
2164
|
+
.lm-dock { flex-direction: column; min-height: 0; gap: 6px; }
|
|
2165
|
+
.lm-tabs { display: flex; flex: none; gap: 2px; border-bottom: 1px solid var(--lm-line); overflow: hidden; }
|
|
2166
|
+
.lm-tabs button { font: 500 .78rem var(--lm-font); color: var(--lm-muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 8px; cursor: pointer; white-space: nowrap; }
|
|
2167
|
+
.lm-tabs button[aria-pressed="true"] { color: var(--lm-fg); border-color: var(--lm-fg); }
|
|
2168
|
+
.lm-mini:not([data-active]) { display: none; }
|
|
2169
|
+
.lm[data-full] > .lm-side[data-drawer] { inset: 8px; width: auto; }
|
|
1671
2170
|
}
|
|
1672
2171
|
|
|
1673
2172
|
.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }
|
|
@@ -1733,7 +2232,15 @@ const LOADMAP_CSS = `
|
|
|
1733
2232
|
.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }
|
|
1734
2233
|
.lm-story { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; min-width: 0; padding: 8px 12px; border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-accent); border-radius: 6px; background: var(--lm-surface); }
|
|
1735
2234
|
.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }
|
|
1736
|
-
.lm-story p { flex: 1 1 240px; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }
|
|
2235
|
+
.lm-story p { flex: 1 1 240px; display: grid; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }
|
|
2236
|
+
.lm-story p > span { grid-area: 1 / 1; }
|
|
2237
|
+
.lm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
2238
|
+
.lm-story p > span:not([data-shown]), .lm-story em:not([data-shown]) { visibility: hidden; }
|
|
2239
|
+
.lm-story-progress { display: flex; align-items: center; gap: 4px; }
|
|
2240
|
+
.lm-story-progress i { position: relative; width: 28px; height: 4px; border-radius: 2px; background: var(--lm-line); overflow: hidden; }
|
|
2241
|
+
.lm-story-progress i[data-state="done"], .lm-story:not([data-playing]) .lm-story-progress i[data-state="now"] { background: var(--lm-accent); }
|
|
2242
|
+
.lm-story[data-playing] .lm-story-progress i[data-state="now"]::before { content: ""; position: absolute; inset: 0; background: var(--lm-accent); transform-origin: left; animation: lm-step var(--lm-step) linear both; }
|
|
2243
|
+
@keyframes lm-step { from { transform: scaleX(0); } to { transform: scaleX(1); } }
|
|
1737
2244
|
.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }
|
|
1738
2245
|
.lm-story-nav { display: flex; gap: 6px; }
|
|
1739
2246
|
.lm-story em { color: var(--lm-muted); }
|
|
@@ -1765,7 +2272,10 @@ const LOADMAP_CSS = `
|
|
|
1765
2272
|
.lm-node { cursor: pointer; outline: none; }
|
|
1766
2273
|
.lm-node:focus-visible > :first-child { stroke-width: 3; }
|
|
1767
2274
|
|
|
1768
|
-
@media (prefers-reduced-motion: reduce) {
|
|
2275
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2276
|
+
.lm-fill { transition: none; }
|
|
2277
|
+
.lm-story[data-playing] .lm-story-progress i[data-state="now"]::before { animation: none; transform: none; }
|
|
2278
|
+
}
|
|
1769
2279
|
`;
|
|
1770
2280
|
/** Adds the stylesheet once per document. */
|
|
1771
2281
|
function injectStyles(doc = document) {
|
|
@@ -1857,9 +2367,9 @@ const TOKENS = [
|
|
|
1857
2367
|
/** The stroke of a hollow dot, in scene units. */
|
|
1858
2368
|
const RING = 1.4;
|
|
1859
2369
|
/**
|
|
1860
|
-
* Everything that moves, without React: the sim, the dots on the canvas
|
|
1861
|
-
*
|
|
1862
|
-
* by frame instead of the animation loop.
|
|
2370
|
+
* Everything that moves, without React: the sim, the dots on the canvas, the worker fills in the SVG, and the move from
|
|
2371
|
+
* one structure to the next. React renders the structure once per scene, and once per frame while it moves; the engine
|
|
2372
|
+
* updates the moving parts every frame, and export drives it frame by frame instead of the animation loop.
|
|
1863
2373
|
*/
|
|
1864
2374
|
var Engine = class {
|
|
1865
2375
|
model;
|
|
@@ -1867,6 +2377,13 @@ var Engine = class {
|
|
|
1867
2377
|
sim;
|
|
1868
2378
|
ev;
|
|
1869
2379
|
scene = null;
|
|
2380
|
+
/** What the diagram draws now: the scene, or a frame of the move to it. */
|
|
2381
|
+
frame = null;
|
|
2382
|
+
/** Counts the frames: export waits until the diagram drew this one. */
|
|
2383
|
+
frameId = 0;
|
|
2384
|
+
drawnFrame = -1;
|
|
2385
|
+
/** Seconds a new structure takes to move in; 0 cuts. */
|
|
2386
|
+
transition = .8;
|
|
1870
2387
|
/** The structure key the current values want; `scene.key` catches up once the layout is done. */
|
|
1871
2388
|
wantKey = "";
|
|
1872
2389
|
/** The values React last drew labels and colours for; a frame is complete once they match `ev.values`. */
|
|
@@ -1883,6 +2400,15 @@ var Engine = class {
|
|
|
1883
2400
|
#o;
|
|
1884
2401
|
#slots = [];
|
|
1885
2402
|
#paths = /* @__PURE__ */ new Map();
|
|
2403
|
+
#move = null;
|
|
2404
|
+
#listeners = /* @__PURE__ */ new Set();
|
|
2405
|
+
/** The last steps came while paused: export drives a paused engine, a page that only paused it does not. */
|
|
2406
|
+
#driven = false;
|
|
2407
|
+
/** While the structure moves, each leg's path in this frame, shared by the dots on it. */
|
|
2408
|
+
#legs = {
|
|
2409
|
+
frame: -1,
|
|
2410
|
+
paths: /* @__PURE__ */ new Map()
|
|
2411
|
+
};
|
|
1886
2412
|
constructor(model, view, ev, o = {}) {
|
|
1887
2413
|
this.model = model;
|
|
1888
2414
|
this.view = view;
|
|
@@ -1896,20 +2422,49 @@ var Engine = class {
|
|
|
1896
2422
|
this.ev = ev;
|
|
1897
2423
|
if (!same) this.sim.update(ev);
|
|
1898
2424
|
}
|
|
1899
|
-
|
|
2425
|
+
/**
|
|
2426
|
+
* Takes a new scene. A new structure moves in from what is drawn now, unless `cut`, the diagram turned (a new
|
|
2427
|
+
* direction is a new screen size, not a new design), or it is paused with nothing stepping it; the first scene just
|
|
2428
|
+
* shows.
|
|
2429
|
+
*/
|
|
2430
|
+
setScene(scene, o = {}) {
|
|
1900
2431
|
if (scene === this.scene) return;
|
|
2432
|
+
const from = this.frame;
|
|
2433
|
+
const seconds = this.transition;
|
|
1901
2434
|
this.scene = scene;
|
|
1902
2435
|
this.#paths.clear();
|
|
2436
|
+
const move = from && !o.cut && seconds > 0 && Number.isFinite(seconds) && (!this.paused || this.#driven) && from.direction === scene.direction && from.key !== scene.key;
|
|
2437
|
+
this.#move = move ? {
|
|
2438
|
+
at: morph(from, scene),
|
|
2439
|
+
t: 0,
|
|
2440
|
+
seconds
|
|
2441
|
+
} : null;
|
|
2442
|
+
this.#show(move ? this.#move.at(0) : scene);
|
|
2443
|
+
}
|
|
2444
|
+
/** Calls `f` whenever the frame changes; returns a function that stops it. */
|
|
2445
|
+
subscribe = (f) => {
|
|
2446
|
+
this.#listeners.add(f);
|
|
2447
|
+
return () => this.#listeners.delete(f);
|
|
2448
|
+
};
|
|
2449
|
+
#show(frame) {
|
|
2450
|
+
this.frame = frame;
|
|
2451
|
+
this.frameId++;
|
|
2452
|
+
for (const f of this.#listeners) f();
|
|
1903
2453
|
}
|
|
1904
|
-
/** Starts the sim over from empty queues, with this seed (default: the original one). */
|
|
2454
|
+
/** Starts the sim over from empty queues, with this seed (default: the original one), and ends a move. */
|
|
1905
2455
|
reset(seed) {
|
|
1906
2456
|
this.sim = createSim(this.model, this.ev, {
|
|
1907
2457
|
...this.#o,
|
|
1908
2458
|
seed: seed ?? this.#o.seed
|
|
1909
2459
|
});
|
|
1910
2460
|
this.#paths.clear();
|
|
2461
|
+
if (this.#move && this.scene) {
|
|
2462
|
+
this.#move = null;
|
|
2463
|
+
this.#show(this.scene);
|
|
2464
|
+
}
|
|
1911
2465
|
}
|
|
1912
2466
|
bind(svg, canvas) {
|
|
2467
|
+
const fresh = canvas !== this.canvas;
|
|
1913
2468
|
this.svg = svg;
|
|
1914
2469
|
this.canvas = canvas;
|
|
1915
2470
|
this.#slots = [];
|
|
@@ -1921,7 +2476,8 @@ var Engine = class {
|
|
|
1921
2476
|
y: Number(el.dataset.y),
|
|
1922
2477
|
s: Number(el.dataset.s)
|
|
1923
2478
|
});
|
|
1924
|
-
this.resize();
|
|
2479
|
+
if (fresh) this.resize();
|
|
2480
|
+
this.drawFills();
|
|
1925
2481
|
}
|
|
1926
2482
|
/** Reads the theme tokens from the element that carries them. Call again when the theme changes. */
|
|
1927
2483
|
readColors(root) {
|
|
@@ -1943,22 +2499,33 @@ var Engine = class {
|
|
|
1943
2499
|
const r = c.getBoundingClientRect();
|
|
1944
2500
|
if (!r.width) return;
|
|
1945
2501
|
const dpr = Math.min(2, globalThis.devicePixelRatio || 1);
|
|
1946
|
-
|
|
1947
|
-
|
|
2502
|
+
const w = Math.round(r.width * dpr);
|
|
2503
|
+
const h = Math.round(r.height * dpr);
|
|
2504
|
+
if (c.width === w && c.height === h) return;
|
|
2505
|
+
c.width = w;
|
|
2506
|
+
c.height = h;
|
|
2507
|
+
this.draw();
|
|
1948
2508
|
}
|
|
2509
|
+
/** Advances the sim, and the move to a new structure, by `dtReal` seconds. */
|
|
1949
2510
|
step(dtReal, o = {}) {
|
|
2511
|
+
this.#driven = this.paused;
|
|
1950
2512
|
this.sim.step(dtReal, o);
|
|
2513
|
+
const m = this.#move;
|
|
2514
|
+
if (!m || dtReal <= 0) return;
|
|
2515
|
+
m.t += dtReal / m.seconds;
|
|
2516
|
+
if (m.t >= 1) this.#move = null;
|
|
2517
|
+
this.#show(m.at(m.t));
|
|
1951
2518
|
}
|
|
1952
2519
|
/** Draws the dots on the overlay canvas and the worker fills in the SVG. */
|
|
1953
2520
|
draw(o = {}) {
|
|
1954
2521
|
this.drawFills();
|
|
1955
2522
|
const c = this.canvas;
|
|
1956
2523
|
const ctx = c?.getContext("2d");
|
|
1957
|
-
if (!c || !ctx || !this.
|
|
2524
|
+
if (!c || !ctx || !this.frame) return;
|
|
1958
2525
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1959
2526
|
ctx.clearRect(0, 0, c.width, c.height);
|
|
1960
2527
|
if (o.particles === false) return;
|
|
1961
|
-
this.paintParticles(ctx, c.width / this.
|
|
2528
|
+
this.paintParticles(ctx, c.width / this.frame.width);
|
|
1962
2529
|
}
|
|
1963
2530
|
drawFills() {
|
|
1964
2531
|
for (const sl of this.#slots) {
|
|
@@ -1970,7 +2537,7 @@ var Engine = class {
|
|
|
1970
2537
|
}
|
|
1971
2538
|
/** Every dot as it is drawn now, in scene units: for the canvas, and for an SVG export. */
|
|
1972
2539
|
dots() {
|
|
1973
|
-
const scene = this.
|
|
2540
|
+
const scene = this.frame;
|
|
1974
2541
|
if (!scene) return [];
|
|
1975
2542
|
const out = [];
|
|
1976
2543
|
const live = /* @__PURE__ */ new Set();
|
|
@@ -1993,7 +2560,7 @@ var Engine = class {
|
|
|
1993
2560
|
}
|
|
1994
2561
|
/** Paints the dots onto any 2D context, scene units × `scale`: the overlay, or an export frame. */
|
|
1995
2562
|
paintParticles(ctx, scale) {
|
|
1996
|
-
if (!this.
|
|
2563
|
+
if (!this.frame) return;
|
|
1997
2564
|
ctx.save();
|
|
1998
2565
|
ctx.transform(scale, 0, 0, scale, 0, 0);
|
|
1999
2566
|
for (const d of this.dots()) {
|
|
@@ -2015,6 +2582,20 @@ var Engine = class {
|
|
|
2015
2582
|
#position(scene, d) {
|
|
2016
2583
|
if (d.phase !== "move") return anchor(scene, d.to, d.flow);
|
|
2017
2584
|
const key = `${d.leg}|${d.from.stage}|${d.from.cell}|${d.to.stage}|${d.to.cell}`;
|
|
2585
|
+
if (this.#move) {
|
|
2586
|
+
const legs = this.#legs;
|
|
2587
|
+
if (legs.frame !== this.frameId) {
|
|
2588
|
+
legs.frame = this.frameId;
|
|
2589
|
+
legs.paths.clear();
|
|
2590
|
+
}
|
|
2591
|
+
const leg = `${d.flow}|${key}`;
|
|
2592
|
+
let points = legs.paths.get(leg);
|
|
2593
|
+
if (!points) {
|
|
2594
|
+
points = legPath(scene, d.from, d.to, d.flow);
|
|
2595
|
+
legs.paths.set(leg, points);
|
|
2596
|
+
}
|
|
2597
|
+
return pointAt(points, d.t / d.dur);
|
|
2598
|
+
}
|
|
2018
2599
|
let p = this.#paths.get(d.id);
|
|
2019
2600
|
if (!p || p.key !== key) {
|
|
2020
2601
|
p = {
|
|
@@ -2050,6 +2631,7 @@ function useLoadmap(model, view, o = {}) {
|
|
|
2050
2631
|
const engineRef = useRef(null);
|
|
2051
2632
|
if (!engineRef.current || engineRef.current.model !== model || engineRef.current.view !== view) engineRef.current = new Engine(model, view, ev, o);
|
|
2052
2633
|
const engine = engineRef.current;
|
|
2634
|
+
engine.transition = o.transition ?? .8;
|
|
2053
2635
|
const [root, setRoot] = useState(null);
|
|
2054
2636
|
const wide = o.direction ?? "RIGHT";
|
|
2055
2637
|
const [direction, setDirection] = useState(wide);
|
|
@@ -2157,6 +2739,89 @@ function useLoadmap(model, view, o = {}) {
|
|
|
2157
2739
|
const focus = shown && !stepChanged ? shown.focus ?? null : null;
|
|
2158
2740
|
engine.wantFocus = focus;
|
|
2159
2741
|
engine.storyStep = step;
|
|
2742
|
+
const [playing, setPlaying] = useState(false);
|
|
2743
|
+
if (playing && (step == null || stepChanged)) setPlaying(false);
|
|
2744
|
+
const storyPlaying = playing && step != null && !stepChanged;
|
|
2745
|
+
useEffect(() => {
|
|
2746
|
+
if (!storyPlaying || step == null) return;
|
|
2747
|
+
const last = model.story.length - 1;
|
|
2748
|
+
const t = setTimeout(() => step < last ? setStep(step + 1) : setPlaying(false), model.story[step].seconds * 1e3);
|
|
2749
|
+
return () => clearTimeout(t);
|
|
2750
|
+
}, [
|
|
2751
|
+
storyPlaying,
|
|
2752
|
+
step,
|
|
2753
|
+
model,
|
|
2754
|
+
setStep
|
|
2755
|
+
]);
|
|
2756
|
+
const setStoryPlaying = useCallback((on) => {
|
|
2757
|
+
if (on && (step == null || stepChanged || step === model.story.length - 1)) setStep(step == null || step === model.story.length - 1 ? 0 : step);
|
|
2758
|
+
setPlaying(on && model.story.length > 0);
|
|
2759
|
+
}, [
|
|
2760
|
+
step,
|
|
2761
|
+
stepChanged,
|
|
2762
|
+
model,
|
|
2763
|
+
setStep
|
|
2764
|
+
]);
|
|
2765
|
+
const [screen, setScreen] = useState(false);
|
|
2766
|
+
const [overlay, setOverlay] = useState(false);
|
|
2767
|
+
const fullScreen = screen || overlay;
|
|
2768
|
+
useEffect(() => {
|
|
2769
|
+
const f = () => setScreen(!!root && document.fullscreenElement === root);
|
|
2770
|
+
document.addEventListener("fullscreenchange", f);
|
|
2771
|
+
return () => document.removeEventListener("fullscreenchange", f);
|
|
2772
|
+
}, [root]);
|
|
2773
|
+
const start = o.fullScreenMode ?? "panels";
|
|
2774
|
+
const [modeState, setModeState] = useState({
|
|
2775
|
+
start,
|
|
2776
|
+
mode: start
|
|
2777
|
+
});
|
|
2778
|
+
const fullScreenMode = modeState.start === start ? modeState.mode : start;
|
|
2779
|
+
const setFullScreenMode = useCallback((mode) => setModeState({
|
|
2780
|
+
start,
|
|
2781
|
+
mode
|
|
2782
|
+
}), [start]);
|
|
2783
|
+
useEffect(() => {
|
|
2784
|
+
if (!root || !fullScreen) return;
|
|
2785
|
+
root.setAttribute("data-full", overlay ? "overlay" : "screen");
|
|
2786
|
+
const top = overlay && typeof root.showPopover === "function";
|
|
2787
|
+
if (top) {
|
|
2788
|
+
root.popover = "manual";
|
|
2789
|
+
root.showPopover();
|
|
2790
|
+
}
|
|
2791
|
+
return () => {
|
|
2792
|
+
root.removeAttribute("data-full");
|
|
2793
|
+
if (top) {
|
|
2794
|
+
root.hidePopover();
|
|
2795
|
+
root.removeAttribute("popover");
|
|
2796
|
+
}
|
|
2797
|
+
};
|
|
2798
|
+
}, [
|
|
2799
|
+
root,
|
|
2800
|
+
fullScreen,
|
|
2801
|
+
overlay
|
|
2802
|
+
]);
|
|
2803
|
+
useEffect(() => {
|
|
2804
|
+
if (!root || !fullScreen) return;
|
|
2805
|
+
root.setAttribute("data-mode", fullScreenMode);
|
|
2806
|
+
return () => root.removeAttribute("data-mode");
|
|
2807
|
+
}, [
|
|
2808
|
+
root,
|
|
2809
|
+
fullScreen,
|
|
2810
|
+
fullScreenMode
|
|
2811
|
+
]);
|
|
2812
|
+
useEffect(() => {
|
|
2813
|
+
if (!overlay) return;
|
|
2814
|
+
const f = (e) => e.key === "Escape" && setOverlay(false);
|
|
2815
|
+
document.addEventListener("keydown", f);
|
|
2816
|
+
return () => document.removeEventListener("keydown", f);
|
|
2817
|
+
}, [overlay]);
|
|
2818
|
+
const toggleFullScreen = useCallback(() => {
|
|
2819
|
+
if (!root) return;
|
|
2820
|
+
if (overlay) setOverlay(false);
|
|
2821
|
+
else if (document.fullscreenElement) document.exitFullscreen().catch(() => {});
|
|
2822
|
+
else if (root.requestFullscreen) root.requestFullscreen().catch(() => setOverlay(true));
|
|
2823
|
+
else setOverlay(true);
|
|
2824
|
+
}, [root, overlay]);
|
|
2160
2825
|
return {
|
|
2161
2826
|
model,
|
|
2162
2827
|
view,
|
|
@@ -2168,6 +2833,12 @@ function useLoadmap(model, view, o = {}) {
|
|
|
2168
2833
|
stepChanged,
|
|
2169
2834
|
setStep,
|
|
2170
2835
|
focus,
|
|
2836
|
+
storyPlaying,
|
|
2837
|
+
setStoryPlaying,
|
|
2838
|
+
fullScreen,
|
|
2839
|
+
toggleFullScreen,
|
|
2840
|
+
fullScreenMode,
|
|
2841
|
+
setFullScreenMode,
|
|
2171
2842
|
ev,
|
|
2172
2843
|
scene,
|
|
2173
2844
|
labels,
|
|
@@ -2221,7 +2892,7 @@ function LoadmapRoot({ lm, theme = "auto", children }) {
|
|
|
2221
2892
|
children
|
|
2222
2893
|
});
|
|
2223
2894
|
}
|
|
2224
|
-
/** The panels
|
|
2895
|
+
/** The panels full screen shows with the diagram, compact: the verdict and the assumptions in a line under it. */
|
|
2225
2896
|
const LOADMAP_PANELS = [
|
|
2226
2897
|
"verdict",
|
|
2227
2898
|
"live",
|
|
@@ -2240,40 +2911,110 @@ function Loadmap({ model, view, theme, title, assumptions, headroom = true, comp
|
|
|
2240
2911
|
if (headroom) charts.push("headroom");
|
|
2241
2912
|
if (side) charts.push("compare");
|
|
2242
2913
|
const out = (...panels) => panels.some((p) => fullScreen.includes(p)) ? void 0 : "";
|
|
2914
|
+
const listed = (p) => fullScreen.includes(p) && (p === "headroom" ? headroom : p !== "compare" || side);
|
|
2915
|
+
const full = lm.fullScreen;
|
|
2916
|
+
const focus = full && lm.fullScreenMode === "focus";
|
|
2917
|
+
const [drawer, setDrawer] = useState(null);
|
|
2918
|
+
if (drawer && !full) setDrawer(null);
|
|
2919
|
+
const close = useRef(null);
|
|
2920
|
+
useEffect(() => {
|
|
2921
|
+
if (drawer) close.current?.focus();
|
|
2922
|
+
}, [drawer]);
|
|
2923
|
+
const open = (p, from) => setDrawer({
|
|
2924
|
+
panel: p,
|
|
2925
|
+
from
|
|
2926
|
+
});
|
|
2927
|
+
const shut = () => {
|
|
2928
|
+
drawer?.from.focus();
|
|
2929
|
+
setDrawer(null);
|
|
2930
|
+
};
|
|
2931
|
+
useEffect(() => {
|
|
2932
|
+
if (!drawer) return;
|
|
2933
|
+
const f = (e) => {
|
|
2934
|
+
if (e.key !== "Escape") return;
|
|
2935
|
+
e.stopPropagation();
|
|
2936
|
+
drawer.from.focus();
|
|
2937
|
+
setDrawer(null);
|
|
2938
|
+
};
|
|
2939
|
+
document.addEventListener("keydown", f, true);
|
|
2940
|
+
return () => document.removeEventListener("keydown", f, true);
|
|
2941
|
+
}, [drawer]);
|
|
2942
|
+
const drawn = (...panels) => drawer && panels.includes(drawer.panel) ? "" : void 0;
|
|
2243
2943
|
const panel = (id, children) => /* @__PURE__ */ jsx("div", {
|
|
2244
2944
|
className: "lm-panel",
|
|
2245
2945
|
"data-panel": id,
|
|
2246
2946
|
"data-out": out(id),
|
|
2247
|
-
|
|
2947
|
+
"data-drawn": drawn(id),
|
|
2948
|
+
children: (!full || drawer?.panel === id) && children
|
|
2248
2949
|
});
|
|
2950
|
+
const heading = title !== false && /* @__PURE__ */ jsx("h2", { children: title ?? model.title });
|
|
2951
|
+
const verdict = listed("verdict");
|
|
2952
|
+
const line = focus ? verdict || listed("controls") : verdict || listed("assumptions");
|
|
2249
2953
|
return /* @__PURE__ */ jsxs(LoadmapRoot, {
|
|
2250
2954
|
lm,
|
|
2251
2955
|
theme,
|
|
2252
2956
|
children: [
|
|
2253
|
-
|
|
2254
|
-
|
|
2957
|
+
full ? /* @__PURE__ */ jsxs("div", {
|
|
2958
|
+
className: "lm-head",
|
|
2959
|
+
children: [heading, /* @__PURE__ */ jsx(Scenarios, { lm })]
|
|
2960
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [heading, /* @__PURE__ */ jsx(Scenarios, { lm })] }),
|
|
2255
2961
|
/* @__PURE__ */ jsx(Story, { lm }),
|
|
2256
2962
|
/* @__PURE__ */ jsx(Diagram, {
|
|
2257
2963
|
lm,
|
|
2258
2964
|
onNodeClick,
|
|
2259
2965
|
selected
|
|
2260
2966
|
}),
|
|
2967
|
+
full && line && /* @__PURE__ */ jsxs("div", {
|
|
2968
|
+
className: "lm-line",
|
|
2969
|
+
"data-tier": lm.ev.verdict.tier,
|
|
2970
|
+
children: [/* @__PURE__ */ jsx(VerdictLine, {
|
|
2971
|
+
lm,
|
|
2972
|
+
verdict,
|
|
2973
|
+
extra: assumptions?.length,
|
|
2974
|
+
open,
|
|
2975
|
+
assumptions: !focus && listed("assumptions")
|
|
2976
|
+
}), focus && listed("controls") && /* @__PURE__ */ jsx(LoadRange, { lm })]
|
|
2977
|
+
}),
|
|
2978
|
+
full && !focus && /* @__PURE__ */ jsx(Dock, {
|
|
2979
|
+
lm,
|
|
2980
|
+
panels: LOADMAP_PANELS.filter(listed),
|
|
2981
|
+
open
|
|
2982
|
+
}),
|
|
2261
2983
|
/* @__PURE__ */ jsxs("div", {
|
|
2262
|
-
className: "lm-side",
|
|
2984
|
+
className: "lm-side lm-drawer",
|
|
2263
2985
|
"data-out": out("verdict", "live", "limits", "controls", ...charts, "assumptions"),
|
|
2986
|
+
"data-drawer": drawer?.panel,
|
|
2987
|
+
...drawer && {
|
|
2988
|
+
role: "dialog",
|
|
2989
|
+
"aria-label": "The whole panel"
|
|
2990
|
+
},
|
|
2264
2991
|
children: [
|
|
2992
|
+
drawer && /* @__PURE__ */ jsx("div", {
|
|
2993
|
+
className: "lm-drawer-bar",
|
|
2994
|
+
"data-drawn": "",
|
|
2995
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
2996
|
+
type: "button",
|
|
2997
|
+
className: "lm-btn",
|
|
2998
|
+
onClick: shut,
|
|
2999
|
+
ref: close,
|
|
3000
|
+
children: "✕ Back to full screen"
|
|
3001
|
+
})
|
|
3002
|
+
}),
|
|
2265
3003
|
panel("verdict", /* @__PURE__ */ jsx(Verdict, { lm })),
|
|
2266
3004
|
charts.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
2267
3005
|
className: charts.length > 1 ? "lm-charts lm-strip" : "lm-charts",
|
|
2268
3006
|
"data-out": out(...charts),
|
|
3007
|
+
"data-drawn": drawn(...charts),
|
|
2269
3008
|
children: [headroom && panel("headroom", /* @__PURE__ */ jsx(HeadroomChart, { lm })), side && panel("compare", /* @__PURE__ */ jsx(Compare, { lm }))]
|
|
2270
3009
|
}),
|
|
2271
3010
|
/* @__PURE__ */ jsxs("div", {
|
|
2272
3011
|
className: "lm-strip lm-live",
|
|
2273
3012
|
"data-out": out("live", "limits", "controls"),
|
|
3013
|
+
"data-drawn": drawn("live", "limits", "controls"),
|
|
2274
3014
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
2275
3015
|
className: "lm-card",
|
|
2276
3016
|
"data-out": out("live", "limits"),
|
|
3017
|
+
"data-drawn": drawn("live", "limits"),
|
|
2277
3018
|
children: [panel("live", /* @__PURE__ */ jsx(Meters, { lm })), panel("limits", /* @__PURE__ */ jsx(Limits, { lm }))]
|
|
2278
3019
|
}), panel("controls", /* @__PURE__ */ jsx(Controls, { lm }))]
|
|
2279
3020
|
}),
|
|
@@ -2292,7 +3033,7 @@ function handleOf(lm) {
|
|
|
2292
3033
|
engine,
|
|
2293
3034
|
async ready(timeoutMs = 1e4) {
|
|
2294
3035
|
const t0 = performance.now();
|
|
2295
|
-
const drawn = () => engine.scene && engine.scene.key === engine.wantKey && engine.svg && engine.drawnValues === JSON.stringify(engine.ev.values) && engine.drawnFocus === engine.wantFocus;
|
|
3036
|
+
const drawn = () => engine.scene && engine.scene.key === engine.wantKey && engine.svg && engine.drawnValues === JSON.stringify(engine.ev.values) && engine.drawnFocus === engine.wantFocus && engine.drawnFrame === engine.frameId;
|
|
2296
3037
|
while (!drawn()) {
|
|
2297
3038
|
if (performance.now() - t0 > timeoutMs) throw new Error("loadmap: layout not ready");
|
|
2298
3039
|
await new Promise((r) => requestAnimationFrame(r));
|
|
@@ -2313,10 +3054,10 @@ function handleOf(lm) {
|
|
|
2313
3054
|
engine.step(dt, { particles: true });
|
|
2314
3055
|
engine.draw({ particles: true });
|
|
2315
3056
|
},
|
|
2316
|
-
board: () => engine.svg && engine.canvas && engine.
|
|
3057
|
+
board: () => engine.svg && engine.canvas && engine.frame ? {
|
|
2317
3058
|
svg: engine.svg,
|
|
2318
3059
|
canvas: engine.canvas,
|
|
2319
|
-
scene: engine.
|
|
3060
|
+
scene: engine.frame
|
|
2320
3061
|
} : null
|
|
2321
3062
|
};
|
|
2322
3063
|
}
|