dsh-recency-guard 0.11.4 → 0.12.1
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 +76 -0
- package/dist/client.js +805 -166
- package/dist/index.js +799 -246
- package/locale/en.json +22 -4
- package/locale/zh.json +21 -3
- package/package.json +27 -18
package/dist/client.js
CHANGED
|
@@ -31,10 +31,10 @@ __export(entry_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(entry_exports);
|
|
32
32
|
|
|
33
33
|
// src/client/index.ts
|
|
34
|
-
var
|
|
34
|
+
var import_react7 = require("react");
|
|
35
35
|
|
|
36
36
|
// src/client/GuardPanel.tsx
|
|
37
|
-
var
|
|
37
|
+
var import_react5 = require("react");
|
|
38
38
|
|
|
39
39
|
// locale/zh.json
|
|
40
40
|
var zh_default = {
|
|
@@ -50,6 +50,8 @@ var zh_default = {
|
|
|
50
50
|
archive: "\u5F52\u6863\u91CD\u7F6E",
|
|
51
51
|
archiveConfirm: "\u5F52\u6863\u5F53\u524D\u4EA7\u7269\u5E76\u6309\u6700\u65B0\u4E8B\u5B9E\u91CD\u8DD1\uFF1F",
|
|
52
52
|
archiveDefaultReason: "\u9762\u677F\u624B\u52A8\u5F52\u6863",
|
|
53
|
+
conflictNotice: "\u72B6\u6001\u5DF2\u53D8\u5316\uFF0C\u4E0A\u4E00\u6B21\u52A8\u4F5C\u672A\u6267\u884C\u3002\u753B\u9762\u5DF2\u5237\u65B0\u4E3A\u6700\u65B0\u4E8B\u5B9E\uFF0C\u8BF7\u636E\u6B64\u91CD\u65B0\u51B3\u5B9A\u3002",
|
|
54
|
+
conflictDismiss: "\u77E5\u9053\u4E86",
|
|
53
55
|
recover: "\u7ACB\u5373\u6062\u590D",
|
|
54
56
|
reenable: "\u91CD\u65B0\u542F\u7528",
|
|
55
57
|
empty: "\u6682\u65E0\u6570\u636E",
|
|
@@ -89,7 +91,9 @@ var zh_default = {
|
|
|
89
91
|
transitions: "\u8FC1\u79FB\u6B21\u6570",
|
|
90
92
|
noTransitions: "\u5C1A\u65E0\u8FC1\u79FB\u8BB0\u5F55",
|
|
91
93
|
autoDisabled: "\u81EA\u52A8\u5173\u95ED",
|
|
92
|
-
restored: "\u5DF2\u6062\u590D"
|
|
94
|
+
restored: "\u5DF2\u6062\u590D",
|
|
95
|
+
moreTransitions: "\u8FD8\u6709 {count} \u6B21\u66F4\u65E9\u7684\u8FC1\u79FB\u672A\u663E\u793A",
|
|
96
|
+
fewerTransitions: "\u6536\u8D77\u8F83\u65E9\u7684\u8FC1\u79FB"
|
|
93
97
|
},
|
|
94
98
|
metrics: {
|
|
95
99
|
crashRate: "\u5D29\u6E83\u7387",
|
|
@@ -113,7 +117,9 @@ var zh_default = {
|
|
|
113
117
|
converged: "\u5DF2\u6536\u655B",
|
|
114
118
|
notConverged: "\u672A\u6536\u655B",
|
|
115
119
|
samples: "{count} \u6B21\u8FC1\u79FB",
|
|
116
|
-
empty: "\u5C1A\u65E0\u8FC1\u79FB\u8BB0\u5F55\uFF0C\u8F6C\u79FB\u77E9\u9635\u4E0D\u53EF\u5224\u5B9A"
|
|
120
|
+
empty: "\u5C1A\u65E0\u8FC1\u79FB\u8BB0\u5F55\uFF0C\u8F6C\u79FB\u77E9\u9635\u4E0D\u53EF\u5224\u5B9A",
|
|
121
|
+
stationaryMore: "\u5176\u4F59 {count} \u4E2A\u9636\u6BB5",
|
|
122
|
+
stationaryAll: "\u5171 {count} \u4E2A\u9636\u6BB5\u6709\u957F\u671F\u5360\u6BD4"
|
|
117
123
|
},
|
|
118
124
|
dataflow: {
|
|
119
125
|
title: "\u6570\u636E\u6D41",
|
|
@@ -276,7 +282,19 @@ var zh_default = {
|
|
|
276
282
|
edgeTo: "\u6D88\u8D39\u65B9\uFF08\u7EC8\u70B9\uFF09",
|
|
277
283
|
edgeKind: "\u8BED\u4E49",
|
|
278
284
|
edgeTransitions: "\u72B6\u6001\u8FC1\u79FB",
|
|
279
|
-
edgeRanks: "\u6392\u5E8F\u5F15\u7528"
|
|
285
|
+
edgeRanks: "\u6392\u5E8F\u5F15\u7528",
|
|
286
|
+
minimap: "\u5C0F\u5730\u56FE",
|
|
287
|
+
minimapHint: "\u65B9\u6846\u662F\u5F53\u524D\u53EF\u89C1\u533A\u57DF\uFF1B\u70B9\u51FB\u6216\u62D6\u52A8\u65B9\u6846\u53EF\u628A\u4E3B\u89C6\u56FE\u79FB\u5230\u8BE5\u5904\u3002",
|
|
288
|
+
arrowHint: "\u65B9\u5411\u952E\u6362\u8282\u70B9",
|
|
289
|
+
linkRange: {
|
|
290
|
+
label: "\u5173\u8054\u8303\u56F4",
|
|
291
|
+
hops1: "\u76F4\u63A5",
|
|
292
|
+
hops2: "\u4E24\u8DF3",
|
|
293
|
+
closure: "\u5168\u8FDE\u901A"
|
|
294
|
+
},
|
|
295
|
+
filteredEmpty: "\u5F53\u524D\u8FC7\u6EE4\u6761\u4EF6\u628A\u56FE\u6EE4\u7A7A\u4E86\u3002",
|
|
296
|
+
filteredEmptyReset: "\u6062\u590D\u663E\u793A",
|
|
297
|
+
searchMore: "\u5176\u4F59 {count} \u4E2A\u5339\u914D"
|
|
280
298
|
},
|
|
281
299
|
events: {
|
|
282
300
|
title: "\u4E8B\u4EF6\u6D41",
|
|
@@ -332,6 +350,8 @@ var en_default = {
|
|
|
332
350
|
archive: "Archive & reset",
|
|
333
351
|
archiveConfirm: "Archive the current artifacts and restart from the latest facts?",
|
|
334
352
|
archiveDefaultReason: "manual archive from the panel",
|
|
353
|
+
conflictNotice: "State changed, so the last action was not executed. The view now shows the latest facts \u2014 decide again from them.",
|
|
354
|
+
conflictDismiss: "Got it",
|
|
335
355
|
recover: "Recover now",
|
|
336
356
|
reenable: "Re-enable",
|
|
337
357
|
empty: "No data",
|
|
@@ -371,7 +391,9 @@ var en_default = {
|
|
|
371
391
|
transitions: "Transitions",
|
|
372
392
|
noTransitions: "No transitions recorded",
|
|
373
393
|
autoDisabled: "Auto-disabled",
|
|
374
|
-
restored: "Restored"
|
|
394
|
+
restored: "Restored",
|
|
395
|
+
moreTransitions: "{count} earlier transitions hidden",
|
|
396
|
+
fewerTransitions: "Show fewer transitions"
|
|
375
397
|
},
|
|
376
398
|
metrics: {
|
|
377
399
|
crashRate: "Crash rate",
|
|
@@ -395,7 +417,9 @@ var en_default = {
|
|
|
395
417
|
converged: "converged",
|
|
396
418
|
notConverged: "not converged",
|
|
397
419
|
samples: "{count} transitions",
|
|
398
|
-
empty: "No transitions recorded yet \u2014 the matrix is not determinable"
|
|
420
|
+
empty: "No transitions recorded yet \u2014 the matrix is not determinable",
|
|
421
|
+
stationaryMore: "{count} more stages",
|
|
422
|
+
stationaryAll: "{count} stages have a long-run share"
|
|
399
423
|
},
|
|
400
424
|
dataflow: {
|
|
401
425
|
title: "Data flow",
|
|
@@ -502,7 +526,7 @@ var en_default = {
|
|
|
502
526
|
},
|
|
503
527
|
graph: {
|
|
504
528
|
title: "Capability production and consumption",
|
|
505
|
-
hint: "
|
|
529
|
+
hint: "ctrl/\u2318 + wheel zoom \xB7 drag to pan \xB7 drag a node to nudge it \xB7 click to highlight \xB7 double-click to centre \xB7 Esc to exit",
|
|
506
530
|
zoomGroup: "Zoom",
|
|
507
531
|
zoomIn: "Zoom in",
|
|
508
532
|
zoomOut: "Zoom out",
|
|
@@ -558,7 +582,19 @@ var en_default = {
|
|
|
558
582
|
edgeTo: "Consumes (to)",
|
|
559
583
|
edgeKind: "Semantics",
|
|
560
584
|
edgeTransitions: "transition",
|
|
561
|
-
edgeRanks: "ranking"
|
|
585
|
+
edgeRanks: "ranking",
|
|
586
|
+
minimap: "Minimap",
|
|
587
|
+
minimapHint: "the box is what you can see right now; click or drag it to move the main view",
|
|
588
|
+
arrowHint: "arrow keys move between nodes",
|
|
589
|
+
linkRange: {
|
|
590
|
+
label: "Link range",
|
|
591
|
+
hops1: "direct",
|
|
592
|
+
hops2: "2 hops",
|
|
593
|
+
closure: "all linked"
|
|
594
|
+
},
|
|
595
|
+
filteredEmpty: "The current filters hid every node.",
|
|
596
|
+
filteredEmptyReset: "Show everything",
|
|
597
|
+
searchMore: "{count} more matches"
|
|
562
598
|
},
|
|
563
599
|
events: {
|
|
564
600
|
title: "Event stream",
|
|
@@ -647,7 +683,7 @@ function flatten(dict, prefix = "") {
|
|
|
647
683
|
}
|
|
648
684
|
|
|
649
685
|
// src/client/GuardGraph.tsx
|
|
650
|
-
var
|
|
686
|
+
var import_react2 = require("react");
|
|
651
687
|
|
|
652
688
|
// src/client/viewport.ts
|
|
653
689
|
var SCALE_MIN = 0.25;
|
|
@@ -848,7 +884,7 @@ function parallelCurvature(parallelIndex, unit = 18) {
|
|
|
848
884
|
const magnitude = Math.ceil(parallelIndex / 2) * unit;
|
|
849
885
|
return parallelIndex % 2 === 1 ? magnitude : -magnitude;
|
|
850
886
|
}
|
|
851
|
-
function matchNodes(nodes, query, limit =
|
|
887
|
+
function matchNodes(nodes, query, limit = Number.POSITIVE_INFINITY) {
|
|
852
888
|
const q = query.trim().toLowerCase();
|
|
853
889
|
if (q === "") return [];
|
|
854
890
|
const scored = [];
|
|
@@ -864,7 +900,36 @@ function matchNodes(nodes, query, limit = 8) {
|
|
|
864
900
|
if (rank !== null) scored.push({ node, rank });
|
|
865
901
|
}
|
|
866
902
|
scored.sort((a, b) => a.rank - b.rank || a.node.id.localeCompare(b.node.id));
|
|
867
|
-
|
|
903
|
+
const cap = Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : scored.length;
|
|
904
|
+
return scored.slice(0, cap).map((s) => s.node);
|
|
905
|
+
}
|
|
906
|
+
function searchSummary(all, displayLimit, cursor) {
|
|
907
|
+
const total = all.length;
|
|
908
|
+
if (total === 0) {
|
|
909
|
+
return { all: [], visible: [], total: 0, omitted: 0, cycleIndex: 0, indexInVisible: -1 };
|
|
910
|
+
}
|
|
911
|
+
const raw = Number.isFinite(cursor) ? Math.floor(cursor) : 0;
|
|
912
|
+
const cycleIndex = (raw % total + total) % total;
|
|
913
|
+
const cap = Number.isFinite(displayLimit) ? Math.max(0, Math.floor(displayLimit)) : total;
|
|
914
|
+
const shown = Math.min(total, cap);
|
|
915
|
+
const start = Math.min(Math.max(0, cycleIndex - shown + 1), Math.max(0, total - shown));
|
|
916
|
+
const visible = all.slice(start, start + shown);
|
|
917
|
+
return {
|
|
918
|
+
all: [...all],
|
|
919
|
+
visible,
|
|
920
|
+
total,
|
|
921
|
+
omitted: Math.max(0, total - visible.length),
|
|
922
|
+
cycleIndex,
|
|
923
|
+
indexInVisible: cycleIndex - start
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
function isWorldPointVisible(viewport, size, world, margin = 0) {
|
|
927
|
+
const scale = viewport.scale;
|
|
928
|
+
if (!Number.isFinite(scale) || !(scale > 0)) return false;
|
|
929
|
+
if (!Number.isFinite(world.x) || !Number.isFinite(world.y)) return false;
|
|
930
|
+
const x = world.x * scale + viewport.tx;
|
|
931
|
+
const y = world.y * scale + viewport.ty;
|
|
932
|
+
return x >= margin && y >= margin && x <= finite(size.width, 0) - margin && y <= finite(size.height, 0) - margin;
|
|
868
933
|
}
|
|
869
934
|
function centerOn(viewport, size, world, targetScale) {
|
|
870
935
|
const scale = clampScale(targetScale ?? viewport.scale);
|
|
@@ -937,8 +1002,12 @@ function buildNodeIndex(nodes) {
|
|
|
937
1002
|
function hitNodesOf(nodes) {
|
|
938
1003
|
return nodes.map((node) => ({ id: node.id, x: node.x, y: node.y, w: NODE_WIDTH, h: NODE_HEIGHT }));
|
|
939
1004
|
}
|
|
1005
|
+
function linkRangeHops(range) {
|
|
1006
|
+
return range === "closure" ? null : range === "hops2" ? 2 : 1;
|
|
1007
|
+
}
|
|
940
1008
|
function filterGraph(nodes, edges, filter) {
|
|
941
|
-
const
|
|
1009
|
+
const hops = filter.maxHops ?? null;
|
|
1010
|
+
const linked = filter.onlyConnectedWith === null ? null : hops === null ? traceFrom(filter.onlyConnectedWith, edges, "both") : kHopNeighborhood(filter.onlyConnectedWith, edges, hops);
|
|
942
1011
|
const keptNodes = nodes.filter(
|
|
943
1012
|
(node) => !filter.hidden.has(node.kind) && (linked === null || linked.has(node.id))
|
|
944
1013
|
);
|
|
@@ -946,6 +1015,35 @@ function filterGraph(nodes, edges, filter) {
|
|
|
946
1015
|
const keptEdges = edges.filter((edge) => keptIndex.has(edge.from) && keptIndex.has(edge.to));
|
|
947
1016
|
return { nodes: keptNodes, edges: keptEdges };
|
|
948
1017
|
}
|
|
1018
|
+
function kHopNeighborhood(startId, edges, hops) {
|
|
1019
|
+
const visited = /* @__PURE__ */ new Set([startId]);
|
|
1020
|
+
const depth = Math.floor(hops);
|
|
1021
|
+
if (!(depth > 0)) return visited;
|
|
1022
|
+
const adjacency = /* @__PURE__ */ new Map();
|
|
1023
|
+
const push = (from, to) => {
|
|
1024
|
+
const list = adjacency.get(from);
|
|
1025
|
+
if (list) list.push(to);
|
|
1026
|
+
else adjacency.set(from, [to]);
|
|
1027
|
+
};
|
|
1028
|
+
for (const edge of edges) {
|
|
1029
|
+
push(edge.from, edge.to);
|
|
1030
|
+
push(edge.to, edge.from);
|
|
1031
|
+
}
|
|
1032
|
+
let frontier = [startId];
|
|
1033
|
+
for (let d = 0; d < depth; d += 1) {
|
|
1034
|
+
const next = [];
|
|
1035
|
+
for (const id of frontier) {
|
|
1036
|
+
for (const neighbor of adjacency.get(id) ?? []) {
|
|
1037
|
+
if (visited.has(neighbor)) continue;
|
|
1038
|
+
visited.add(neighbor);
|
|
1039
|
+
next.push(neighbor);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
frontier = next;
|
|
1043
|
+
if (frontier.length === 0) break;
|
|
1044
|
+
}
|
|
1045
|
+
return visited;
|
|
1046
|
+
}
|
|
949
1047
|
function graphBounds(nodes) {
|
|
950
1048
|
let minX = Infinity;
|
|
951
1049
|
let minY = Infinity;
|
|
@@ -985,6 +1083,32 @@ function degreeOf(id, edges) {
|
|
|
985
1083
|
}
|
|
986
1084
|
return { in: incoming, out: outgoing };
|
|
987
1085
|
}
|
|
1086
|
+
function degreeTally(edges) {
|
|
1087
|
+
const tally = /* @__PURE__ */ new Map();
|
|
1088
|
+
for (const edge of edges) {
|
|
1089
|
+
tally.set(edge.from, (tally.get(edge.from) ?? 0) + 1);
|
|
1090
|
+
tally.set(edge.to, (tally.get(edge.to) ?? 0) + 1);
|
|
1091
|
+
}
|
|
1092
|
+
return tally;
|
|
1093
|
+
}
|
|
1094
|
+
function edgeDegreeSum(tally, edge) {
|
|
1095
|
+
return (tally.get(edge.from) ?? 0) + (tally.get(edge.to) ?? 0);
|
|
1096
|
+
}
|
|
1097
|
+
var EDGE_DEGREE_SUM_MIN = 2;
|
|
1098
|
+
var EDGE_DEGREE_SUM_MAX = 20;
|
|
1099
|
+
function logScale(value, domainMax) {
|
|
1100
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
1101
|
+
if (!Number.isFinite(domainMax) || domainMax <= 0) return 0;
|
|
1102
|
+
return Math.min(1, Math.log1p(value) / Math.log1p(domainMax));
|
|
1103
|
+
}
|
|
1104
|
+
var EDGE_WIDTH_MIN = 1.2;
|
|
1105
|
+
var EDGE_WIDTH_MAX = 3.4;
|
|
1106
|
+
function edgeWidthOf(tally, edge, referenceMax = EDGE_DEGREE_SUM_MAX, minPx = EDGE_WIDTH_MIN, maxPx = EDGE_WIDTH_MAX) {
|
|
1107
|
+
const excess = edgeDegreeSum(tally, edge) - EDGE_DEGREE_SUM_MIN;
|
|
1108
|
+
const domainExcess = referenceMax - EDGE_DEGREE_SUM_MIN;
|
|
1109
|
+
const raw = minPx + (maxPx - minPx) * logScale(excess, domainExcess);
|
|
1110
|
+
return Math.min(maxPx, Math.max(minPx, raw));
|
|
1111
|
+
}
|
|
988
1112
|
function edgeDetailOf(edge, index) {
|
|
989
1113
|
const from = index.get(edge.from);
|
|
990
1114
|
const to = index.get(edge.to);
|
|
@@ -1097,6 +1221,32 @@ function withLayout(nodes, positions, offsets) {
|
|
|
1097
1221
|
};
|
|
1098
1222
|
});
|
|
1099
1223
|
}
|
|
1224
|
+
function directionalCandidate(from, direction, candidates) {
|
|
1225
|
+
const horizontal = direction === "left" || direction === "right";
|
|
1226
|
+
const sign = direction === "left" || direction === "up" ? -1 : 1;
|
|
1227
|
+
const ahead = candidates.filter((node) => {
|
|
1228
|
+
const delta = horizontal ? node.x - from.x : node.y - from.y;
|
|
1229
|
+
return delta * sign > 0;
|
|
1230
|
+
});
|
|
1231
|
+
if (ahead.length === 0) return null;
|
|
1232
|
+
const crossOf = (node) => Math.abs(horizontal ? node.y - from.y : node.x - from.x);
|
|
1233
|
+
const alongOf = (node) => Math.abs((horizontal ? node.x - from.x : node.y - from.y) * sign);
|
|
1234
|
+
const bestCross = Math.min(...ahead.map(crossOf));
|
|
1235
|
+
const tolerance = Math.max(bestCross, horizontal ? NODE_HEIGHT : NODE_WIDTH / 2);
|
|
1236
|
+
const band = ahead.filter((node) => crossOf(node) <= tolerance);
|
|
1237
|
+
const pool = band.length > 0 ? band : ahead;
|
|
1238
|
+
let best = pool[0];
|
|
1239
|
+
if (!best) return null;
|
|
1240
|
+
let bestScore = alongOf(best) * 4 + crossOf(best);
|
|
1241
|
+
for (const node of pool) {
|
|
1242
|
+
const score = alongOf(node) * 4 + crossOf(node);
|
|
1243
|
+
if (score < bestScore) {
|
|
1244
|
+
best = node;
|
|
1245
|
+
bestScore = score;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
return best?.id ?? null;
|
|
1249
|
+
}
|
|
1100
1250
|
function zoomLabel(scale) {
|
|
1101
1251
|
if (!Number.isFinite(scale)) return "100%";
|
|
1102
1252
|
return `${Math.round(scale * 100)}%`;
|
|
@@ -1118,10 +1268,108 @@ function shapePath(shape, size, cy) {
|
|
|
1118
1268
|
}
|
|
1119
1269
|
}
|
|
1120
1270
|
|
|
1271
|
+
// src/client/minimap-model.ts
|
|
1272
|
+
var NODE_WIDTH2 = LAYOUT.nodeWidth;
|
|
1273
|
+
var NODE_HEIGHT2 = LAYOUT.nodeHeight;
|
|
1274
|
+
var MINIMAP_PADDING = 4;
|
|
1275
|
+
function minimapProjection(bounds, canvas, padding = MINIMAP_PADDING) {
|
|
1276
|
+
const drawWidth = canvas.width - padding * 2;
|
|
1277
|
+
const drawHeight = canvas.height - padding * 2;
|
|
1278
|
+
if (!(bounds.width > 0) || !(bounds.height > 0) || !(drawWidth > 0) || !(drawHeight > 0)) {
|
|
1279
|
+
return {
|
|
1280
|
+
worldScale: 1,
|
|
1281
|
+
offsetX: padding,
|
|
1282
|
+
offsetY: padding,
|
|
1283
|
+
minX: 0,
|
|
1284
|
+
minY: 0,
|
|
1285
|
+
figureWidth: 0,
|
|
1286
|
+
figureHeight: 0
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
const worldScale = Math.min(drawWidth / bounds.width, drawHeight / bounds.height);
|
|
1290
|
+
const figureWidth = bounds.width * worldScale;
|
|
1291
|
+
const figureHeight = bounds.height * worldScale;
|
|
1292
|
+
return {
|
|
1293
|
+
worldScale,
|
|
1294
|
+
// 居中:空白在两侧均分,小地图里的「图居中」才与主视口 fit 的居中同构。
|
|
1295
|
+
offsetX: padding + (drawWidth - figureWidth) / 2,
|
|
1296
|
+
offsetY: padding + (drawHeight - figureHeight) / 2,
|
|
1297
|
+
minX: bounds.minX,
|
|
1298
|
+
minY: bounds.minY,
|
|
1299
|
+
figureWidth,
|
|
1300
|
+
figureHeight
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
function worldToMinimap(proj, point) {
|
|
1304
|
+
return {
|
|
1305
|
+
x: proj.offsetX + (point.x - proj.minX) * proj.worldScale,
|
|
1306
|
+
y: proj.offsetY + (point.y - proj.minY) * proj.worldScale
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
function minimapToWorld(proj, point) {
|
|
1310
|
+
if (!(proj.worldScale > 0) || !Number.isFinite(proj.worldScale)) return { x: proj.minX, y: proj.minY };
|
|
1311
|
+
return {
|
|
1312
|
+
x: (point.x - proj.offsetX) / proj.worldScale + proj.minX,
|
|
1313
|
+
y: (point.y - proj.offsetY) / proj.worldScale + proj.minY
|
|
1314
|
+
};
|
|
1315
|
+
}
|
|
1316
|
+
function minimapNodeRects(nodes, proj, color) {
|
|
1317
|
+
return nodes.map((node) => {
|
|
1318
|
+
const at = worldToMinimap(proj, { x: node.x, y: node.y });
|
|
1319
|
+
return {
|
|
1320
|
+
id: node.id,
|
|
1321
|
+
x: at.x,
|
|
1322
|
+
y: at.y,
|
|
1323
|
+
w: Math.max(1.5, NODE_WIDTH2 * proj.worldScale),
|
|
1324
|
+
h: Math.max(1, NODE_HEIGHT2 * proj.worldScale),
|
|
1325
|
+
fill: color(node)
|
|
1326
|
+
};
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
function minimapViewportRect(proj, viewport, size) {
|
|
1330
|
+
const scale = viewport.scale;
|
|
1331
|
+
if (!(proj.figureWidth > 0) || !(proj.figureHeight > 0)) {
|
|
1332
|
+
return { x: 0, y: 0, w: 0, h: 0, zoomedOut: true };
|
|
1333
|
+
}
|
|
1334
|
+
const figureLeft = proj.offsetX;
|
|
1335
|
+
const figureTop = proj.offsetY;
|
|
1336
|
+
if (!(scale > 0) || !Number.isFinite(scale)) {
|
|
1337
|
+
return { x: figureLeft, y: figureTop, w: proj.figureWidth, h: proj.figureHeight, zoomedOut: true };
|
|
1338
|
+
}
|
|
1339
|
+
const toWorld = (point) => ({
|
|
1340
|
+
x: (point.x - viewport.tx) / scale,
|
|
1341
|
+
y: (point.y - viewport.ty) / scale
|
|
1342
|
+
});
|
|
1343
|
+
const a = worldToMinimap(proj, toWorld({ x: 0, y: 0 }));
|
|
1344
|
+
const b = worldToMinimap(proj, toWorld({ x: size.width, y: size.height }));
|
|
1345
|
+
const left = Math.max(Math.min(a.x, b.x), figureLeft);
|
|
1346
|
+
const top = Math.max(Math.min(a.y, b.y), figureTop);
|
|
1347
|
+
const right = Math.min(Math.max(a.x, b.x), figureLeft + proj.figureWidth);
|
|
1348
|
+
const bottom = Math.min(Math.max(a.y, b.y), figureTop + proj.figureHeight);
|
|
1349
|
+
const epsilon = 0.5;
|
|
1350
|
+
const w = Math.max(0, right - left);
|
|
1351
|
+
const h = Math.max(0, bottom - top);
|
|
1352
|
+
if (w + epsilon >= proj.figureWidth && h + epsilon >= proj.figureHeight) {
|
|
1353
|
+
return { x: figureLeft, y: figureTop, w: proj.figureWidth, h: proj.figureHeight, zoomedOut: true };
|
|
1354
|
+
}
|
|
1355
|
+
if (w <= 0 || h <= 0) {
|
|
1356
|
+
return {
|
|
1357
|
+
x: Math.min(Math.max(Math.min(a.x, b.x), figureLeft), figureLeft + proj.figureWidth),
|
|
1358
|
+
y: Math.min(Math.max(Math.min(a.y, b.y), figureTop), figureTop + proj.figureHeight),
|
|
1359
|
+
w: 0,
|
|
1360
|
+
h: 0,
|
|
1361
|
+
zoomedOut: false
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
return { x: left, y: top, w, h, zoomedOut: false };
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1121
1367
|
// src/client/GraphParts.tsx
|
|
1368
|
+
var import_react = require("react");
|
|
1122
1369
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1123
1370
|
var LAYOUT_MODES = ["layered", "radial"];
|
|
1124
1371
|
var COLOR_MODES = ["tone", "kind", "stage"];
|
|
1372
|
+
var LINK_RANGES = ["hops1", "hops2", "closure"];
|
|
1125
1373
|
function GraphToolbar(props) {
|
|
1126
1374
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rg-graph-toolbar", role: "toolbar", "aria-label": t("graph.title"), children: [
|
|
1127
1375
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rg-graph-zoom", role: "group", "aria-label": t("graph.zoomGroup"), children: [
|
|
@@ -1139,7 +1387,7 @@ function GraphToolbar(props) {
|
|
|
1139
1387
|
placeholder: t("graph.search"),
|
|
1140
1388
|
onChange: (event) => props.onQuery(event.target.value),
|
|
1141
1389
|
onKeyDown: (event) => {
|
|
1142
|
-
if (event.key === "Enter" && props.
|
|
1390
|
+
if (event.key === "Enter" && props.matchTotal > 0) {
|
|
1143
1391
|
event.preventDefault?.();
|
|
1144
1392
|
props.onMatchNext();
|
|
1145
1393
|
}
|
|
@@ -1150,19 +1398,22 @@ function GraphToolbar(props) {
|
|
|
1150
1398
|
"aria-keyshortcuts": "Enter"
|
|
1151
1399
|
}
|
|
1152
1400
|
),
|
|
1153
|
-
props.query.trim() !== "" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "rg-search-results", role: "listbox", "aria-label": t("graph.searchResults"), children: props.
|
|
1154
|
-
"
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1401
|
+
props.query.trim() !== "" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "rg-search-results", role: "listbox", "aria-label": t("graph.searchResults"), children: props.matchTotal === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "rg-search-noresult", children: t("graph.noResults") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1402
|
+
props.matches.map((node) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1403
|
+
"button",
|
|
1404
|
+
{
|
|
1405
|
+
type: "button",
|
|
1406
|
+
onClick: () => props.onLocate(node.id),
|
|
1407
|
+
"aria-current": node.id === props.currentMatchId,
|
|
1408
|
+
children: [
|
|
1409
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `rg-dot rg-dot-${node.tone}`, "aria-hidden": true }),
|
|
1410
|
+
node.label
|
|
1411
|
+
]
|
|
1412
|
+
}
|
|
1413
|
+
) }, node.id)),
|
|
1414
|
+
props.matchOmitted > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "rg-search-omitted", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "rg-link", onClick: props.onToggleResults, children: t("graph.searchMore", { count: props.matchOmitted }) }) })
|
|
1415
|
+
] }) }),
|
|
1416
|
+
props.query.trim() !== "" && props.matchTotal > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rg-search-index", role: "status", children: t("graph.matchIndex", { index: props.matchOrdinal, total: props.matchTotal }) })
|
|
1166
1417
|
] }),
|
|
1167
1418
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1168
1419
|
Segmented,
|
|
@@ -1182,6 +1433,15 @@ function GraphToolbar(props) {
|
|
|
1182
1433
|
onSelect: (value) => props.onColorMode(value)
|
|
1183
1434
|
}
|
|
1184
1435
|
),
|
|
1436
|
+
props.onlyConnected && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1437
|
+
Segmented,
|
|
1438
|
+
{
|
|
1439
|
+
label: t("graph.linkRange.label"),
|
|
1440
|
+
options: LINK_RANGES.map((range) => ({ value: range, label: t(`graph.linkRange.${range}`) })),
|
|
1441
|
+
active: props.linkRange,
|
|
1442
|
+
onSelect: (value) => props.onLinkRange(value)
|
|
1443
|
+
}
|
|
1444
|
+
),
|
|
1185
1445
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1186
1446
|
"button",
|
|
1187
1447
|
{
|
|
@@ -1194,6 +1454,17 @@ function GraphToolbar(props) {
|
|
|
1194
1454
|
children: t("graph.onlyConnected")
|
|
1195
1455
|
}
|
|
1196
1456
|
),
|
|
1457
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1458
|
+
"button",
|
|
1459
|
+
{
|
|
1460
|
+
type: "button",
|
|
1461
|
+
className: `rg-button rg-button-small${props.minimapVisible ? " rg-button-active" : ""}`,
|
|
1462
|
+
onClick: props.onToggleMinimap,
|
|
1463
|
+
"aria-pressed": props.minimapVisible,
|
|
1464
|
+
title: t("graph.minimapHint"),
|
|
1465
|
+
children: t("graph.minimap")
|
|
1466
|
+
}
|
|
1467
|
+
),
|
|
1197
1468
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1198
1469
|
"button",
|
|
1199
1470
|
{
|
|
@@ -1320,6 +1591,106 @@ function edgeKindKey(kind) {
|
|
|
1320
1591
|
return "graph.edgeRanks";
|
|
1321
1592
|
}
|
|
1322
1593
|
}
|
|
1594
|
+
function GraphMinimap({ width, height, rects, view, focusRect, onNavigate }) {
|
|
1595
|
+
const svgRef = (0, import_react.useRef)(null);
|
|
1596
|
+
const draggingRef = (0, import_react.useRef)(false);
|
|
1597
|
+
const localPoint = (clientX, clientY) => {
|
|
1598
|
+
const box = svgRef.current?.getBoundingClientRect();
|
|
1599
|
+
if (!box || box.width === 0 || box.height === 0) return { x: 0, y: 0 };
|
|
1600
|
+
return { x: (clientX - box.left) / box.width * width, y: (clientY - box.top) / box.height * height };
|
|
1601
|
+
};
|
|
1602
|
+
const capturePointer = (event) => {
|
|
1603
|
+
try {
|
|
1604
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
1605
|
+
} catch {
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
const releasePointer = (event) => {
|
|
1609
|
+
try {
|
|
1610
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
1611
|
+
} catch {
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1615
|
+
"svg",
|
|
1616
|
+
{
|
|
1617
|
+
ref: svgRef,
|
|
1618
|
+
className: "rg-minimap",
|
|
1619
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
1620
|
+
width,
|
|
1621
|
+
height,
|
|
1622
|
+
role: "img",
|
|
1623
|
+
"aria-label": t("graph.minimap"),
|
|
1624
|
+
onPointerDown: (event) => {
|
|
1625
|
+
event.stopPropagation();
|
|
1626
|
+
draggingRef.current = true;
|
|
1627
|
+
capturePointer(event);
|
|
1628
|
+
onNavigate(localPoint(event.clientX, event.clientY));
|
|
1629
|
+
},
|
|
1630
|
+
onPointerMove: (event) => {
|
|
1631
|
+
event.stopPropagation();
|
|
1632
|
+
if (!draggingRef.current) return;
|
|
1633
|
+
onNavigate(localPoint(event.clientX, event.clientY));
|
|
1634
|
+
},
|
|
1635
|
+
onPointerUp: (event) => {
|
|
1636
|
+
event.stopPropagation();
|
|
1637
|
+
draggingRef.current = false;
|
|
1638
|
+
releasePointer(event);
|
|
1639
|
+
},
|
|
1640
|
+
onPointerCancel: (event) => {
|
|
1641
|
+
event.stopPropagation();
|
|
1642
|
+
draggingRef.current = false;
|
|
1643
|
+
},
|
|
1644
|
+
onClick: (event) => {
|
|
1645
|
+
event.stopPropagation();
|
|
1646
|
+
},
|
|
1647
|
+
onDoubleClick: (event) => event.stopPropagation(),
|
|
1648
|
+
children: [
|
|
1649
|
+
rects.map((rect) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1650
|
+
"rect",
|
|
1651
|
+
{
|
|
1652
|
+
x: rect.x,
|
|
1653
|
+
y: rect.y,
|
|
1654
|
+
width: rect.w,
|
|
1655
|
+
height: rect.h,
|
|
1656
|
+
rx: 1,
|
|
1657
|
+
fill: rect.fill,
|
|
1658
|
+
fillOpacity: 0.75
|
|
1659
|
+
},
|
|
1660
|
+
rect.id
|
|
1661
|
+
)),
|
|
1662
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1663
|
+
"rect",
|
|
1664
|
+
{
|
|
1665
|
+
className: `rg-minimap-view${view.zoomedOut ? " rg-minimap-view-all" : ""}`,
|
|
1666
|
+
x: view.x,
|
|
1667
|
+
y: view.y,
|
|
1668
|
+
width: Math.max(4, view.w),
|
|
1669
|
+
height: Math.max(4, view.h),
|
|
1670
|
+
rx: 2,
|
|
1671
|
+
fill: "none",
|
|
1672
|
+
stroke: "var(--dsw-alias-brand-primary)",
|
|
1673
|
+
strokeWidth: 1.5
|
|
1674
|
+
}
|
|
1675
|
+
),
|
|
1676
|
+
focusRect !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1677
|
+
"rect",
|
|
1678
|
+
{
|
|
1679
|
+
className: "rg-minimap-focus",
|
|
1680
|
+
x: focusRect.x,
|
|
1681
|
+
y: focusRect.y,
|
|
1682
|
+
width: Math.max(3, focusRect.w),
|
|
1683
|
+
height: Math.max(2, focusRect.h),
|
|
1684
|
+
rx: 1,
|
|
1685
|
+
fill: "none",
|
|
1686
|
+
stroke: "var(--dsw-alias-state-warn-primary)",
|
|
1687
|
+
strokeWidth: 1.5
|
|
1688
|
+
}
|
|
1689
|
+
)
|
|
1690
|
+
]
|
|
1691
|
+
}
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1323
1694
|
function GraphTooltip({ node, degree, x, y, containerWidth }) {
|
|
1324
1695
|
const halfWidth = 130;
|
|
1325
1696
|
const left = Math.min(Math.max(x, halfWidth), Math.max(halfWidth, containerWidth - halfWidth));
|
|
@@ -1339,62 +1710,69 @@ function GraphTooltip({ node, degree, x, y, containerWidth }) {
|
|
|
1339
1710
|
|
|
1340
1711
|
// src/client/GuardGraph.tsx
|
|
1341
1712
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1713
|
+
var MINIMAP_CANVAS = { width: 152, height: 96 };
|
|
1714
|
+
var MINIMAP_CANVAS_NARROW = { width: 112, height: 72 };
|
|
1715
|
+
var SEARCH_RESULTS_INITIAL = 8;
|
|
1342
1716
|
function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChange, locateRequest = null }) {
|
|
1343
|
-
const [viewport, setViewport] = (0,
|
|
1344
|
-
const [hoverId, setHoverId] = (0,
|
|
1345
|
-
const [hoverEdgeId, setHoverEdgeId] = (0,
|
|
1346
|
-
const [selectedEdgeId, setSelectedEdgeId] = (0,
|
|
1347
|
-
const [hidden, setHidden] = (0,
|
|
1348
|
-
const [size, setSize] = (0,
|
|
1349
|
-
const [query, setQuery] = (0,
|
|
1350
|
-
const [matchIndex, setMatchIndex] = (0,
|
|
1351
|
-
const [
|
|
1352
|
-
const [
|
|
1353
|
-
const [
|
|
1354
|
-
const [
|
|
1355
|
-
const
|
|
1356
|
-
const
|
|
1357
|
-
const [
|
|
1358
|
-
const
|
|
1359
|
-
const
|
|
1717
|
+
const [viewport, setViewport] = (0, import_react2.useState)(IDENTITY);
|
|
1718
|
+
const [hoverId, setHoverId] = (0, import_react2.useState)(null);
|
|
1719
|
+
const [hoverEdgeId, setHoverEdgeId] = (0, import_react2.useState)(null);
|
|
1720
|
+
const [selectedEdgeId, setSelectedEdgeId] = (0, import_react2.useState)(null);
|
|
1721
|
+
const [hidden, setHidden] = (0, import_react2.useState)(/* @__PURE__ */ new Set());
|
|
1722
|
+
const [size, setSize] = (0, import_react2.useState)({ width: 0, height });
|
|
1723
|
+
const [query, setQuery] = (0, import_react2.useState)("");
|
|
1724
|
+
const [matchIndex, setMatchIndex] = (0, import_react2.useState)(0);
|
|
1725
|
+
const [showAllResults, setShowAllResults] = (0, import_react2.useState)(false);
|
|
1726
|
+
const [layoutMode, setLayoutMode] = (0, import_react2.useState)("layered");
|
|
1727
|
+
const [colorMode, setColorMode] = (0, import_react2.useState)("tone");
|
|
1728
|
+
const [onlyConnected, setOnlyConnected] = (0, import_react2.useState)(false);
|
|
1729
|
+
const [linkRange, setLinkRange] = (0, import_react2.useState)("hops1");
|
|
1730
|
+
const [minimapVisible, setMinimapVisible] = (0, import_react2.useState)(true);
|
|
1731
|
+
const [layoutEpoch, setLayoutEpoch] = (0, import_react2.useState)(0);
|
|
1732
|
+
const pointersRef = (0, import_react2.useRef)(/* @__PURE__ */ new Map());
|
|
1733
|
+
const pinchPrevRef = (0, import_react2.useRef)(null);
|
|
1734
|
+
const [offsets, setOffsets] = (0, import_react2.useState)({});
|
|
1735
|
+
const wrapRef = (0, import_react2.useRef)(null);
|
|
1736
|
+
const dragRef = (0, import_react2.useRef)({
|
|
1360
1737
|
active: false,
|
|
1361
1738
|
moved: false,
|
|
1362
1739
|
x: 0,
|
|
1363
1740
|
y: 0
|
|
1364
1741
|
});
|
|
1365
|
-
const nodeDragRef = (0,
|
|
1366
|
-
const suppressClickRef = (0,
|
|
1367
|
-
const fittedRef = (0,
|
|
1368
|
-
const lastLocateNonceRef = (0,
|
|
1369
|
-
const counts = (0,
|
|
1370
|
-
const positions = (0,
|
|
1371
|
-
const positionedNodes = (0,
|
|
1372
|
-
const view = (0,
|
|
1742
|
+
const nodeDragRef = (0, import_react2.useRef)(null);
|
|
1743
|
+
const suppressClickRef = (0, import_react2.useRef)(false);
|
|
1744
|
+
const fittedRef = (0, import_react2.useRef)(false);
|
|
1745
|
+
const lastLocateNonceRef = (0, import_react2.useRef)(0);
|
|
1746
|
+
const counts = (0, import_react2.useMemo)(() => kindCounts(graph.nodes), [graph.nodes]);
|
|
1747
|
+
const positions = (0, import_react2.useMemo)(() => layoutPositionsOf(graph.nodes, layoutMode), [graph.nodes, layoutMode]);
|
|
1748
|
+
const positionedNodes = (0, import_react2.useMemo)(() => withLayout(graph.nodes, positions, offsets), [graph.nodes, positions, offsets]);
|
|
1749
|
+
const view = (0, import_react2.useMemo)(
|
|
1373
1750
|
() => filterGraph(positionedNodes, graph.edges, {
|
|
1374
1751
|
hidden,
|
|
1375
|
-
onlyConnectedWith: onlyConnected ? focusId : null
|
|
1752
|
+
onlyConnectedWith: onlyConnected ? focusId : null,
|
|
1753
|
+
maxHops: linkRangeHops(linkRange)
|
|
1376
1754
|
}),
|
|
1377
|
-
[positionedNodes, graph.edges, hidden, onlyConnected, focusId]
|
|
1755
|
+
[positionedNodes, graph.edges, hidden, onlyConnected, focusId, linkRange]
|
|
1378
1756
|
);
|
|
1379
1757
|
const visibleNodes = view.nodes;
|
|
1380
1758
|
const visibleEdges = view.edges;
|
|
1381
|
-
const nodeById = (0,
|
|
1382
|
-
const positionedById = (0,
|
|
1383
|
-
const grid = (0,
|
|
1384
|
-
const bounds = (0,
|
|
1385
|
-
const curvatures = (0,
|
|
1386
|
-
const stageOfColumn = (0,
|
|
1759
|
+
const nodeById = (0, import_react2.useMemo)(() => buildNodeIndex(visibleNodes), [visibleNodes]);
|
|
1760
|
+
const positionedById = (0, import_react2.useMemo)(() => buildNodeIndex(positionedNodes), [positionedNodes]);
|
|
1761
|
+
const grid = (0, import_react2.useMemo)(() => new SpatialGrid(hitNodesOf(visibleNodes)), [visibleNodes]);
|
|
1762
|
+
const bounds = (0, import_react2.useMemo)(() => graphBounds(visibleNodes), [visibleNodes]);
|
|
1763
|
+
const curvatures = (0, import_react2.useMemo)(() => edgeCurvatures(visibleEdges), [visibleEdges]);
|
|
1764
|
+
const stageOfColumn = (0, import_react2.useMemo)(() => {
|
|
1387
1765
|
const map = /* @__PURE__ */ new Map();
|
|
1388
1766
|
for (const column of graph.columns) map.set(column.index, column.stage ?? "");
|
|
1389
1767
|
return map;
|
|
1390
1768
|
}, [graph.columns]);
|
|
1391
|
-
const apply2 = (0,
|
|
1769
|
+
const apply2 = (0, import_react2.useCallback)(
|
|
1392
1770
|
(next) => {
|
|
1393
1771
|
setViewport(clampPan(next, size, bounds));
|
|
1394
1772
|
},
|
|
1395
1773
|
[size, bounds]
|
|
1396
1774
|
);
|
|
1397
|
-
(0,
|
|
1775
|
+
(0, import_react2.useEffect)(() => {
|
|
1398
1776
|
const measure = () => {
|
|
1399
1777
|
const rect = wrapRef.current?.getBoundingClientRect();
|
|
1400
1778
|
if (!rect || rect.width === 0) return;
|
|
@@ -1405,30 +1783,30 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1405
1783
|
if (observer && wrapRef.current) observer.observe(wrapRef.current);
|
|
1406
1784
|
return () => observer?.disconnect();
|
|
1407
1785
|
}, [height]);
|
|
1408
|
-
(0,
|
|
1786
|
+
(0, import_react2.useEffect)(() => {
|
|
1409
1787
|
if (fittedRef.current) return;
|
|
1410
1788
|
if (size.width === 0) return;
|
|
1411
1789
|
fittedRef.current = true;
|
|
1412
1790
|
setViewport(clampPan(fitToView(bounds, size), size, bounds));
|
|
1413
1791
|
}, [size]);
|
|
1414
|
-
(0,
|
|
1792
|
+
(0, import_react2.useEffect)(() => {
|
|
1415
1793
|
if (!fittedRef.current) return;
|
|
1416
1794
|
setViewport((current) => clampPan(current, size, bounds));
|
|
1417
1795
|
}, [size, bounds]);
|
|
1418
|
-
(0,
|
|
1796
|
+
(0, import_react2.useEffect)(() => {
|
|
1419
1797
|
if (layoutEpoch === 0 || !fittedRef.current) return;
|
|
1420
1798
|
setViewport(clampPan(fitToView(bounds, size), size, bounds));
|
|
1421
1799
|
}, [layoutEpoch]);
|
|
1422
|
-
const doFit = (0,
|
|
1800
|
+
const doFit = (0, import_react2.useCallback)(() => {
|
|
1423
1801
|
setViewport(clampPan(fitToView(bounds, size), size, bounds));
|
|
1424
1802
|
}, [bounds, size]);
|
|
1425
|
-
const doZoom = (0,
|
|
1803
|
+
const doZoom = (0, import_react2.useCallback)(
|
|
1426
1804
|
(factor) => {
|
|
1427
1805
|
apply2(zoomBy(viewport, centerOf(size), factor));
|
|
1428
1806
|
},
|
|
1429
1807
|
[apply2, viewport, size]
|
|
1430
1808
|
);
|
|
1431
|
-
const onWheel = (0,
|
|
1809
|
+
const onWheel = (0, import_react2.useCallback)(
|
|
1432
1810
|
(event) => {
|
|
1433
1811
|
event.preventDefault?.();
|
|
1434
1812
|
const rect = wrapRef.current?.getBoundingClientRect();
|
|
@@ -1437,9 +1815,9 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1437
1815
|
},
|
|
1438
1816
|
[apply2, viewport]
|
|
1439
1817
|
);
|
|
1440
|
-
const wheelHandlerRef = (0,
|
|
1818
|
+
const wheelHandlerRef = (0, import_react2.useRef)(onWheel);
|
|
1441
1819
|
wheelHandlerRef.current = onWheel;
|
|
1442
|
-
(0,
|
|
1820
|
+
(0, import_react2.useEffect)(() => {
|
|
1443
1821
|
const host = wrapRef.current;
|
|
1444
1822
|
if (host === null) return void 0;
|
|
1445
1823
|
const listener = (event) => {
|
|
@@ -1450,7 +1828,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1450
1828
|
host.addEventListener("wheel", listener, { passive: false });
|
|
1451
1829
|
return () => host.removeEventListener("wheel", listener);
|
|
1452
1830
|
}, []);
|
|
1453
|
-
const onPointerDown = (0,
|
|
1831
|
+
const onPointerDown = (0, import_react2.useCallback)((event) => {
|
|
1454
1832
|
const id = event.pointerId ?? 0;
|
|
1455
1833
|
pointersRef.current.set(id, { x: event.clientX, y: event.clientY });
|
|
1456
1834
|
if (pointersRef.current.size >= 2) {
|
|
@@ -1462,7 +1840,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1462
1840
|
suppressClickRef.current = false;
|
|
1463
1841
|
dragRef.current = { active: true, moved: false, x: event.clientX, y: event.clientY };
|
|
1464
1842
|
}, []);
|
|
1465
|
-
const onPointerMove = (0,
|
|
1843
|
+
const onPointerMove = (0, import_react2.useCallback)(
|
|
1466
1844
|
(event) => {
|
|
1467
1845
|
const id = event.pointerId ?? 0;
|
|
1468
1846
|
if (pointersRef.current.has(id)) pointersRef.current.set(id, { x: event.clientX, y: event.clientY });
|
|
@@ -1501,14 +1879,14 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1501
1879
|
},
|
|
1502
1880
|
[viewport.scale, size, bounds]
|
|
1503
1881
|
);
|
|
1504
|
-
const onPointerUp = (0,
|
|
1882
|
+
const onPointerUp = (0, import_react2.useCallback)((event) => {
|
|
1505
1883
|
pointersRef.current.delete(event?.pointerId ?? 0);
|
|
1506
1884
|
if (pointersRef.current.size < 2) pinchPrevRef.current = null;
|
|
1507
1885
|
if (nodeDragRef.current !== null && nodeDragRef.current.moved) suppressClickRef.current = true;
|
|
1508
1886
|
nodeDragRef.current = null;
|
|
1509
1887
|
dragRef.current = { active: false, moved: false, x: 0, y: 0 };
|
|
1510
1888
|
}, []);
|
|
1511
|
-
const onNodePointerDown = (0,
|
|
1889
|
+
const onNodePointerDown = (0, import_react2.useCallback)(
|
|
1512
1890
|
(event, nodeId) => {
|
|
1513
1891
|
event.stopPropagation();
|
|
1514
1892
|
suppressClickRef.current = false;
|
|
@@ -1516,7 +1894,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1516
1894
|
},
|
|
1517
1895
|
[]
|
|
1518
1896
|
);
|
|
1519
|
-
const onClick = (0,
|
|
1897
|
+
const onClick = (0, import_react2.useCallback)(
|
|
1520
1898
|
(event) => {
|
|
1521
1899
|
if (dragRef.current.moved || suppressClickRef.current) return;
|
|
1522
1900
|
const rect = wrapRef.current?.getBoundingClientRect();
|
|
@@ -1530,18 +1908,18 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1530
1908
|
},
|
|
1531
1909
|
[grid, viewport, onFocusChange]
|
|
1532
1910
|
);
|
|
1533
|
-
const centreOfNode = (0,
|
|
1911
|
+
const centreOfNode = (0, import_react2.useCallback)(
|
|
1534
1912
|
(node) => ({ x: node.x + NODE_WIDTH / 2, y: node.y + NODE_HEIGHT / 2 }),
|
|
1535
1913
|
[]
|
|
1536
1914
|
);
|
|
1537
|
-
const onNodeDoubleClick = (0,
|
|
1915
|
+
const onNodeDoubleClick = (0, import_react2.useCallback)(
|
|
1538
1916
|
(node) => {
|
|
1539
1917
|
apply2(centerOn(viewport, size, centreOfNode(node)));
|
|
1540
1918
|
onFocusChange(node.id);
|
|
1541
1919
|
},
|
|
1542
1920
|
[apply2, viewport, size, centreOfNode, onFocusChange]
|
|
1543
1921
|
);
|
|
1544
|
-
const locateNode = (0,
|
|
1922
|
+
const locateNode = (0, import_react2.useCallback)(
|
|
1545
1923
|
(nodeId) => {
|
|
1546
1924
|
const node = positionedById.get(nodeId);
|
|
1547
1925
|
if (!node) return;
|
|
@@ -1552,10 +1930,11 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1552
1930
|
},
|
|
1553
1931
|
[apply2, viewport, size, positionedById, centreOfNode, onFocusChange]
|
|
1554
1932
|
);
|
|
1555
|
-
(0,
|
|
1933
|
+
(0, import_react2.useEffect)(() => {
|
|
1556
1934
|
setMatchIndex(0);
|
|
1935
|
+
setShowAllResults(false);
|
|
1557
1936
|
}, [query]);
|
|
1558
|
-
(0,
|
|
1937
|
+
(0, import_react2.useEffect)(() => {
|
|
1559
1938
|
if (locateRequest === null) return;
|
|
1560
1939
|
if (locateRequest.nonce === lastLocateNonceRef.current) return;
|
|
1561
1940
|
lastLocateNonceRef.current = locateRequest.nonce;
|
|
@@ -1563,7 +1942,75 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1563
1942
|
if (!node) return;
|
|
1564
1943
|
setViewport(clampPan(centerOn(viewport, size, centreOfNode(node)), size, bounds));
|
|
1565
1944
|
}, [locateRequest]);
|
|
1566
|
-
const
|
|
1945
|
+
const highlighted = (0, import_react2.useMemo)(() => {
|
|
1946
|
+
if (focusId === null) return /* @__PURE__ */ new Set();
|
|
1947
|
+
const hops = linkRangeHops(linkRange);
|
|
1948
|
+
return hops === null ? traceFrom(focusId, visibleEdges, "both") : kHopNeighborhood(focusId, visibleEdges, hops);
|
|
1949
|
+
}, [focusId, visibleEdges, linkRange]);
|
|
1950
|
+
const edgeDegrees = (0, import_react2.useMemo)(() => degreeTally(visibleEdges), [visibleEdges]);
|
|
1951
|
+
const minimapCanvas = height <= VIEWPORT_HEIGHT_NARROW ? MINIMAP_CANVAS_NARROW : MINIMAP_CANVAS;
|
|
1952
|
+
const minimapProj = (0, import_react2.useMemo)(() => minimapProjection(bounds, minimapCanvas), [bounds]);
|
|
1953
|
+
const minimapRects = (0, import_react2.useMemo)(
|
|
1954
|
+
() => minimapNodeRects(visibleNodes, minimapProj, (node) => colorOf(node, colorMode, (column) => stageOfColumn.get(column))),
|
|
1955
|
+
[visibleNodes, minimapProj, colorMode, stageOfColumn]
|
|
1956
|
+
);
|
|
1957
|
+
const minimapView = (0, import_react2.useMemo)(
|
|
1958
|
+
() => minimapViewportRect(minimapProj, viewport, size),
|
|
1959
|
+
[minimapProj, viewport, size]
|
|
1960
|
+
);
|
|
1961
|
+
const minimapFocusRect = (0, import_react2.useMemo)(() => {
|
|
1962
|
+
if (focusId === null) return null;
|
|
1963
|
+
const rect = minimapRects.find((candidate) => candidate.id === focusId);
|
|
1964
|
+
return rect === void 0 ? null : { x: rect.x, y: rect.y, w: rect.w, h: rect.h };
|
|
1965
|
+
}, [minimapRects, focusId]);
|
|
1966
|
+
const navigateFromMinimap = (0, import_react2.useCallback)(
|
|
1967
|
+
(point) => {
|
|
1968
|
+
const world = minimapToWorld(minimapProj, point);
|
|
1969
|
+
apply2(centerOn(viewport, size, world));
|
|
1970
|
+
},
|
|
1971
|
+
[apply2, minimapProj, viewport, size]
|
|
1972
|
+
);
|
|
1973
|
+
const moveFocusByArrow = (0, import_react2.useCallback)(
|
|
1974
|
+
(direction) => {
|
|
1975
|
+
const nodes = visibleNodes.map((node2) => ({ id: node2.id, x: node2.x + NODE_WIDTH / 2, y: node2.y + NODE_HEIGHT / 2 }));
|
|
1976
|
+
if (nodes.length === 0) return;
|
|
1977
|
+
const current = focusId === null ? void 0 : positionedById.get(focusId);
|
|
1978
|
+
const centreWorld = {
|
|
1979
|
+
x: (size.width / 2 - viewport.tx) / viewport.scale,
|
|
1980
|
+
y: (size.height / 2 - viewport.ty) / viewport.scale
|
|
1981
|
+
};
|
|
1982
|
+
const from = current ? { x: current.x + NODE_WIDTH / 2, y: current.y + NODE_HEIGHT / 2 } : centreWorld;
|
|
1983
|
+
const targetId = directionalCandidate(from, direction, nodes);
|
|
1984
|
+
if (targetId === null) return;
|
|
1985
|
+
onFocusChange(targetId);
|
|
1986
|
+
const host = wrapRef.current;
|
|
1987
|
+
let element = null;
|
|
1988
|
+
if (host) {
|
|
1989
|
+
for (const candidate of host.querySelectorAll("[data-node-id]")) {
|
|
1990
|
+
if (candidate.getAttribute("data-node-id") === targetId) {
|
|
1991
|
+
element = candidate;
|
|
1992
|
+
break;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
const focusable = element;
|
|
1997
|
+
focusable?.focus?.();
|
|
1998
|
+
const node = positionedById.get(targetId);
|
|
1999
|
+
if (node) {
|
|
2000
|
+
const centre = { x: node.x + NODE_WIDTH / 2, y: node.y + NODE_HEIGHT / 2 };
|
|
2001
|
+
const margin = NODE_WIDTH * viewport.scale / 2;
|
|
2002
|
+
if (!isWorldPointVisible(viewport, size, centre, margin)) apply2(centerOn(viewport, size, centre));
|
|
2003
|
+
}
|
|
2004
|
+
},
|
|
2005
|
+
[focusId, positionedById, visibleNodes, onFocusChange, apply2, viewport, size]
|
|
2006
|
+
);
|
|
2007
|
+
const allMatches = (0, import_react2.useMemo)(() => matchNodes(visibleNodes, query), [visibleNodes, query]);
|
|
2008
|
+
const search = (0, import_react2.useMemo)(
|
|
2009
|
+
() => searchSummary(allMatches, showAllResults ? Number.POSITIVE_INFINITY : SEARCH_RESULTS_INITIAL, matchIndex),
|
|
2010
|
+
[allMatches, showAllResults, matchIndex]
|
|
2011
|
+
);
|
|
2012
|
+
const matches = search.visible;
|
|
2013
|
+
const onKeyDown = (0, import_react2.useCallback)(
|
|
1567
2014
|
(event) => {
|
|
1568
2015
|
if (event.key === "Escape") {
|
|
1569
2016
|
event.preventDefault?.();
|
|
@@ -1587,39 +2034,40 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1587
2034
|
if (event.key === "0") {
|
|
1588
2035
|
event.preventDefault?.();
|
|
1589
2036
|
doFit();
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
if (event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "ArrowUp" || event.key === "ArrowDown") {
|
|
2040
|
+
event.preventDefault?.();
|
|
2041
|
+
moveFocusByArrow(event.key.slice(6).toLowerCase());
|
|
1590
2042
|
}
|
|
1591
2043
|
},
|
|
1592
|
-
[doZoom, doFit, onFocusChange]
|
|
2044
|
+
[doZoom, doFit, onFocusChange, moveFocusByArrow]
|
|
1593
2045
|
);
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
const matches = (0, import_react.useMemo)(() => matchNodes(visibleNodes, query), [visibleNodes, query]);
|
|
1599
|
-
const locateMatchNext = (0, import_react.useCallback)(() => {
|
|
1600
|
-
if (matches.length === 0) return;
|
|
1601
|
-
const next = (matchIndex + 1) % matches.length;
|
|
2046
|
+
const locateMatchNext = (0, import_react2.useCallback)(() => {
|
|
2047
|
+
const all = search.all;
|
|
2048
|
+
if (all.length === 0) return;
|
|
2049
|
+
const next = (search.cycleIndex + 1) % all.length;
|
|
1602
2050
|
setMatchIndex(next);
|
|
1603
|
-
const node =
|
|
2051
|
+
const node = all[next];
|
|
1604
2052
|
if (!node) return;
|
|
1605
2053
|
apply2(centerOn(viewport, size, centreOfNode(node)));
|
|
1606
2054
|
onFocusChange(node.id);
|
|
1607
|
-
}, [
|
|
1608
|
-
const matchIds = (0,
|
|
2055
|
+
}, [search, apply2, viewport, size, centreOfNode, onFocusChange]);
|
|
2056
|
+
const matchIds = (0, import_react2.useMemo)(() => new Set(search.all.map((node) => node.id)), [search.all]);
|
|
1609
2057
|
const focusNode = focusId === null ? void 0 : nodeById.get(focusId);
|
|
1610
|
-
const focusDegree = (0,
|
|
1611
|
-
const focusNeighbors = (0,
|
|
2058
|
+
const focusDegree = (0, import_react2.useMemo)(() => focusId === null ? { in: 0, out: 0 } : degreeOf(focusId, visibleEdges), [focusId, visibleEdges]);
|
|
2059
|
+
const focusNeighbors = (0, import_react2.useMemo)(
|
|
1612
2060
|
() => focusId === null ? { upstream: [], downstream: [] } : neighborsOf(focusId, visibleEdges, nodeById),
|
|
1613
2061
|
[focusId, visibleEdges, nodeById]
|
|
1614
2062
|
);
|
|
1615
|
-
const labelOf = (0,
|
|
2063
|
+
const labelOf = (0, import_react2.useCallback)(
|
|
1616
2064
|
(id) => {
|
|
1617
2065
|
const node = nodeById.get(id);
|
|
1618
2066
|
return node ? { label: node.label, tone: node.tone, detail: node.detail } : { label: id, tone: "neutral" };
|
|
1619
2067
|
},
|
|
1620
2068
|
[nodeById]
|
|
1621
2069
|
);
|
|
1622
|
-
const selectedEdgeDetail = (0,
|
|
2070
|
+
const selectedEdgeDetail = (0, import_react2.useMemo)(() => {
|
|
1623
2071
|
if (selectedEdgeId === null) return null;
|
|
1624
2072
|
const edge = visibleEdges.find((e) => e.id === selectedEdgeId);
|
|
1625
2073
|
if (!edge) return null;
|
|
@@ -1661,8 +2109,12 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1661
2109
|
query,
|
|
1662
2110
|
onQuery: setQuery,
|
|
1663
2111
|
matches,
|
|
2112
|
+
matchTotal: search.total,
|
|
2113
|
+
matchOmitted: search.omitted,
|
|
2114
|
+
matchOrdinal: search.cycleIndex + 1,
|
|
2115
|
+
currentMatchId: search.all[search.cycleIndex]?.id ?? null,
|
|
2116
|
+
onToggleResults: () => setShowAllResults((current) => !current),
|
|
1664
2117
|
onLocate: locateNode,
|
|
1665
|
-
matchIndex,
|
|
1666
2118
|
onMatchNext: locateMatchNext,
|
|
1667
2119
|
counts,
|
|
1668
2120
|
hidden,
|
|
@@ -1675,7 +2127,11 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1675
2127
|
}),
|
|
1676
2128
|
onlyConnected,
|
|
1677
2129
|
onToggleConnected: () => setOnlyConnected((current) => !current),
|
|
1678
|
-
connectedAvailable: focusId !== null
|
|
2130
|
+
connectedAvailable: focusId !== null,
|
|
2131
|
+
linkRange,
|
|
2132
|
+
onLinkRange: setLinkRange,
|
|
2133
|
+
minimapVisible,
|
|
2134
|
+
onToggleMinimap: () => setMinimapVisible((current) => !current)
|
|
1679
2135
|
}
|
|
1680
2136
|
),
|
|
1681
2137
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "rg-graph-body", children: [
|
|
@@ -1695,6 +2151,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1695
2151
|
tabIndex: 0,
|
|
1696
2152
|
role: "application",
|
|
1697
2153
|
"aria-label": t("graph.title"),
|
|
2154
|
+
"aria-keyshortcuts": "ArrowUp ArrowDown ArrowLeft ArrowRight + - 0 Escape Enter",
|
|
1698
2155
|
children: [
|
|
1699
2156
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "100%", height: "100%", role: "presentation", children: [
|
|
1700
2157
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("defs", { children: [
|
|
@@ -1716,6 +2173,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1716
2173
|
const hoveredEdge = hoverEdgeId === edge.id;
|
|
1717
2174
|
const selectedEdge = selectedEdgeId === edge.id;
|
|
1718
2175
|
const geometry = edgeGeometry(from, to, curvatures[index] ?? 0);
|
|
2176
|
+
const baseWidth = edgeWidthOf(edgeDegrees, edge);
|
|
1719
2177
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("g", { children: [
|
|
1720
2178
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1721
2179
|
"path",
|
|
@@ -1737,7 +2195,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1737
2195
|
d: geometry.path,
|
|
1738
2196
|
fill: "none",
|
|
1739
2197
|
stroke: selectedEdge || hoveredEdge || active ? "var(--dsw-alias-brand-primary)" : edgeColor(edge),
|
|
1740
|
-
strokeWidth: selectedEdge ?
|
|
2198
|
+
strokeWidth: selectedEdge ? EDGE_WIDTH_MAX + 0.8 : hoveredEdge ? baseWidth + 1 : active ? baseWidth + 0.6 : baseWidth,
|
|
1741
2199
|
strokeOpacity: focusId === null && selectedEdgeId === null ? 0.9 : selectedEdge || hoveredEdge || active ? 1 : 0.22,
|
|
1742
2200
|
markerEnd: selectedEdge || hoveredEdge || active ? "url(#rg-arrow-active)" : "url(#rg-arrow)"
|
|
1743
2201
|
}
|
|
@@ -1755,6 +2213,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1755
2213
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1756
2214
|
"g",
|
|
1757
2215
|
{
|
|
2216
|
+
"data-node-id": node.id,
|
|
1758
2217
|
style: {
|
|
1759
2218
|
transform: `translate(${node.x}px, ${node.y}px)`,
|
|
1760
2219
|
transition: dragged ? "none" : void 0
|
|
@@ -1830,7 +2289,36 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1830
2289
|
})
|
|
1831
2290
|
] })
|
|
1832
2291
|
] }),
|
|
1833
|
-
tooltip && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GraphTooltip, { node: tooltip.node, degree: degreeOf(tooltip.node.id, visibleEdges), x: tooltip.x, y: tooltip.y, containerWidth: size.width })
|
|
2292
|
+
tooltip && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GraphTooltip, { node: tooltip.node, degree: degreeOf(tooltip.node.id, visibleEdges), x: tooltip.x, y: tooltip.y, containerWidth: size.width }),
|
|
2293
|
+
minimapVisible && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "rg-minimap-wrap", children: [
|
|
2294
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2295
|
+
GraphMinimap,
|
|
2296
|
+
{
|
|
2297
|
+
width: minimapCanvas.width,
|
|
2298
|
+
height: minimapCanvas.height,
|
|
2299
|
+
rects: minimapRects,
|
|
2300
|
+
view: minimapView,
|
|
2301
|
+
focusRect: minimapFocusRect,
|
|
2302
|
+
onNavigate: navigateFromMinimap
|
|
2303
|
+
}
|
|
2304
|
+
),
|
|
2305
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "rg-sr-only", children: t("graph.minimapHint") })
|
|
2306
|
+
] }),
|
|
2307
|
+
visibleNodes.length === 0 && (hidden.size > 0 || onlyConnected) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "rg-graph-filtered-empty", role: "status", children: [
|
|
2308
|
+
t("graph.filteredEmpty"),
|
|
2309
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2310
|
+
"button",
|
|
2311
|
+
{
|
|
2312
|
+
type: "button",
|
|
2313
|
+
className: "rg-link",
|
|
2314
|
+
onClick: () => {
|
|
2315
|
+
setHidden(/* @__PURE__ */ new Set());
|
|
2316
|
+
setOnlyConnected(false);
|
|
2317
|
+
},
|
|
2318
|
+
children: t("graph.filteredEmptyReset")
|
|
2319
|
+
}
|
|
2320
|
+
)
|
|
2321
|
+
] })
|
|
1834
2322
|
]
|
|
1835
2323
|
}
|
|
1836
2324
|
),
|
|
@@ -1860,13 +2348,17 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
|
|
|
1860
2348
|
": ",
|
|
1861
2349
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: selectedLabel })
|
|
1862
2350
|
] }),
|
|
1863
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
2351
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "rg-graph-hint", children: [
|
|
2352
|
+
t("graph.hint"),
|
|
2353
|
+
" \xB7 ",
|
|
2354
|
+
t("graph.arrowHint")
|
|
2355
|
+
] })
|
|
1864
2356
|
] })
|
|
1865
2357
|
] });
|
|
1866
2358
|
}
|
|
1867
2359
|
|
|
1868
2360
|
// src/client/PanelCards.tsx
|
|
1869
|
-
var
|
|
2361
|
+
var import_react3 = require("react");
|
|
1870
2362
|
|
|
1871
2363
|
// src/client/panel-model.ts
|
|
1872
2364
|
var STAGE_ORDER = ["idle", "monitoring", "crashed", "deciding", "stabilizing", "recovered"];
|
|
@@ -2143,7 +2635,7 @@ function Card({
|
|
|
2143
2635
|
children,
|
|
2144
2636
|
hint
|
|
2145
2637
|
}) {
|
|
2146
|
-
const [enlarged, setEnlarged] = (0,
|
|
2638
|
+
const [enlarged, setEnlarged] = (0, import_react3.useState)(false);
|
|
2147
2639
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2148
2640
|
"article",
|
|
2149
2641
|
{
|
|
@@ -2266,9 +2758,14 @@ function StabilityRing({ score }) {
|
|
|
2266
2758
|
}
|
|
2267
2759
|
);
|
|
2268
2760
|
}
|
|
2761
|
+
var TRANSITIONS_INITIAL = 8;
|
|
2269
2762
|
function LifecycleBody({ snapshot }) {
|
|
2270
2763
|
const rail = stageRail(snapshot.stage, snapshot.transitions);
|
|
2271
2764
|
const verdict = snapshot.lastRecoveryVerdict;
|
|
2765
|
+
const [showAllTransitions, setShowAllTransitions] = (0, import_react3.useState)(false);
|
|
2766
|
+
const transitionsIndexed = snapshot.transitions.map((transition, index) => ({ transition, index }));
|
|
2767
|
+
const visibleTransitions = showAllTransitions ? transitionsIndexed : transitionsIndexed.slice(-TRANSITIONS_INITIAL);
|
|
2768
|
+
const omittedTransitions = transitionsIndexed.length - visibleTransitions.length;
|
|
2272
2769
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2273
2770
|
verdict !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2274
2771
|
"p",
|
|
@@ -2299,11 +2796,19 @@ function LifecycleBody({ snapshot }) {
|
|
|
2299
2796
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dt", { children: t("state.restored") }),
|
|
2300
2797
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { children: snapshot.restored.length })
|
|
2301
2798
|
] }),
|
|
2302
|
-
snapshot.transitions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("state.noTransitions") }) : /* @__PURE__ */ (0, import_jsx_runtime3.
|
|
2303
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2799
|
+
snapshot.transitions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("state.noTransitions") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2800
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ol", { className: "rg-transitions", children: visibleTransitions.map(({ transition, index }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: "rg-transition", children: [
|
|
2801
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: `rg-badge rg-badge-${transition.to}`, children: stageLabelOf(transition.to) }),
|
|
2802
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rg-transition-reason", title: transition.reason, children: transition.reason }),
|
|
2803
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("time", { className: "rg-transition-time", children: formatClock(transition.at) })
|
|
2804
|
+
] }, `${transition.at}-${index}`)) }),
|
|
2805
|
+
omittedTransitions > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "rg-link rg-risks-expand", onClick: () => setShowAllTransitions(true), children: t("state.moreTransitions", { count: omittedTransitions }) }),
|
|
2806
|
+
showAllTransitions && snapshot.transitions.length > TRANSITIONS_INITIAL && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { type: "button", className: "rg-link", onClick: () => setShowAllTransitions(false), children: [
|
|
2807
|
+
t("state.fewerTransitions"),
|
|
2808
|
+
" \xB7 ",
|
|
2809
|
+
snapshot.transitions.length
|
|
2810
|
+
] })
|
|
2811
|
+
] })
|
|
2307
2812
|
] });
|
|
2308
2813
|
}
|
|
2309
2814
|
function MetricsBody({ snapshot }) {
|
|
@@ -2321,7 +2826,7 @@ function RisksBody({
|
|
|
2321
2826
|
}) {
|
|
2322
2827
|
if (snapshot.risks.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("risks.empty") });
|
|
2323
2828
|
const INITIAL_VISIBLE = 15;
|
|
2324
|
-
const [showAllRisks, setShowAllRisks] = (0,
|
|
2829
|
+
const [showAllRisks, setShowAllRisks] = (0, import_react3.useState)(false);
|
|
2325
2830
|
const visibleRisks = showAllRisks ? snapshot.risks : snapshot.risks.slice(0, INITIAL_VISIBLE);
|
|
2326
2831
|
const hiddenCount = snapshot.risks.length - visibleRisks.length;
|
|
2327
2832
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
@@ -2354,6 +2859,7 @@ function BackupPolicyBody({ snapshot }) {
|
|
|
2354
2859
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("backupPolicy.hint") })
|
|
2355
2860
|
] });
|
|
2356
2861
|
}
|
|
2862
|
+
var CAPABILITY_INITIAL = 8;
|
|
2357
2863
|
function CapabilityBody({
|
|
2358
2864
|
snapshot,
|
|
2359
2865
|
graph,
|
|
@@ -2361,8 +2867,10 @@ function CapabilityBody({
|
|
|
2361
2867
|
onSelect
|
|
2362
2868
|
}) {
|
|
2363
2869
|
const capability = snapshot.capability;
|
|
2364
|
-
const [expanded, setExpanded] = (0,
|
|
2365
|
-
const
|
|
2870
|
+
const [expanded, setExpanded] = (0, import_react3.useState)(false);
|
|
2871
|
+
const allRows = capabilityRows(graph, Number.POSITIVE_INFINITY);
|
|
2872
|
+
const rows = expanded ? allRows : allRows.slice(0, CAPABILITY_INITIAL);
|
|
2873
|
+
const omittedRows = allRows.length - rows.length;
|
|
2366
2874
|
const exposedCount = graph ? graph.nodes.filter((node) => node.kind === "capability" && (node.weight ?? 0) > 0).length : capability.exposed;
|
|
2367
2875
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2368
2876
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("dl", { className: "rg-dl", children: [
|
|
@@ -2420,7 +2928,12 @@ function CapabilityBody({
|
|
|
2420
2928
|
row.id
|
|
2421
2929
|
)) })
|
|
2422
2930
|
] }),
|
|
2423
|
-
|
|
2931
|
+
omittedRows > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "rg-button rg-button-small", onClick: () => setExpanded(true), "aria-expanded": expanded, children: t("capabilities.expand", { count: allRows.length }) }),
|
|
2932
|
+
expanded && allRows.length > CAPABILITY_INITIAL && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { type: "button", className: "rg-button rg-button-small", onClick: () => setExpanded(false), "aria-expanded": expanded, children: [
|
|
2933
|
+
t("capabilities.collapse"),
|
|
2934
|
+
" \xB7 ",
|
|
2935
|
+
allRows.length
|
|
2936
|
+
] })
|
|
2424
2937
|
] }),
|
|
2425
2938
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: "rg-card-subtitle", children: t("capabilities.gaps") }),
|
|
2426
2939
|
capability.gaps.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("capabilities.noGaps") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ul", { className: "rg-gaps", children: capability.gaps.map((gap, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: "rg-gap", children: [
|
|
@@ -2519,7 +3032,7 @@ function PartitionRow({
|
|
|
2519
3032
|
}
|
|
2520
3033
|
var EVENTS_INITIAL = 12;
|
|
2521
3034
|
function EventsBody({ events }) {
|
|
2522
|
-
const [showAll, setShowAll] = (0,
|
|
3035
|
+
const [showAll, setShowAll] = (0, import_react3.useState)(false);
|
|
2523
3036
|
if (events.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("panel.emptyHint") });
|
|
2524
3037
|
const ordered = [...events].reverse();
|
|
2525
3038
|
const visible = showAll ? ordered : ordered.slice(0, EVENTS_INITIAL);
|
|
@@ -2556,7 +3069,7 @@ function ArchivesCard({
|
|
|
2556
3069
|
onArchive,
|
|
2557
3070
|
busy
|
|
2558
3071
|
}) {
|
|
2559
|
-
const [draft, setDraft] = (0,
|
|
3072
|
+
const [draft, setDraft] = (0, import_react3.useState)(reason);
|
|
2560
3073
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("article", { className: "rg-card", "data-card-id": "archives", children: [
|
|
2561
3074
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className: "rg-card-title", children: t("sections.archives") }),
|
|
2562
3075
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-card-note", children: t("archives.explain") }),
|
|
@@ -2602,9 +3115,14 @@ function archiveEntriesOf(payload) {
|
|
|
2602
3115
|
}
|
|
2603
3116
|
|
|
2604
3117
|
// src/client/InsightCards.tsx
|
|
3118
|
+
var import_react4 = require("react");
|
|
2605
3119
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
3120
|
+
var STATIONARY_VISIBLE = 4;
|
|
2606
3121
|
function MarkovBody({ snapshot }) {
|
|
3122
|
+
const [showAllStationary, setShowAllStationary] = (0, import_react4.useState)(false);
|
|
2607
3123
|
const view = markovView(snapshot);
|
|
3124
|
+
const stationaryVisible = showAllStationary ? view.stationary : view.stationary.slice(0, STATIONARY_VISIBLE);
|
|
3125
|
+
const stationaryOmitted = view.stationary.length - stationaryVisible.length;
|
|
2608
3126
|
if (!view.available) {
|
|
2609
3127
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rg-empty", children: t("markov.empty") });
|
|
2610
3128
|
}
|
|
@@ -2630,12 +3148,25 @@ function MarkovBody({ snapshot }) {
|
|
|
2630
3148
|
] }, row.stage)) }),
|
|
2631
3149
|
view.stationary.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rg-markov-stationary", children: [
|
|
2632
3150
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h4", { className: "rg-subhead", children: t("markov.stationary") }),
|
|
2633
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
3151
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rg-chip-row", role: "list", children: [
|
|
3152
|
+
stationaryVisible.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rg-chip", role: "listitem", title: `${entry.stage} ${entry.percent}%`, children: [
|
|
3153
|
+
stageLabelOf(entry.stage, entry.stage),
|
|
3154
|
+
" ",
|
|
3155
|
+
entry.percent,
|
|
3156
|
+
"%"
|
|
3157
|
+
] }, entry.stage)),
|
|
3158
|
+
stationaryOmitted > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3159
|
+
"button",
|
|
3160
|
+
{
|
|
3161
|
+
type: "button",
|
|
3162
|
+
className: "rg-chip rg-chip-more",
|
|
3163
|
+
onClick: () => setShowAllStationary(true),
|
|
3164
|
+
"aria-label": t("markov.stationaryMore", { count: stationaryOmitted }),
|
|
3165
|
+
children: t("markov.stationaryMore", { count: stationaryOmitted })
|
|
3166
|
+
}
|
|
3167
|
+
)
|
|
3168
|
+
] }),
|
|
3169
|
+
showAllStationary && view.stationary.length > STATIONARY_VISIBLE && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "rg-link", onClick: () => setShowAllStationary(false), children: t("markov.stationaryAll", { count: view.stationary.length }) })
|
|
2639
3170
|
] })
|
|
2640
3171
|
] });
|
|
2641
3172
|
}
|
|
@@ -2685,21 +3216,22 @@ function saveCollapsed(cards) {
|
|
|
2685
3216
|
}
|
|
2686
3217
|
}
|
|
2687
3218
|
function GuardPanel(props) {
|
|
2688
|
-
const [snapshot, setSnapshot] = (0,
|
|
2689
|
-
const [graph, setGraph] = (0,
|
|
2690
|
-
const [archives, setArchives] = (0,
|
|
2691
|
-
const [failure, setFailure] = (0,
|
|
2692
|
-
const [busy, setBusy] = (0,
|
|
2693
|
-
const [polling, setPolling] = (0,
|
|
2694
|
-
const [collapsed, setCollapsed] = (0,
|
|
2695
|
-
const [form, setForm] = (0,
|
|
2696
|
-
const [selectedNodeId, setSelectedNodeId] = (0,
|
|
2697
|
-
const [locateRequest, setLocateRequest] = (0,
|
|
2698
|
-
const [requestedKey, setRequestedKey] = (0,
|
|
2699
|
-
const [partitionMismatch, setPartitionMismatch] = (0,
|
|
2700
|
-
const
|
|
2701
|
-
const
|
|
2702
|
-
const
|
|
3219
|
+
const [snapshot, setSnapshot] = (0, import_react5.useState)(null);
|
|
3220
|
+
const [graph, setGraph] = (0, import_react5.useState)(null);
|
|
3221
|
+
const [archives, setArchives] = (0, import_react5.useState)(null);
|
|
3222
|
+
const [failure, setFailure] = (0, import_react5.useState)(null);
|
|
3223
|
+
const [busy, setBusy] = (0, import_react5.useState)(false);
|
|
3224
|
+
const [polling, setPolling] = (0, import_react5.useState)(true);
|
|
3225
|
+
const [collapsed, setCollapsed] = (0, import_react5.useState)(() => loadCollapsed());
|
|
3226
|
+
const [form, setForm] = (0, import_react5.useState)("wide");
|
|
3227
|
+
const [selectedNodeId, setSelectedNodeId] = (0, import_react5.useState)(null);
|
|
3228
|
+
const [locateRequest, setLocateRequest] = (0, import_react5.useState)(null);
|
|
3229
|
+
const [requestedKey, setRequestedKey] = (0, import_react5.useState)(null);
|
|
3230
|
+
const [partitionMismatch, setPartitionMismatch] = (0, import_react5.useState)(null);
|
|
3231
|
+
const [conflictNotice, setConflictNotice] = (0, import_react5.useState)(false);
|
|
3232
|
+
const rootRef = (0, import_react5.useRef)(null);
|
|
3233
|
+
const mounted = (0, import_react5.useRef)(true);
|
|
3234
|
+
const load = (0, import_react5.useCallback)(
|
|
2703
3235
|
async (partitionKey) => {
|
|
2704
3236
|
const [snapshotResult, graphResult, archivesResult] = await Promise.all([
|
|
2705
3237
|
props.fetchSnapshot(partitionKey ?? void 0),
|
|
@@ -2723,7 +3255,7 @@ function GuardPanel(props) {
|
|
|
2723
3255
|
},
|
|
2724
3256
|
[props.fetchSnapshot, props.fetchGraph, props.fetchArchives]
|
|
2725
3257
|
);
|
|
2726
|
-
(0,
|
|
3258
|
+
(0, import_react5.useEffect)(() => {
|
|
2727
3259
|
mounted.current = true;
|
|
2728
3260
|
void load(requestedKey);
|
|
2729
3261
|
if (!polling) {
|
|
@@ -2737,7 +3269,7 @@ function GuardPanel(props) {
|
|
|
2737
3269
|
clearInterval(timer);
|
|
2738
3270
|
};
|
|
2739
3271
|
}, [load, polling, requestedKey]);
|
|
2740
|
-
(0,
|
|
3272
|
+
(0, import_react5.useEffect)(() => {
|
|
2741
3273
|
const measure = () => {
|
|
2742
3274
|
const width = rootRef.current?.getBoundingClientRect().width ?? 0;
|
|
2743
3275
|
if (width > 0) setForm(panelForm(width));
|
|
@@ -2747,20 +3279,30 @@ function GuardPanel(props) {
|
|
|
2747
3279
|
if (observer && rootRef.current) observer.observe(rootRef.current);
|
|
2748
3280
|
return () => observer?.disconnect();
|
|
2749
3281
|
}, []);
|
|
2750
|
-
const runAction = (0,
|
|
3282
|
+
const runAction = (0, import_react5.useCallback)(
|
|
2751
3283
|
async (action, payload = {}) => {
|
|
2752
3284
|
setBusy(true);
|
|
2753
3285
|
try {
|
|
2754
|
-
const
|
|
2755
|
-
|
|
3286
|
+
const inspectingOther = requestedKey !== null;
|
|
3287
|
+
const body = !inspectingOther && snapshot?.revision ? { ...payload, expectedRevision: snapshot.revision } : payload;
|
|
3288
|
+
const result = await props.postAction(action, body);
|
|
3289
|
+
if (!result.ok) {
|
|
3290
|
+
if (result.conflict === "stale-revision") setConflictNotice(true);
|
|
3291
|
+
else {
|
|
3292
|
+
setConflictNotice(false);
|
|
3293
|
+
setFailure(result.reason);
|
|
3294
|
+
}
|
|
3295
|
+
} else {
|
|
3296
|
+
setConflictNotice(false);
|
|
3297
|
+
}
|
|
2756
3298
|
await load(requestedKey);
|
|
2757
3299
|
} finally {
|
|
2758
3300
|
if (mounted.current) setBusy(false);
|
|
2759
3301
|
}
|
|
2760
3302
|
},
|
|
2761
|
-
[props.postAction, load, requestedKey]
|
|
3303
|
+
[props.postAction, load, requestedKey, snapshot?.revision]
|
|
2762
3304
|
);
|
|
2763
|
-
const toggleCollapse = (0,
|
|
3305
|
+
const toggleCollapse = (0, import_react5.useCallback)((card) => {
|
|
2764
3306
|
setCollapsed((current) => {
|
|
2765
3307
|
const next = new Set(current);
|
|
2766
3308
|
if (next.has(card)) next.delete(card);
|
|
@@ -2769,32 +3311,32 @@ function GuardPanel(props) {
|
|
|
2769
3311
|
return next;
|
|
2770
3312
|
});
|
|
2771
3313
|
}, []);
|
|
2772
|
-
const onGraphFocus = (0,
|
|
3314
|
+
const onGraphFocus = (0, import_react5.useCallback)((id) => {
|
|
2773
3315
|
setSelectedNodeId(id);
|
|
2774
3316
|
}, []);
|
|
2775
|
-
const locateInGraph = (0,
|
|
3317
|
+
const locateInGraph = (0, import_react5.useCallback)((id) => {
|
|
2776
3318
|
setSelectedNodeId(id);
|
|
2777
3319
|
if (id !== null) setLocateRequest({ id, nonce: Date.now() });
|
|
2778
3320
|
}, []);
|
|
2779
3321
|
const currentPartition = snapshot?.partitions.find((partition) => partition.key === snapshot.projectKey);
|
|
2780
|
-
const partitionState = (0,
|
|
3322
|
+
const partitionState = (0, import_react5.useMemo)(
|
|
2781
3323
|
() => snapshot === null ? null : partitionView(snapshot, requestedKey ?? snapshot.projectKey),
|
|
2782
3324
|
[snapshot, requestedKey]
|
|
2783
3325
|
);
|
|
2784
3326
|
const graphHeight = form === "narrow" ? VIEWPORT_HEIGHT_NARROW : VIEWPORT_HEIGHT_WIDE;
|
|
2785
|
-
const selectedLabel = (0,
|
|
3327
|
+
const selectedLabel = (0, import_react5.useMemo)(() => {
|
|
2786
3328
|
if (selectedNodeId === null || graph === null) return null;
|
|
2787
3329
|
return graph.nodes.find((node) => node.id === selectedNodeId)?.label ?? null;
|
|
2788
3330
|
}, [selectedNodeId, graph]);
|
|
2789
3331
|
const unavailable = failure !== null && snapshot === null;
|
|
2790
3332
|
const loading = snapshot === null;
|
|
2791
|
-
const [nowTick, setNowTick] = (0,
|
|
2792
|
-
(0,
|
|
3333
|
+
const [nowTick, setNowTick] = (0, import_react5.useState)(() => Date.now());
|
|
3334
|
+
(0, import_react5.useEffect)(() => {
|
|
2793
3335
|
if (polling) return;
|
|
2794
3336
|
const timer = setInterval(() => setNowTick(Date.now()), 6e4);
|
|
2795
3337
|
return () => clearInterval(timer);
|
|
2796
3338
|
}, [polling]);
|
|
2797
|
-
const staleMinutes = (0,
|
|
3339
|
+
const staleMinutes = (0, import_react5.useMemo)(() => {
|
|
2798
3340
|
if (polling || snapshot === null) return 0;
|
|
2799
3341
|
return Math.max(0, Math.round((nowTick - Date.parse(snapshot.at)) / 6e4));
|
|
2800
3342
|
}, [polling, snapshot, nowTick]);
|
|
@@ -2842,6 +3384,11 @@ function GuardPanel(props) {
|
|
|
2842
3384
|
)
|
|
2843
3385
|
] })
|
|
2844
3386
|
] }),
|
|
3387
|
+
conflictNotice && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "rg-notice", role: "status", children: [
|
|
3388
|
+
t("panel.conflictNotice"),
|
|
3389
|
+
" ",
|
|
3390
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "rg-link", onClick: () => setConflictNotice(false), children: t("panel.conflictDismiss") })
|
|
3391
|
+
] }),
|
|
2845
3392
|
partitionMismatch !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "rg-notice", role: "status", children: [
|
|
2846
3393
|
t("partitions.mismatch", {
|
|
2847
3394
|
requested: partitionMismatch.requested.slice(0, 8),
|
|
@@ -3038,11 +3585,11 @@ function GuardPanel(props) {
|
|
|
3038
3585
|
}
|
|
3039
3586
|
|
|
3040
3587
|
// src/client/GuardPanelIcon.ts
|
|
3041
|
-
var
|
|
3588
|
+
var import_react6 = require("react");
|
|
3042
3589
|
function GuardPanelIcon(props) {
|
|
3043
3590
|
const size = typeof props.size === "number" && props.size > 0 ? props.size : 20;
|
|
3044
3591
|
const active = props.active === true;
|
|
3045
|
-
return (0,
|
|
3592
|
+
return (0, import_react6.createElement)(
|
|
3046
3593
|
"svg",
|
|
3047
3594
|
{
|
|
3048
3595
|
width: size,
|
|
@@ -3053,9 +3600,9 @@ function GuardPanelIcon(props) {
|
|
|
3053
3600
|
"aria-label": t("panel.title"),
|
|
3054
3601
|
"aria-hidden": active ? void 0 : "true"
|
|
3055
3602
|
},
|
|
3056
|
-
(0,
|
|
3603
|
+
(0, import_react6.createElement)("title", { key: "title" }, t("panel.title")),
|
|
3057
3604
|
// 盾牌轮廓:守护的隐喻。
|
|
3058
|
-
(0,
|
|
3605
|
+
(0, import_react6.createElement)("path", {
|
|
3059
3606
|
key: "shield",
|
|
3060
3607
|
d: "M12 2.5 4.5 5.2v6.1c0 4.6 3.1 8.9 7.5 10.2 4.4-1.3 7.5-5.6 7.5-10.2V5.2L12 2.5Z",
|
|
3061
3608
|
stroke: active ? "var(--dsw-alias-brand-primary)" : "currentColor",
|
|
@@ -3065,7 +3612,7 @@ function GuardPanelIcon(props) {
|
|
|
3065
3612
|
fillOpacity: active ? 0.14 : 0
|
|
3066
3613
|
}),
|
|
3067
3614
|
// 心跳线:崩溃检测的隐喻。
|
|
3068
|
-
(0,
|
|
3615
|
+
(0, import_react6.createElement)("path", {
|
|
3069
3616
|
key: "pulse",
|
|
3070
3617
|
d: "M6.8 12h2.6l1.5-3.4 2 6.2 1.6-2.8h2.7",
|
|
3071
3618
|
stroke: active ? "var(--dsw-alias-brand-primary)" : "currentColor",
|
|
@@ -3096,7 +3643,21 @@ async function fetchJson(url, init) {
|
|
|
3096
3643
|
headers: { accept: "application/json", ...init?.headers ?? {} }
|
|
3097
3644
|
});
|
|
3098
3645
|
if (!response.ok) {
|
|
3099
|
-
|
|
3646
|
+
let detail = null;
|
|
3647
|
+
try {
|
|
3648
|
+
const parsed = await response.json();
|
|
3649
|
+
if (typeof parsed === "object" && parsed !== null) detail = parsed;
|
|
3650
|
+
} catch {
|
|
3651
|
+
detail = null;
|
|
3652
|
+
}
|
|
3653
|
+
const reason = typeof detail?.reason === "string" && detail.reason.length > 0 ? detail.reason : `HTTP ${response.status}`;
|
|
3654
|
+
return {
|
|
3655
|
+
ok: false,
|
|
3656
|
+
reason,
|
|
3657
|
+
status: response.status,
|
|
3658
|
+
...typeof detail?.conflict === "string" ? { conflict: detail.conflict } : {},
|
|
3659
|
+
...typeof detail?.current === "string" ? { current: detail.current } : {}
|
|
3660
|
+
};
|
|
3100
3661
|
}
|
|
3101
3662
|
const payload = await response.json();
|
|
3102
3663
|
if (typeof payload === "object" && payload !== null && payload.available === false) {
|
|
@@ -3193,12 +3754,12 @@ function integratePanel(ctx) {
|
|
|
3193
3754
|
try {
|
|
3194
3755
|
const panelRegistration = api.register(
|
|
3195
3756
|
{ name: "main", key: PANEL_ID, order: 20, label: () => t("panel.title"), locale: NAMESPACE },
|
|
3196
|
-
() => (0,
|
|
3757
|
+
() => (0, import_react7.createElement)(GuardPanel, { fetchSnapshot, fetchGraph, fetchArchives, postAction })
|
|
3197
3758
|
);
|
|
3198
3759
|
if (typeof panelRegistration === "function") yield panelRegistration;
|
|
3199
3760
|
const iconRegistration = api.register(
|
|
3200
3761
|
{ name: "sidebar.panellist", id: PANEL_ID, order: 20, label: () => t("panel.title"), locale: NAMESPACE },
|
|
3201
|
-
() => (0,
|
|
3762
|
+
() => (0, import_react7.createElement)(GuardPanelIcon)
|
|
3202
3763
|
);
|
|
3203
3764
|
if (typeof iconRegistration === "function") yield iconRegistration;
|
|
3204
3765
|
telemetry.registered = true;
|
|
@@ -3228,7 +3789,7 @@ function integratePanel(ctx) {
|
|
|
3228
3789
|
try {
|
|
3229
3790
|
const iconRegistration = api.register(
|
|
3230
3791
|
{ name: "sidebar.panellist", id: PANEL_ID, order: 20, label: () => t("panel.title"), locale: NAMESPACE },
|
|
3231
|
-
() => (0,
|
|
3792
|
+
() => (0, import_react7.createElement)(GuardPanelIcon)
|
|
3232
3793
|
);
|
|
3233
3794
|
telemetry.registered = true;
|
|
3234
3795
|
telemetry.error = null;
|
|
@@ -3271,30 +3832,108 @@ var styles_default = "/**\n * \u7BA1\u7406\u9762\u677F\u7684\u6837\u5F0F\u3002\n
|
|
|
3271
3832
|
// src/client/styles.ts
|
|
3272
3833
|
var STYLE_ELEMENT_ID = "dsh-recency-guard-styles";
|
|
3273
3834
|
var PANEL_CSS = styles_default;
|
|
3835
|
+
var GRAPH_CSS = `
|
|
3836
|
+
/* ---------- \u5C0F\u5730\u56FE\uFF08Overview + \u7F29\u7565\u5BFC\u822A\uFF09 ---------- */
|
|
3837
|
+
.rg-minimap-wrap {
|
|
3838
|
+
position: absolute;
|
|
3839
|
+
right: 10px;
|
|
3840
|
+
bottom: 10px;
|
|
3841
|
+
/* \u538B\u5728\u300C\u6EE4\u7A7A\u63D0\u793A\u300D\u4E4B\u4E0A\uFF1A\u90A3\u5757\u63D0\u793A\u662F inset:0 \u7684\u6574\u9762\u8986\u76D6\u5C42\uFF0C\u82E5\u4E0D\u7ED9\u5B83\u66F4\u9AD8
|
|
3842
|
+
\u5C42\u7EA7\uFF0C\u56FE\u88AB\u6EE4\u7A7A\u65F6\u7528\u6237\u6070\u597D\u6700\u9700\u8981\u7528\u7684\u590D\u4F4D/\u5207\u6362\u5165\u53E3\u4F1A\u88AB\u906E\u4F4F\u3002 */
|
|
3843
|
+
z-index: 6;
|
|
3844
|
+
display: flex;
|
|
3845
|
+
flex-direction: column;
|
|
3846
|
+
gap: 2px;
|
|
3847
|
+
padding: 4px;
|
|
3848
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
3849
|
+
border-radius: var(--dsw-radius-sm, 8px);
|
|
3850
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
3851
|
+
/* \u534A\u900F\u660E\uFF1A\u5C0F\u5730\u56FE\u662F\u53C2\u7167\u7269\uFF0C\u4E0D\u80FD\u6321\u4F4F\u5B83\u5E95\u4E0B\u7684\u8FB9\u3002 */
|
|
3852
|
+
opacity: 0.92;
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3855
|
+
.rg-minimap {
|
|
3856
|
+
display: block;
|
|
3857
|
+
cursor: crosshair;
|
|
3858
|
+
touch-action: none;
|
|
3859
|
+
border-radius: var(--dsw-radius-xs, 4px);
|
|
3860
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
3861
|
+
}
|
|
3862
|
+
|
|
3863
|
+
/* \u89C6\u53E3\u6846\uFF1A\u5168\u89C8\u6001\u6362\u6210\u865A\u7EBF \u2014\u2014 \u300C\u6846\u94FA\u6EE1\u300D\u4E0E\u300C\u6846\u5728\u5C40\u90E8\u300D\u5FC5\u987B\u80FD\u4E00\u773C\u5206\u8FA8\uFF0C
|
|
3864
|
+
\u5426\u5219\u7528\u6237\u5206\u4E0D\u6E05\u300C\u6211\u5DF2\u7ECF\u770B\u5168\u4E86\u300D\u548C\u300C\u63A7\u4EF6\u51FA\u9519\u4E86\u300D\u3002 */
|
|
3865
|
+
.rg-minimap-view-all {
|
|
3866
|
+
stroke-dasharray: 3 3;
|
|
3867
|
+
}
|
|
3868
|
+
|
|
3869
|
+
/* ---------- \u641C\u7D22\u7ED3\u679C\u300C\u7701\u7565 N \u6761\u300D\u884C ---------- */
|
|
3870
|
+
/* \u5C55\u5F00\u5165\u53E3\u4E0E\u7ED3\u679C\u884C\u4E4B\u95F4\u5FC5\u987B\u770B\u5F97\u51FA\u5206\u754C\uFF1A\u5426\u5219\u5B83\u770B\u8D77\u6765\u50CF\u7B2C 9 \u6761\u7ED3\u679C\uFF0C
|
|
3871
|
+
\u7528\u6237\u4F1A\u53BB\u70B9\u4E00\u4E2A\u4E0D\u662F\u8282\u70B9\u7684\u6309\u94AE\u3002 */
|
|
3872
|
+
.rg-search-omitted {
|
|
3873
|
+
border-top: 1px solid var(--dsw-alias-border-l1);
|
|
3874
|
+
margin-top: 2px;
|
|
3875
|
+
padding-top: 2px;
|
|
3876
|
+
}
|
|
3877
|
+
|
|
3878
|
+
/* ---------- \u8FC7\u6EE4\u6EE4\u7A7A\u7684\u8BDA\u5B9E\u63D0\u793A ---------- */
|
|
3879
|
+
.rg-graph-filtered-empty {
|
|
3880
|
+
position: absolute;
|
|
3881
|
+
inset: 0;
|
|
3882
|
+
display: flex;
|
|
3883
|
+
align-items: center;
|
|
3884
|
+
justify-content: center;
|
|
3885
|
+
gap: 8px;
|
|
3886
|
+
flex-wrap: wrap;
|
|
3887
|
+
padding: 0 16px;
|
|
3888
|
+
text-align: center;
|
|
3889
|
+
font-size: var(--dsw-font-xs-13, 13px);
|
|
3890
|
+
color: var(--dsw-alias-label-secondary);
|
|
3891
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
3892
|
+
pointer-events: auto;
|
|
3893
|
+
}
|
|
3894
|
+
|
|
3895
|
+
/* ---------- \u4EC5\u8BFB\u5C4F\u53EF\u89C1\uFF08\u9F20\u6807\u6377\u5F84\u5FC5\u987B\u53E6\u6709\u7B49\u4EF7\u5165\u53E3\uFF09 ---------- */
|
|
3896
|
+
.rg-sr-only {
|
|
3897
|
+
position: absolute;
|
|
3898
|
+
width: 1px;
|
|
3899
|
+
height: 1px;
|
|
3900
|
+
margin: -1px;
|
|
3901
|
+
padding: 0;
|
|
3902
|
+
overflow: hidden;
|
|
3903
|
+
clip-path: inset(50%);
|
|
3904
|
+
white-space: nowrap;
|
|
3905
|
+
border: 0;
|
|
3906
|
+
}
|
|
3907
|
+
`;
|
|
3908
|
+
var GRAPH_STYLE_ELEMENT_ID = "dsh-recency-guard-graph-styles";
|
|
3274
3909
|
function installStyles(ctx) {
|
|
3275
3910
|
const effect = ctx.effect;
|
|
3276
3911
|
if (typeof effect !== "function") {
|
|
3277
|
-
applyStyle();
|
|
3912
|
+
applyStyle(STYLE_ELEMENT_ID, PANEL_CSS);
|
|
3913
|
+
applyStyle(GRAPH_STYLE_ELEMENT_ID, GRAPH_CSS);
|
|
3278
3914
|
return;
|
|
3279
3915
|
}
|
|
3280
3916
|
effect(
|
|
3281
3917
|
() => {
|
|
3282
|
-
const
|
|
3918
|
+
const elements = [
|
|
3919
|
+
applyStyle(STYLE_ELEMENT_ID, PANEL_CSS),
|
|
3920
|
+
applyStyle(GRAPH_STYLE_ELEMENT_ID, GRAPH_CSS)
|
|
3921
|
+
];
|
|
3283
3922
|
return () => {
|
|
3284
|
-
element?.remove();
|
|
3923
|
+
for (const element of elements) element?.remove();
|
|
3285
3924
|
};
|
|
3286
3925
|
},
|
|
3287
3926
|
"recency-guard: styles"
|
|
3288
3927
|
);
|
|
3289
3928
|
}
|
|
3290
|
-
function applyStyle() {
|
|
3929
|
+
function applyStyle(id, text) {
|
|
3291
3930
|
const doc = globalThis.document;
|
|
3292
3931
|
if (!doc || typeof doc.createElement !== "function") return null;
|
|
3293
|
-
const existing = doc.getElementById(
|
|
3932
|
+
const existing = doc.getElementById(id);
|
|
3294
3933
|
if (existing) return null;
|
|
3295
3934
|
const style = doc.createElement("style");
|
|
3296
|
-
style.id =
|
|
3297
|
-
style.textContent =
|
|
3935
|
+
style.id = id;
|
|
3936
|
+
style.textContent = text;
|
|
3298
3937
|
const parent = doc.head ?? doc.body;
|
|
3299
3938
|
if (!parent) return null;
|
|
3300
3939
|
parent.appendChild(style);
|