@loadmap/react 0.1.1 → 0.2.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/dist/index.d.ts +17 -10
- package/dist/index.js +84 -21
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,16 @@ import { AnyNodeDef, ClusterDef, Direction, EdgeDef, ElkEngine, FlowColor, FlowV
|
|
|
5
5
|
import { ReactNode, Ref } from "react";
|
|
6
6
|
import { Particle, Sim, SimOptions } from "@loadmap/sim";
|
|
7
7
|
export * from "@loadmap/core";
|
|
8
|
+
/** A dot as it is drawn now, in scene units. */
|
|
9
|
+
interface Dot {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
r: number;
|
|
13
|
+
color: string;
|
|
14
|
+
alpha: number;
|
|
15
|
+
/** A retry: drawn as a ring of this stroke width, inside r. */
|
|
16
|
+
ring?: number;
|
|
17
|
+
}
|
|
8
18
|
/**
|
|
9
19
|
* Everything that moves, without React: the sim, the dots on the canvas and the worker fills in the SVG. React
|
|
10
20
|
* renders the structure once per scene; the engine updates the moving parts every frame, and export drives it frame
|
|
@@ -50,13 +60,7 @@ declare class Engine {
|
|
|
50
60
|
}): void;
|
|
51
61
|
drawFills(): void;
|
|
52
62
|
/** Every dot as it is drawn now, in scene units: for the canvas, and for an SVG export. */
|
|
53
|
-
dots():
|
|
54
|
-
x: number;
|
|
55
|
-
y: number;
|
|
56
|
-
r: number;
|
|
57
|
-
color: string;
|
|
58
|
-
alpha: number;
|
|
59
|
-
}[];
|
|
63
|
+
dots(): Dot[];
|
|
60
64
|
/** Paints the dots onto any 2D context, scene units × `scale`: the overlay, or an export frame. */
|
|
61
65
|
paintParticles(ctx: CanvasRenderingContext2D, scale: number): void;
|
|
62
66
|
}
|
|
@@ -162,7 +166,10 @@ export declare function Limits({ lm, title }: {
|
|
|
162
166
|
lm: LoadmapController;
|
|
163
167
|
title?: ReactNode;
|
|
164
168
|
}): import("react").JSX.Element;
|
|
165
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* Live numbers: from the sim, lag and drops per queue, busy workers, rejected requests; from the model, pods running,
|
|
171
|
+
* cache answers and retries.
|
|
172
|
+
*/
|
|
166
173
|
export declare function Meters({ lm }: {
|
|
167
174
|
lm: LoadmapController;
|
|
168
175
|
}): import("react").JSX.Element;
|
|
@@ -207,7 +214,7 @@ export declare function Story({ lm }: {
|
|
|
207
214
|
lm: LoadmapController;
|
|
208
215
|
}): import("react").JSX.Element | null;
|
|
209
216
|
/** Theme tokens and the layout of every piece. Scoped to `.lm`; override any `--lm-*` token to restyle. */
|
|
210
|
-
export declare const LOADMAP_CSS = "\n.lm { \n --lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;\n --lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;\n --lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;\n --lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;\n --lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-bg);\n display: grid; gap: 14px; padding: 16px; min-width: 0; box-sizing: border-box; }\n@media (prefers-color-scheme: dark) { .lm:not([data-theme=\"light\"]) { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; } }\n.lm[data-theme=\"dark\"] { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; }\n.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }\n.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }\n.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }\n.lm button:focus-visible, .lm input:focus-visible, .lm select:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }\n\n.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }\n.lm-wrap:fullscreen { background: var(--lm-bg); padding: 16px; align-content: center; overflow: auto; }\n.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }\n.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }\n.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }\n.lm-wrap:fullscreen .lm-board { width: auto; max-width: 100%; max-height: calc(100vh - 90px); }\n.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }\n.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }\n.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }\n.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }\n\n.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; }\n.lm-verdict[data-tier=\"warn\"] { border-color: var(--lm-warn); }\n.lm-verdict[data-tier=\"over\"] { border-color: var(--lm-drop); }\n.lm-measure { margin: 6px 0 0; padding: 0 14px; font-size: .86rem; color: var(--lm-muted); }\n\n.lm-strip { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }\n@container (max-width: 860px) { .lm-strip { grid-template-columns: minmax(0, 1fr); } }\n.lm { container-type: inline-size; }\n\n.lm-meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }\n.lm-meter { padding: 8px 10px; border-radius: 6px; background: var(--lm-bg); min-width: 0; }\n.lm-meter b { display: block; font: 500 1.15rem var(--lm-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-meter span { font-size: .74rem; color: var(--lm-muted); }\n.lm-meter[data-state=\"warn\"] b { color: var(--lm-warn); } .lm-meter[data-state=\"over\"] b { color: var(--lm-drop); }\n\n.lm-limits { display: grid; gap: 10px; }\n.lm-lim, .lm-scale { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 10rem; gap: 4px 14px; align-items: center; }\n@container (max-width: 640px) { .lm-lim, .lm-scale { grid-template-columns: minmax(0, 1fr); } .lm-scale > :first-child, .lm-scale > :last-child { display: none; } }\n.lm-lim b { display: block; font-weight: 600; font-size: .88rem; }\n.lm-lim .lm-sub { display: block; font-size: .74rem; color: var(--lm-muted); }\n.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }\n.lm-tag[data-kind=\"first\"] { color: var(--lm-surface); background: var(--lm-drop); }\n.lm-tag[data-kind=\"estimated\"] { color: var(--lm-warn); border: 1px solid currentColor; }\n.lm-tag[data-kind=\"range\"] { color: var(--lm-muted); border: 1px solid currentColor; }\n.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }\n.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }\n.lm-fill[data-state=\"warn\"] { background: var(--lm-warn); } .lm-fill[data-state=\"over\"] { background: var(--lm-drop); }\n.lm-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--lm-fg); opacity: .55; }\n.lm-val { font: 500 .8rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-val small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-scale { font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }\n.lm-scale div { position: relative; height: 12px; }\n.lm-scale div span { position: absolute; transform: translateX(-50%); white-space: nowrap; }\n\n.lm-controls label.lm-range { display: grid; gap: 4px; font-size: .84rem; }\n.lm-controls label.lm-range > span { display: flex; justify-content: space-between; gap: 8px; }\n.lm-controls output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-controls input[type=range] { width: 100%; accent-color: var(--lm-accent); }\n.lm-presets { display: flex; flex-wrap: wrap; gap: 6px; }\n.lm-presets button { font: 500 .76rem var(--lm-font); background: var(--lm-accent-soft); color: var(--lm-fg); border: 1px solid transparent; border-radius: 5px; padding: 5px 10px; cursor: pointer; }\n.lm-presets button[aria-pressed=\"true\"] { border-color: var(--lm-accent); }\n.lm-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-size: .84rem; cursor: pointer; }\n.lm-switch input { margin: 3px 0 0; accent-color: var(--lm-accent); }\n.lm-switch small, .lm-select small { grid-column: 2; color: var(--lm-muted); font-size: .74rem; line-height: 1.3; }\n.lm-select { display: grid; gap: 4px; font-size: .84rem; }\n.lm-select select { width: 100%; min-width: 0; font: 400 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 5px; padding: 5px 8px; }\n.lm-off { opacity: .45; cursor: default; }\n\n.lm-facts { margin: 0; padding-left: 1.1em; font-size: .88rem; columns: 2; column-gap: 28px; }\n@container (max-width: 860px) { .lm-facts { columns: 1; } }\n.lm-facts li { margin-bottom: 8px; break-inside: avoid; }\n.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }\n.lm-prov[data-kind=\"measured\"] { color: var(--lm-ok); } .lm-prov[data-kind=\"estimated\"] { color: var(--lm-warn); }\n\n/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */\n.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }\n.lm-scenarios legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin-right: 6px; padding: 0; }\n.lm-scenarios button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-scenarios button[aria-pressed=\"true\"] { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }\n.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }\n.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); }\n.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }\n.lm-story p { flex: 1 1 240px; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }\n.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }\n.lm-story-nav { display: flex; gap: 6px; }\n.lm-story em { color: var(--lm-muted); }\n.lm-story button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-story button[aria-disabled=\"true\"] { opacity: .45; cursor: default; }\n.lm-own { font-size: .78rem; color: var(--lm-muted); }\n.lm-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; margin-right: 6px; }\n\n.lm-compare-text { margin: 0; }\n.lm-table-wrap { overflow-x: auto; }\n.lm-table { border-collapse: collapse; width: 100%; font-size: .84rem; }\n.lm-table th, .lm-table td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--lm-line); vertical-align: top; }\n.lm-table thead th { font: 600 .7rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; color: var(--lm-muted); }\n.lm-table tbody th { font-weight: 600; white-space: nowrap; }\n.lm-table td { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-table td.lm-text { font-family: var(--lm-font); }\n.lm-table td small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-table tr[aria-current] th { text-decoration: underline; text-underline-offset: 3px; }\n\n.lm-chart { position: relative; min-width: 0; }\n.lm-chart svg { display: block; overflow: visible; }\n.lm-chart:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-axis, .lm-axis text { font: 400 11px var(--lm-mono); fill: var(--lm-muted); }\n.lm-mark { font: 600 11px var(--lm-mono); fill: var(--lm-fg); }\n.lm-tip { position: absolute; z-index: 2; display: grid; gap: 2px; width: max-content; max-width: 17rem; padding: 8px 10px; font-size: .78rem; background: var(--lm-surface); color: var(--lm-fg); border: 1px solid var(--lm-line); border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .14); pointer-events: none; }\n.lm-tip strong { font: 600 .82rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-tip .lm-sub { color: var(--lm-muted); }\n.lm-nowrap { white-space: nowrap; }\n.lm-node { cursor: pointer; outline: none; }\n.lm-node:focus-visible > :first-child { stroke-width: 3; }\n\n@media (prefers-reduced-motion: reduce) { .lm-fill { transition: none; } }\n";
|
|
217
|
+
export declare const LOADMAP_CSS = "\n.lm { \n --lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;\n --lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;\n --lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;\n --lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;\n --lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-bg);\n display: grid; gap: 14px; padding: 16px; min-width: 0; box-sizing: border-box; }\n@media (prefers-color-scheme: dark) { .lm:not([data-theme=\"light\"]) { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; } }\n.lm[data-theme=\"dark\"] { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; }\n.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }\n.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }\n.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }\n.lm button:focus-visible, .lm input:focus-visible, .lm select:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }\n\n.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }\n.lm-wrap:fullscreen { background: var(--lm-bg); padding: 16px; align-content: center; overflow: auto; }\n.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }\n.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }\n.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }\n.lm-wrap:fullscreen .lm-board { width: auto; max-width: 100%; max-height: calc(100vh - 90px); }\n.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }\n.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }\n.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }\n.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }\n\n.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; }\n.lm-verdict[data-tier=\"warn\"] { border-color: var(--lm-warn); }\n.lm-verdict[data-tier=\"over\"] { border-color: var(--lm-drop); }\n.lm-measure { margin: 6px 0 0; padding: 0 14px; font-size: .86rem; color: var(--lm-muted); }\n\n.lm-strip { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }\n@container (max-width: 860px) { .lm-strip { grid-template-columns: minmax(0, 1fr); } }\n.lm { container-type: inline-size; }\n\n.lm-meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }\n.lm-meter { padding: 8px 10px; border-radius: 6px; background: var(--lm-bg); min-width: 0; }\n.lm-meter b { display: block; font: 500 1.15rem var(--lm-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-meter span { font-size: .74rem; color: var(--lm-muted); }\n.lm-meter[data-state=\"warn\"] b { color: var(--lm-warn); } .lm-meter[data-state=\"over\"] b { color: var(--lm-drop); }\n\n.lm-limits { display: grid; gap: 10px; }\n.lm-lim, .lm-scale { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 10rem; gap: 4px 14px; align-items: center; }\n@container (max-width: 640px) { .lm-lim, .lm-scale { grid-template-columns: minmax(0, 1fr); } .lm-scale > :first-child, .lm-scale > :last-child { display: none; } }\n.lm-lim b { display: block; font-weight: 600; font-size: .88rem; }\n.lm-lim .lm-sub { display: block; font-size: .74rem; color: var(--lm-muted); }\n.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }\n.lm-tag[data-kind=\"first\"] { color: var(--lm-surface); background: var(--lm-drop); }\n.lm-tag[data-kind=\"estimated\"] { color: var(--lm-warn); border: 1px solid currentColor; }\n.lm-tag[data-kind=\"range\"] { color: var(--lm-muted); border: 1px solid currentColor; }\n.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }\n.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }\n.lm-fill[data-state=\"warn\"] { background: var(--lm-warn); } .lm-fill[data-state=\"over\"] { background: var(--lm-drop); }\n.lm-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--lm-fg); opacity: .55; }\n.lm-val { font: 500 .8rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-val small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-scale { font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }\n.lm-scale div { position: relative; height: 12px; }\n.lm-scale div span { position: absolute; transform: translateX(-50%); white-space: nowrap; }\n\n.lm-controls label.lm-range { display: grid; gap: 4px; font-size: .84rem; }\n.lm-controls label.lm-range > span { display: flex; justify-content: space-between; gap: 8px; }\n.lm-controls output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-controls input[type=range] { width: 100%; accent-color: var(--lm-accent); }\n.lm-presets { display: flex; flex-wrap: wrap; gap: 6px; }\n.lm-presets button { font: 500 .76rem var(--lm-font); background: var(--lm-accent-soft); color: var(--lm-fg); border: 1px solid transparent; border-radius: 5px; padding: 5px 10px; cursor: pointer; }\n.lm-presets button[aria-pressed=\"true\"] { border-color: var(--lm-accent); }\n.lm-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-size: .84rem; cursor: pointer; }\n.lm-switch input { margin: 3px 0 0; accent-color: var(--lm-accent); }\n.lm-switch small, .lm-select small { grid-column: 2; color: var(--lm-muted); font-size: .74rem; line-height: 1.3; }\n.lm-select { display: grid; gap: 4px; font-size: .84rem; }\n.lm-select select { width: 100%; min-width: 0; font: 400 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 5px; padding: 5px 8px; }\n.lm-off { opacity: .45; cursor: default; }\n\n.lm-facts { margin: 0; padding-left: 1.1em; font-size: .88rem; columns: 2; column-gap: 28px; }\n@container (max-width: 860px) { .lm-facts { columns: 1; } }\n.lm-facts li { margin-bottom: 8px; break-inside: avoid; }\n.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }\n.lm-prov[data-kind=\"measured\"] { color: var(--lm-ok); } .lm-prov[data-kind=\"estimated\"] { color: var(--lm-warn); }\n.lm-prov[data-kind=\"configured\"] { color: var(--lm-accent); }\n\n/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */\n.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }\n.lm-scenarios legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin-right: 6px; padding: 0; }\n.lm-scenarios button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-scenarios button[aria-pressed=\"true\"] { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }\n.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }\n.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); }\n.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }\n.lm-story p { flex: 1 1 240px; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }\n.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }\n.lm-story-nav { display: flex; gap: 6px; }\n.lm-story em { color: var(--lm-muted); }\n.lm-story button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-story button[aria-disabled=\"true\"] { opacity: .45; cursor: default; }\n.lm-own { font-size: .78rem; color: var(--lm-muted); }\n.lm-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; margin-right: 6px; }\n\n.lm-compare-text { margin: 0; }\n.lm-table-wrap { overflow-x: auto; }\n.lm-table { border-collapse: collapse; width: 100%; font-size: .84rem; }\n.lm-table th, .lm-table td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--lm-line); vertical-align: top; }\n.lm-table thead th { font: 600 .7rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; color: var(--lm-muted); }\n.lm-table tbody th { font-weight: 600; white-space: nowrap; }\n.lm-table td { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-table td.lm-text { font-family: var(--lm-font); }\n.lm-table td small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-table tr[aria-current] th { text-decoration: underline; text-underline-offset: 3px; }\n\n.lm-chart { position: relative; min-width: 0; }\n.lm-chart svg { display: block; overflow: visible; }\n.lm-chart:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-axis, .lm-axis text { font: 400 11px var(--lm-mono); fill: var(--lm-muted); }\n.lm-mark { font: 600 11px var(--lm-mono); fill: var(--lm-fg); }\n.lm-tip { position: absolute; z-index: 2; display: grid; gap: 2px; width: max-content; max-width: 17rem; padding: 8px 10px; font-size: .78rem; background: var(--lm-surface); color: var(--lm-fg); border: 1px solid var(--lm-line); border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .14); pointer-events: none; }\n.lm-tip strong { font: 600 .82rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-tip .lm-sub { color: var(--lm-muted); }\n.lm-nowrap { white-space: nowrap; }\n.lm-node { cursor: pointer; outline: none; }\n.lm-node:focus-visible > :first-child { stroke-width: 3; }\n\n@media (prefers-reduced-motion: reduce) { .lm-fill { transition: none; } }\n";
|
|
211
218
|
/** Adds the stylesheet once per document. */
|
|
212
219
|
export declare function injectStyles(doc?: Document): void;
|
|
213
|
-
export { type AnyNodeDef, type ClusterDef, type EdgeDef, type Engine, type FlowColor, type FlowView, type Label, type LoadmapController, type LoadmapHandle, type LoadmapOptions, type LoadmapProps, type NodeDef, type PoolDef, type Theme, type View, type ViewDef, cluster, compact, defineView, edge, fitLinear, fmt, multiple, node, pct, pool, secs };
|
|
220
|
+
export { type AnyNodeDef, type ClusterDef, type Dot, type EdgeDef, type Engine, type FlowColor, type FlowView, type Label, type LoadmapController, type LoadmapHandle, type LoadmapOptions, type LoadmapProps, type NodeDef, type PoolDef, type Theme, type View, type ViewDef, cluster, compact, defineView, edge, fitLinear, fmt, multiple, node, pct, pool, secs };
|
package/dist/index.js
CHANGED
|
@@ -798,6 +798,8 @@ function Txt({ s, children, anchor = "middle", fill = "currentColor" }) {
|
|
|
798
798
|
function Node({ n, state, title, sub, lm, focused, handlers }) {
|
|
799
799
|
const stroke = state ? STATE_STROKE[state] : "var(--lm-line)";
|
|
800
800
|
const flows = lm.view.def.flows;
|
|
801
|
+
const st = n.kind === "pool" ? lm.ev.stages[n.stages[0] ?? ""] : void 0;
|
|
802
|
+
const running = st?.kind === "workers" ? st.running : n.members.length;
|
|
801
803
|
const e = 6;
|
|
802
804
|
return /* @__PURE__ */ jsxs("g", {
|
|
803
805
|
style: { color: "var(--lm-fg)" },
|
|
@@ -834,20 +836,25 @@ function Node({ n, state, title, sub, lm, focused, handlers }) {
|
|
|
834
836
|
fill: "var(--lm-muted)",
|
|
835
837
|
children: sub
|
|
836
838
|
}),
|
|
837
|
-
n.members.map((m) => /* @__PURE__ */ jsxs("g", {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
839
|
+
n.members.map((m, i) => /* @__PURE__ */ jsxs("g", {
|
|
840
|
+
"data-idle": i >= running || void 0,
|
|
841
|
+
opacity: i >= running ? .45 : void 0,
|
|
842
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
843
|
+
x: m.x,
|
|
844
|
+
y: m.y,
|
|
845
|
+
width: m.w,
|
|
846
|
+
height: m.h,
|
|
847
|
+
rx: "4",
|
|
848
|
+
fill: "none",
|
|
849
|
+
stroke: "var(--lm-line)",
|
|
850
|
+
strokeDasharray: i >= running ? "3 3" : void 0
|
|
851
|
+
}), /* @__PURE__ */ jsx(Txt, {
|
|
852
|
+
s: m.spot,
|
|
853
|
+
anchor: "start",
|
|
854
|
+
fill: "var(--lm-muted)",
|
|
855
|
+
children: m.label
|
|
856
|
+
})]
|
|
857
|
+
}, m.label)),
|
|
851
858
|
n.groups.map((g) => /* @__PURE__ */ jsx(Txt, {
|
|
852
859
|
s: g.spot,
|
|
853
860
|
anchor: "start",
|
|
@@ -978,6 +985,7 @@ function Detail({ lm, scene, id, board, detailId }) {
|
|
|
978
985
|
" at ",
|
|
979
986
|
at(c.fullRange, c.full)
|
|
980
987
|
] }),
|
|
988
|
+
blocks(lm, n).map((line) => /* @__PURE__ */ jsx("span", { children: line }, line)),
|
|
981
989
|
c.over && /* @__PURE__ */ jsxs("span", {
|
|
982
990
|
className: "lm-sub",
|
|
983
991
|
children: [
|
|
@@ -1016,6 +1024,17 @@ function Detail({ lm, scene, id, board, detailId }) {
|
|
|
1016
1024
|
]
|
|
1017
1025
|
});
|
|
1018
1026
|
}
|
|
1027
|
+
/** What a box's building blocks do at these values: pods running, cache answers, what a stage turns away. */
|
|
1028
|
+
function blocks(lm, n) {
|
|
1029
|
+
const out = [];
|
|
1030
|
+
for (const id of n.stages) {
|
|
1031
|
+
const s = lm.ev.stages[id];
|
|
1032
|
+
if (s?.kind === "workers" && s.autoscale) out.push(`${s.running} of ${s.pods} pods running, each held near ${pct$1(s.autoscale.target)}`);
|
|
1033
|
+
if (s?.kind === "cache") out.push(`${pct$1(s.hit)} answered here`);
|
|
1034
|
+
if ((s?.kind === "pass" || s?.kind === "limit" || s?.kind === "cache") && s.shed > 0) out.push(`${pct$1(s.shed)} of what reaches it turned away`);
|
|
1035
|
+
}
|
|
1036
|
+
return out;
|
|
1037
|
+
}
|
|
1019
1038
|
// src/panels.tsx
|
|
1020
1039
|
/** The model's one-sentence answer for the current values, and which capacity to measure when it is unsure. */
|
|
1021
1040
|
function Verdict({ lm }) {
|
|
@@ -1128,7 +1147,10 @@ function Limits({ lm, title = "Where it runs out, in order" }) {
|
|
|
1128
1147
|
})
|
|
1129
1148
|
] });
|
|
1130
1149
|
}
|
|
1131
|
-
/**
|
|
1150
|
+
/**
|
|
1151
|
+
* Live numbers: from the sim, lag and drops per queue, busy workers, rejected requests; from the model, pods running,
|
|
1152
|
+
* cache answers and retries.
|
|
1153
|
+
*/
|
|
1132
1154
|
function Meters({ lm }) {
|
|
1133
1155
|
const [, tick] = useState(0);
|
|
1134
1156
|
useEffect(() => {
|
|
@@ -1170,14 +1192,43 @@ function Meters({ lm }) {
|
|
|
1170
1192
|
label: `${s.label} busy`,
|
|
1171
1193
|
state: b > .95 ? "over" : b > .5 ? "warn" : "ok"
|
|
1172
1194
|
});
|
|
1195
|
+
if (s.autoscale) items.push({
|
|
1196
|
+
key: `${s.id}/pods`,
|
|
1197
|
+
value: `${s.running} of ${s.pods}`,
|
|
1198
|
+
label: `${s.label} pods running`,
|
|
1199
|
+
state: s.running < s.pods ? "ok" : (ev.components[s.component]?.util ?? 0) > model.thresholds.full ? "over" : "warn"
|
|
1200
|
+
});
|
|
1173
1201
|
}
|
|
1174
|
-
if (s.kind === "
|
|
1202
|
+
if (s.kind === "cache") items.push({
|
|
1203
|
+
key: `${s.id}/hits`,
|
|
1204
|
+
value: compact$1(sim.arriving(s.id) * (1 - sim.shed(s.id)) * s.hit),
|
|
1205
|
+
label: `answered at ${s.label} /s (${pct$1(s.hit)} hits)`,
|
|
1206
|
+
state: "ok"
|
|
1207
|
+
});
|
|
1208
|
+
if ((s.kind === "pass" || s.kind === "limit" || s.kind === "cache") && sim.shed(s.id) > 0) items.push({
|
|
1175
1209
|
key: `${s.id}/shed`,
|
|
1176
1210
|
value: pct$1(sim.shed(s.id)),
|
|
1177
1211
|
label: `rejected at ${s.label}`,
|
|
1178
1212
|
state: "over"
|
|
1179
1213
|
});
|
|
1180
1214
|
}
|
|
1215
|
+
for (const f of model.flowIds) {
|
|
1216
|
+
const r = ev.retry[f];
|
|
1217
|
+
if (!r || !(r.rate > 0)) continue;
|
|
1218
|
+
const per = r.attempts / r.rate;
|
|
1219
|
+
items.push({
|
|
1220
|
+
key: `${f}/attempts`,
|
|
1221
|
+
value: `${fmt$1(per)}×`,
|
|
1222
|
+
label: `${flowLabel(f)} attempts per ${model.def.flows[f]?.unit ?? "unit"}`,
|
|
1223
|
+
state: per > 1.05 ? "warn" : "ok"
|
|
1224
|
+
});
|
|
1225
|
+
items.push({
|
|
1226
|
+
key: `${f}/failed`,
|
|
1227
|
+
value: pct$1(r.failed),
|
|
1228
|
+
label: `${flowLabel(f)} failing after ${r.times} ${r.times === 1 ? "retry" : "retries"}`,
|
|
1229
|
+
state: r.failed > .005 ? "over" : "ok"
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1181
1232
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("h3", { children: "Live" }), /* @__PURE__ */ jsx("div", {
|
|
1182
1233
|
className: "lm-meters",
|
|
1183
1234
|
children: items.map((m) => /* @__PURE__ */ jsxs("div", {
|
|
@@ -1515,6 +1566,7 @@ const LOADMAP_CSS = `
|
|
|
1515
1566
|
.lm-facts li { margin-bottom: 8px; break-inside: avoid; }
|
|
1516
1567
|
.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }
|
|
1517
1568
|
.lm-prov[data-kind="measured"] { color: var(--lm-ok); } .lm-prov[data-kind="estimated"] { color: var(--lm-warn); }
|
|
1569
|
+
.lm-prov[data-kind="configured"] { color: var(--lm-accent); }
|
|
1518
1570
|
|
|
1519
1571
|
/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */
|
|
1520
1572
|
.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
|
|
@@ -1645,6 +1697,8 @@ const TOKENS = [
|
|
|
1645
1697
|
"surface",
|
|
1646
1698
|
"line"
|
|
1647
1699
|
];
|
|
1700
|
+
/** The stroke of a hollow dot, in scene units. */
|
|
1701
|
+
const RING = 1.4;
|
|
1648
1702
|
/**
|
|
1649
1703
|
* Everything that moves, without React: the sim, the dots on the canvas and the worker fills in the SVG. React
|
|
1650
1704
|
* renders the structure once per scene; the engine updates the moving parts every frame, and export drives it frame
|
|
@@ -1767,12 +1821,14 @@ var Engine = class {
|
|
|
1767
1821
|
live.add(d.id);
|
|
1768
1822
|
const [x, y] = this.#position(scene, d);
|
|
1769
1823
|
const inCell = d.to.cell != null && d.phase !== "move";
|
|
1824
|
+
const done = d.outcome === "delivered" || d.outcome === "answered";
|
|
1770
1825
|
out.push({
|
|
1771
1826
|
x,
|
|
1772
|
-
y: y - (d.phase === "fade" &&
|
|
1827
|
+
y: y - (d.phase === "fade" && !done ? d.t / d.dur * 8 : 0),
|
|
1773
1828
|
r: inCell ? 3 : 3.4,
|
|
1774
1829
|
color: d.phase === "fade" ? this.outcomeColor(d.outcome) : this.flowColor(d.flow),
|
|
1775
|
-
alpha: d.phase === "fade" ? Math.max(0, 1 - d.t / d.dur) : 1
|
|
1830
|
+
alpha: d.phase === "fade" ? Math.max(0, 1 - d.t / d.dur) : 1,
|
|
1831
|
+
...d.attempt ? { ring: RING } : {}
|
|
1776
1832
|
});
|
|
1777
1833
|
}
|
|
1778
1834
|
for (const id of this.#paths.keys()) if (!live.has(id)) this.#paths.delete(id);
|
|
@@ -1785,10 +1841,17 @@ var Engine = class {
|
|
|
1785
1841
|
ctx.transform(scale, 0, 0, scale, 0, 0);
|
|
1786
1842
|
for (const d of this.dots()) {
|
|
1787
1843
|
ctx.globalAlpha = d.alpha;
|
|
1788
|
-
ctx.fillStyle = d.color;
|
|
1789
1844
|
ctx.beginPath();
|
|
1790
|
-
|
|
1791
|
-
|
|
1845
|
+
if (d.ring) {
|
|
1846
|
+
ctx.strokeStyle = d.color;
|
|
1847
|
+
ctx.lineWidth = d.ring;
|
|
1848
|
+
ctx.arc(d.x, d.y, d.r - d.ring / 2, 0, Math.PI * 2);
|
|
1849
|
+
ctx.stroke();
|
|
1850
|
+
} else {
|
|
1851
|
+
ctx.fillStyle = d.color;
|
|
1852
|
+
ctx.arc(d.x, d.y, d.r, 0, Math.PI * 2);
|
|
1853
|
+
ctx.fill();
|
|
1854
|
+
}
|
|
1792
1855
|
}
|
|
1793
1856
|
ctx.restore();
|
|
1794
1857
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loadmap/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Interactive capacity models for React: an architecture diagram with moving dots, the limits ranked, the verdict, scenarios and headroom.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"loadmap",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@loadmap/core": "0.
|
|
34
|
-
"@loadmap/sim": "0.
|
|
35
|
-
"@loadmap/layout": "0.
|
|
33
|
+
"@loadmap/core": "0.2.0",
|
|
34
|
+
"@loadmap/sim": "0.2.0",
|
|
35
|
+
"@loadmap/layout": "0.2.0",
|
|
36
36
|
"elkjs": "^0.12.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|