@peers-app/peers-ui 0.33.20 → 0.33.22
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/command-palette/command-palette.js +3 -43
- package/dist/components/markdown-editor/autolink-plugin.d.ts +5 -1
- package/dist/components/markdown-editor/autolink-plugin.js +5 -8
- package/dist/components/markdown-editor/blocks.d.ts +83 -0
- package/dist/components/markdown-editor/blocks.js +201 -0
- package/dist/components/markdown-editor/code-plugin.d.ts +21 -0
- package/dist/components/markdown-editor/code-plugin.js +109 -0
- package/dist/components/markdown-editor/editor.d.ts +12 -5
- package/dist/components/markdown-editor/editor.js +27 -6
- package/dist/components/markdown-editor/link-plugin.d.ts +41 -0
- package/dist/components/markdown-editor/link-plugin.js +334 -0
- package/dist/components/markdown-editor/markdown-plugin.d.ts +8 -5
- package/dist/components/markdown-editor/markdown-plugin.js +14 -7
- package/dist/components/markdown-editor/mentions-plugin.js +5 -1
- package/dist/components/markdown-editor/theme.d.ts +35 -0
- package/dist/components/markdown-editor/theme.js +36 -0
- package/dist/components/markdown-editor/toolbar.d.ts +11 -0
- package/dist/components/markdown-editor/toolbar.js +16 -5
- package/dist/components/qr-scanner.js +2 -34
- package/dist/graph/ring-layout.d.ts +62 -0
- package/dist/graph/ring-layout.js +100 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/screens/network-viewer/graph/edge-route.d.ts +33 -0
- package/dist/screens/network-viewer/graph/edge-route.js +133 -0
- package/dist/screens/network-viewer/graph/label-placement.d.ts +54 -0
- package/dist/screens/network-viewer/graph/label-placement.js +134 -0
- package/dist/screens/network-viewer/graph/network-graph-card.d.ts +30 -0
- package/dist/screens/network-viewer/graph/network-graph-card.js +91 -0
- package/dist/screens/network-viewer/graph/network-graph-controls.d.ts +26 -0
- package/dist/screens/network-viewer/graph/network-graph-controls.js +80 -0
- package/dist/screens/network-viewer/graph/network-graph-model.d.ts +282 -0
- package/dist/screens/network-viewer/graph/network-graph-model.js +553 -0
- package/dist/screens/network-viewer/graph/network-graph-settings.d.ts +27 -0
- package/dist/screens/network-viewer/graph/network-graph-settings.js +81 -0
- package/dist/screens/network-viewer/graph/network-graph.d.ts +17 -0
- package/dist/screens/network-viewer/graph/network-graph.js +419 -0
- package/dist/screens/network-viewer/network-viewer.d.ts +3 -2
- package/dist/screens/network-viewer/network-viewer.js +65 -8
- package/dist/tabs-layout/linger.d.ts +75 -0
- package/dist/tabs-layout/linger.js +121 -0
- package/dist/tabs-layout/network-status-details.d.ts +27 -0
- package/dist/tabs-layout/network-status-details.js +203 -0
- package/dist/tabs-layout/network-status-format.d.ts +22 -0
- package/dist/tabs-layout/network-status-format.js +58 -0
- package/dist/tabs-layout/network-status-indicator.d.ts +1 -13
- package/dist/tabs-layout/network-status-indicator.js +27 -133
- package/dist/tabs-layout/network-status-model.d.ts +71 -0
- package/dist/tabs-layout/network-status-model.js +155 -0
- package/dist/tabs-layout/use-network-details-data.d.ts +28 -0
- package/dist/tabs-layout/use-network-details-data.js +90 -0
- package/dist/tabs-layout/use-syncing-look.d.ts +18 -0
- package/dist/tabs-layout/use-syncing-look.js +50 -0
- package/dist/theme.css +846 -0
- package/package.json +10 -8
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NetworkGraphStage = NetworkGraphStage;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ring_layout_1 = require("../../../graph/ring-layout");
|
|
7
|
+
const hooks_1 = require("../../../hooks");
|
|
8
|
+
const edge_route_1 = require("./edge-route");
|
|
9
|
+
const label_placement_1 = require("./label-placement");
|
|
10
|
+
const network_graph_card_1 = require("./network-graph-card");
|
|
11
|
+
const network_graph_model_1 = require("./network-graph-model");
|
|
12
|
+
const network_graph_settings_1 = require("./network-graph-settings");
|
|
13
|
+
function useSize(ref) {
|
|
14
|
+
const [size, setSize] = (0, react_1.useState)({ w: 0, h: 0 });
|
|
15
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
16
|
+
const element = ref.current;
|
|
17
|
+
if (!element)
|
|
18
|
+
return;
|
|
19
|
+
const measure = () => setSize({ w: element.clientWidth, h: element.clientHeight });
|
|
20
|
+
measure();
|
|
21
|
+
if (typeof ResizeObserver === "undefined")
|
|
22
|
+
return;
|
|
23
|
+
const observer = new ResizeObserver(measure);
|
|
24
|
+
observer.observe(element);
|
|
25
|
+
return () => observer.disconnect();
|
|
26
|
+
}, []);
|
|
27
|
+
return size;
|
|
28
|
+
}
|
|
29
|
+
const at = (p) => `translate(${p.x.toFixed(1)}px, ${p.y.toFixed(1)}px)`;
|
|
30
|
+
/** How big a node is drawn: this device biggest, then its connections, then theirs. */
|
|
31
|
+
function radiusOf(placed) {
|
|
32
|
+
return placed.ring === 0 ? 15 : placed.ring === 1 ? 11 : placed.ring === 2 ? 7 : 6;
|
|
33
|
+
}
|
|
34
|
+
function shorten(text, max) {
|
|
35
|
+
return text.length > max ? `${text.slice(0, max - 1).trimEnd()}…` : text;
|
|
36
|
+
}
|
|
37
|
+
/** The font size of a name, in pixels, by ring: this device, its connections, the rest. */
|
|
38
|
+
const LABEL_FONT = [14, 12, 11];
|
|
39
|
+
/**
|
|
40
|
+
* The name drawn beside a device: its owner first when it's someone else's, shortened to fit its
|
|
41
|
+
* ring, with how many more it stands for.
|
|
42
|
+
*/
|
|
43
|
+
function nodeLabelText(node, placed, desktop, more) {
|
|
44
|
+
const name = (0, network_graph_model_1.graphName)(node);
|
|
45
|
+
// Room for an owner in front of the name.
|
|
46
|
+
const owned = name === node.name ? 0 : 8;
|
|
47
|
+
const fit = placed.ring === 0
|
|
48
|
+
? 40
|
|
49
|
+
: placed.ring === 3
|
|
50
|
+
? 12
|
|
51
|
+
: desktop
|
|
52
|
+
? placed.ring === 1
|
|
53
|
+
? 24
|
|
54
|
+
: 18
|
|
55
|
+
: placed.ring === 1
|
|
56
|
+
? 16
|
|
57
|
+
: 12;
|
|
58
|
+
return `${shorten(name, fit + owned)}${more ? ` +${more} more` : ""}`;
|
|
59
|
+
}
|
|
60
|
+
/** The most offline devices drawn on the outer ring; the List has them all. */
|
|
61
|
+
const MAX_OFFLINE = 24;
|
|
62
|
+
/** The same, on a phone. */
|
|
63
|
+
const MAX_OFFLINE_PHONE = 10;
|
|
64
|
+
/**
|
|
65
|
+
* The Graph view's stage: this device at the center, its connections around it and theirs
|
|
66
|
+
* further out, with the card for whatever is selected.
|
|
67
|
+
*
|
|
68
|
+
* Arrows point at the device that was chosen to sync with. A dotted line is a connection no
|
|
69
|
+
* group chose. Dots move the way the data does, bigger for more of it. Hovering a device or a
|
|
70
|
+
* connection brings out its neighbors; clicking keeps it selected.
|
|
71
|
+
*/
|
|
72
|
+
function NetworkGraphStage(props) {
|
|
73
|
+
const { graph, desktop } = props;
|
|
74
|
+
const wrap = (0, react_1.useRef)(null);
|
|
75
|
+
const { w, h } = useSize(wrap);
|
|
76
|
+
const [shows] = (0, hooks_1.useObservable)(network_graph_settings_1.networkGraphShows);
|
|
77
|
+
const [groupIds] = (0, hooks_1.useObservable)(network_graph_settings_1.networkGraphGroupIds);
|
|
78
|
+
const selectedGroupIds = (0, react_1.useMemo)(() => groupIds.filter((id) => graph.groups.some((group) => group.groupId === id)), [groupIds, graph.groups]);
|
|
79
|
+
const [selection, setSelection] = (0, react_1.useState)();
|
|
80
|
+
const [hover, setHover] = (0, react_1.useState)();
|
|
81
|
+
// What each connection usually manages, learned while the viewer is open.
|
|
82
|
+
const history = (0, react_1.useRef)(new network_graph_model_1.LatencyHistory());
|
|
83
|
+
(0, react_1.useEffect)(() => {
|
|
84
|
+
const now = Date.now();
|
|
85
|
+
for (const edge of graph.edges) {
|
|
86
|
+
if (edge.own && edge.latencyMs !== undefined) {
|
|
87
|
+
history.current.record(edge.key, edge.latencyMs, now);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
history.current.keepOnly(new Set(graph.edges.map((edge) => edge.key)));
|
|
91
|
+
}, [graph]);
|
|
92
|
+
const healthOf = (edge) => (0, network_graph_model_1.edgeHealth)(edge.latencyMs, edge.errorRate, history.current.usual(edge.key));
|
|
93
|
+
// Room for the card at the right on a wide screen, the controls above, the legend below.
|
|
94
|
+
const cardRoom = desktop && w > 820 ? 290 : 0;
|
|
95
|
+
const top = 54;
|
|
96
|
+
const bottom = desktop ? 64 : Math.min(260, h * 0.42);
|
|
97
|
+
const cx = (w - cardRoom) / 2;
|
|
98
|
+
const cy = top + (h - top - bottom) / 2;
|
|
99
|
+
const rx = Math.max(70, cx - (desktop ? 90 : 50));
|
|
100
|
+
const ry = Math.max(60, (h - top - bottom) / 2 - 26);
|
|
101
|
+
// The layout depends on which devices there are and how they connect, not on live numbers,
|
|
102
|
+
// so a refresh that changes only latency or traffic moves nothing.
|
|
103
|
+
const shape = (0, react_1.useMemo)(() => [...graph.nodes.values()]
|
|
104
|
+
.map((node) => `${node.key}:${node.kind}:${node.name}:${node.offline ? 1 : 0}`)
|
|
105
|
+
.concat(graph.edges.map((edge) => edge.key))
|
|
106
|
+
.join("|"), [graph]);
|
|
107
|
+
const graphRef = (0, react_1.useRef)(graph);
|
|
108
|
+
graphRef.current = graph;
|
|
109
|
+
// `shape` stands in for the graph in the dependencies below.
|
|
110
|
+
const layout = (0, react_1.useMemo)(() => {
|
|
111
|
+
// Offline devices have no connections; they sit on a ring of their own outside the rest,
|
|
112
|
+
// which draw in closer to leave it room.
|
|
113
|
+
const offline = shows.offline
|
|
114
|
+
? (0, network_graph_model_1.offlineNodes)(graphRef.current, desktop ? MAX_OFFLINE : MAX_OFFLINE_PHONE)
|
|
115
|
+
: { shown: [], more: 0 };
|
|
116
|
+
const inner = offline.shown.length ? 0.66 : 1;
|
|
117
|
+
const laid = (0, ring_layout_1.layoutRings)({
|
|
118
|
+
center: graphRef.current.selfId,
|
|
119
|
+
neighbors: (0, network_graph_model_1.neighborsFor)(graphRef.current, shows),
|
|
120
|
+
steps: shows.steps,
|
|
121
|
+
rx: rx * inner,
|
|
122
|
+
ry: ry * inner,
|
|
123
|
+
});
|
|
124
|
+
(0, ring_layout_1.fitRingLayout)(laid.nodes, (w - cardRoom - (desktop ? 200 : 110)) * inner, (h - top - bottom - 70) * inner);
|
|
125
|
+
offline.shown.forEach((node, index) => {
|
|
126
|
+
const angle = -Math.PI / 2 + ((index + 0.5) * 2 * Math.PI) / offline.shown.length;
|
|
127
|
+
laid.nodes.push({
|
|
128
|
+
key: node.key,
|
|
129
|
+
x: Math.cos(angle) * rx,
|
|
130
|
+
y: Math.sin(angle) * ry,
|
|
131
|
+
ring: 3,
|
|
132
|
+
angle,
|
|
133
|
+
span: (2 * Math.PI) / offline.shown.length,
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
return { ...laid, offlineMore: offline.more };
|
|
137
|
+
}, [shape, shows, rx, ry, w, h, cardRoom, top, bottom, desktop]);
|
|
138
|
+
const placed = new Map(layout.nodes.map((node) => [node.key, node]));
|
|
139
|
+
// A line between two other devices that would pass over a third bends around it; straight
|
|
140
|
+
// through, it reads as a connection through that device. This device's own lines run out from
|
|
141
|
+
// the center to the first ring, with nothing between.
|
|
142
|
+
const circles = layout.nodes.map((p) => ({ key: p.key, x: p.x, y: p.y, r: radiusOf(p) }));
|
|
143
|
+
const linesFrom = new Map();
|
|
144
|
+
for (const edge of graph.edges) {
|
|
145
|
+
const a = placed.get(edge.a);
|
|
146
|
+
const b = placed.get(edge.b);
|
|
147
|
+
if (!a || !b)
|
|
148
|
+
continue;
|
|
149
|
+
linesFrom.set(edge.a, [...(linesFrom.get(edge.a) ?? []), b]);
|
|
150
|
+
linesFrom.set(edge.b, [...(linesFrom.get(edge.b) ?? []), a]);
|
|
151
|
+
}
|
|
152
|
+
const linesAt = (key) => linesFrom.get(key) ?? [];
|
|
153
|
+
const edges = [];
|
|
154
|
+
for (const edge of graph.edges) {
|
|
155
|
+
const from = placed.get(edge.a);
|
|
156
|
+
const to = placed.get(edge.b);
|
|
157
|
+
if (!from || !to)
|
|
158
|
+
continue;
|
|
159
|
+
edges.push({
|
|
160
|
+
bend: edge.own
|
|
161
|
+
? undefined
|
|
162
|
+
: (0, edge_route_1.bendAround)({ key: from.key, x: from.x, y: from.y, r: radiusOf(from) }, { key: to.key, x: to.x, y: to.y, r: radiusOf(to) }, circles, linesAt),
|
|
163
|
+
edge,
|
|
164
|
+
view: (0, network_graph_model_1.viewEdge)(edge, selectedGroupIds),
|
|
165
|
+
health: healthOf(edge),
|
|
166
|
+
from,
|
|
167
|
+
to,
|
|
168
|
+
transport: edge.own
|
|
169
|
+
? (0, network_graph_model_1.transportOf)(graph.nodes.get(edge.b)?.connection?.connectionAddress)
|
|
170
|
+
: undefined,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// Each name goes on the side of its device where it hides the least: an outlined name over
|
|
174
|
+
// an arrowhead would hide it. This device's name is placed first, then its connections'.
|
|
175
|
+
const labelSides = (0, label_placement_1.placeLabels)([...layout.nodes]
|
|
176
|
+
.sort((a, b) => a.ring - b.ring)
|
|
177
|
+
.map((p) => {
|
|
178
|
+
const node = graph.nodes.get(p.key);
|
|
179
|
+
const font = LABEL_FONT[Math.min(p.ring, 2)];
|
|
180
|
+
return {
|
|
181
|
+
key: p.key,
|
|
182
|
+
x: p.x,
|
|
183
|
+
y: p.y,
|
|
184
|
+
r: radiusOf(p),
|
|
185
|
+
...(0, label_placement_1.estimateLabelSize)(nodeLabelText(node, p, desktop, layout.more.get(p.key)), font, p.ring === 0),
|
|
186
|
+
};
|
|
187
|
+
}), edges.flatMap(({ edge, view, from, to, bend }) => {
|
|
188
|
+
const ends = { a: edge.a, b: edge.b };
|
|
189
|
+
if (!bend) {
|
|
190
|
+
const line = span(from, to, 0, 0);
|
|
191
|
+
return [
|
|
192
|
+
{
|
|
193
|
+
...ends,
|
|
194
|
+
x1: line.x1,
|
|
195
|
+
y1: line.y1,
|
|
196
|
+
x2: line.x2,
|
|
197
|
+
y2: line.y2,
|
|
198
|
+
arrowAtA: view.bPrefersA,
|
|
199
|
+
arrowAtB: view.aPrefersB,
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
// A bent line counts as two straight halves, each with the arrowhead at its own end.
|
|
204
|
+
const start = toward(from, bend, radiusOf(from));
|
|
205
|
+
const end = toward(to, bend, radiusOf(to));
|
|
206
|
+
const mid = (0, edge_route_1.pointOnCurve)(from, bend, to, 0.5);
|
|
207
|
+
return [
|
|
208
|
+
{ ...ends, x1: start.x, y1: start.y, x2: mid.x, y2: mid.y },
|
|
209
|
+
{ ...ends, x1: mid.x, y1: mid.y, x2: end.x, y2: end.y },
|
|
210
|
+
].map((half, index) => ({
|
|
211
|
+
...half,
|
|
212
|
+
arrowAtA: index === 0 && view.bPrefersA,
|
|
213
|
+
arrowAtB: index === 1 && view.aPrefersB,
|
|
214
|
+
}));
|
|
215
|
+
}));
|
|
216
|
+
// A selection whose device or connection has gone is dropped.
|
|
217
|
+
const live = (item) => {
|
|
218
|
+
if (!item)
|
|
219
|
+
return undefined;
|
|
220
|
+
if (item.kind === "node")
|
|
221
|
+
return placed.has(item.key) ? item : undefined;
|
|
222
|
+
return edges.some((drawn) => drawn.edge.key === item.key) ? item : undefined;
|
|
223
|
+
};
|
|
224
|
+
const selected = live(selection);
|
|
225
|
+
const focus = live(hover) ?? selected;
|
|
226
|
+
const onEdges = new Set();
|
|
227
|
+
const onNodes = new Set();
|
|
228
|
+
if (focus?.kind === "node") {
|
|
229
|
+
onNodes.add(focus.key);
|
|
230
|
+
for (const { edge } of edges) {
|
|
231
|
+
if (edge.a !== focus.key && edge.b !== focus.key)
|
|
232
|
+
continue;
|
|
233
|
+
onEdges.add(edge.key);
|
|
234
|
+
onNodes.add(edge.a).add(edge.b);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else if (focus?.kind === "edge") {
|
|
238
|
+
const drawn = edges.find((item) => item.edge.key === focus.key);
|
|
239
|
+
if (drawn) {
|
|
240
|
+
onEdges.add(drawn.edge.key);
|
|
241
|
+
onNodes.add(drawn.edge.a).add(drawn.edge.b);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// With a group filter, a device none of whose connections are in the filter is dimmed.
|
|
245
|
+
const inFilter = new Set([graph.selfId]);
|
|
246
|
+
for (const { edge, view } of edges) {
|
|
247
|
+
if (view.inFilter)
|
|
248
|
+
inFilter.add(edge.a).add(edge.b);
|
|
249
|
+
}
|
|
250
|
+
const dimNode = (node) => selectedGroupIds.length > 0 && !inFilter.has(node.key) && !node.offline;
|
|
251
|
+
const select = (item) => setSelection((current) => current?.kind === item.kind && current.key === item.key ? undefined : item);
|
|
252
|
+
const self = graph.nodes.get(graph.selfId);
|
|
253
|
+
(0, react_1.useEffect)(() => {
|
|
254
|
+
const key = (event) => {
|
|
255
|
+
if (event.key === "Escape")
|
|
256
|
+
setSelection(undefined);
|
|
257
|
+
};
|
|
258
|
+
document.addEventListener("keydown", key);
|
|
259
|
+
return () => document.removeEventListener("keydown", key);
|
|
260
|
+
}, []);
|
|
261
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-net-wrap", ref: wrap, children: [w && h ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("svg", { className: `peers-net-svg${focus ? " is-hl" : ""}`, viewBox: `${(-cx).toFixed(1)} ${(-cy).toFixed(1)} ${w} ${h}`, role: "img", "aria-label": `Connections around ${self.name}`, children: [(0, jsx_runtime_1.jsx)("defs", { children: ["ok", "faint", "slow", "failing", "on"].map((kind) => ((0, jsx_runtime_1.jsx)("marker", { id: `peers-net-arrow-${kind}`, className: `peers-net-arrow is-${kind}`, viewBox: "0 0 10 10", refX: "8", refY: "5", markerWidth: "6.5", markerHeight: "6.5", orient: "auto-start-reverse", children: (0, jsx_runtime_1.jsx)("path", { d: "M0 0 L10 5 L0 10 z" }) }, kind))) }), (0, jsx_runtime_1.jsx)("rect", { className: "peers-net-bg", x: -cx, y: -cy, width: w, height: h, onClick: () => setSelection(undefined) }), (0, jsx_runtime_1.jsx)("g", { children: edges.map((drawn) => ((0, jsx_runtime_1.jsx)(Edge, { drawn: drawn, on: onEdges.has(drawn.edge.key), selected: selected?.kind === "edge" && selected.key === drawn.edge.key, label: edgeLabel(graph, drawn), onSelect: () => select({ kind: "edge", key: drawn.edge.key }), onHover: (over) => setHover(over ? { kind: "edge", key: drawn.edge.key } : undefined) }, drawn.edge.key))) }), (0, jsx_runtime_1.jsx)("g", { children: layout.nodes.map((p) => {
|
|
262
|
+
const node = graph.nodes.get(p.key);
|
|
263
|
+
return ((0, jsx_runtime_1.jsx)(Node, { placed: p, node: node, desktop: desktop, labelSide: labelSides.get(p.key) ?? "below", more: layout.more.get(p.key), dim: dimNode(node), state: focus?.kind === "node" && focus.key === p.key
|
|
264
|
+
? " is-on"
|
|
265
|
+
: onNodes.has(p.key)
|
|
266
|
+
? " is-nb"
|
|
267
|
+
: "", selected: selected?.kind === "node" && selected.key === p.key, onSelect: () => node.kind === "self"
|
|
268
|
+
? setSelection(undefined)
|
|
269
|
+
: select({ kind: "node", key: p.key }), onHover: (over) => setHover(over ? { kind: "node", key: p.key } : undefined) }, p.key));
|
|
270
|
+
}) }), layout.nodes.every((node) => node.ring === 0 || node.ring === 3) ? ((0, jsx_runtime_1.jsx)("text", { className: "peers-net-alone", y: 52, children: "No devices are connected" })) : null] }), (0, jsx_runtime_1.jsx)("div", { className: "peers-net-notes", "aria-hidden": "true", children: edges.map((drawn) => ((0, jsx_runtime_1.jsx)(EdgeNote, { drawn: drawn, on: onEdges.has(drawn.edge.key), faded: !!focus && !onEdges.has(drawn.edge.key), cx: cx, cy: cy, desktop: desktop }, drawn.edge.key))) })] })) : null, (0, jsx_runtime_1.jsx)(network_graph_card_1.NetworkGraphCard, { graph: graph, overview: props.overview, selection: selected, selectedGroupIds: selectedGroupIds, health: healthOf, actions: { ...props.actions, onSelectNode: (key) => setSelection({ kind: "node", key }) }, onClose: () => setSelection(undefined) }), layout.offlineMore ? ((0, jsx_runtime_1.jsxs)("div", { className: "peers-net-more", children: ["and ", layout.offlineMore, " more offline ", layout.offlineMore === 1 ? "device" : "devices", ", in the List"] })) : null, desktop ? (0, jsx_runtime_1.jsx)(Legend, {}) : null] }));
|
|
271
|
+
}
|
|
272
|
+
/** What a screen reader hears for a connection. */
|
|
273
|
+
function edgeLabel(graph, { edge, view, health }) {
|
|
274
|
+
const a = graph.nodes.get(edge.a)?.name ?? "";
|
|
275
|
+
const b = graph.nodes.get(edge.b)?.name ?? "";
|
|
276
|
+
const choice = view.aPrefersB && view.bPrefersA
|
|
277
|
+
? "they chose each other"
|
|
278
|
+
: view.aPrefersB
|
|
279
|
+
? `${a} chose ${b}`
|
|
280
|
+
: view.bPrefersA
|
|
281
|
+
? `${b} chose ${a}`
|
|
282
|
+
: "connected, not chosen";
|
|
283
|
+
const state = health === "ok" ? "" : `${health}, `;
|
|
284
|
+
return `Connection between ${a} and ${b}: ${state}${(0, network_graph_model_1.formatLatency)(edge.latencyMs)}, ${choice}`;
|
|
285
|
+
}
|
|
286
|
+
/** The ends of a connection's line, stopping short of each device. */
|
|
287
|
+
function span(from, to, gapFrom, gapTo) {
|
|
288
|
+
const dx = to.x - from.x;
|
|
289
|
+
const dy = to.y - from.y;
|
|
290
|
+
const length = Math.hypot(dx, dy) || 1;
|
|
291
|
+
const ux = dx / length;
|
|
292
|
+
const uy = dy / length;
|
|
293
|
+
const start = radiusOf(from) + gapFrom;
|
|
294
|
+
const end = radiusOf(to) + gapTo;
|
|
295
|
+
return {
|
|
296
|
+
x1: from.x + ux * start,
|
|
297
|
+
y1: from.y + uy * start,
|
|
298
|
+
x2: to.x - ux * end,
|
|
299
|
+
y2: to.y - uy * end,
|
|
300
|
+
// A unit vector across the line, for drawing beside it.
|
|
301
|
+
nx: -uy,
|
|
302
|
+
ny: ux,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/** A point moved `distance` from `from` towards `to`. */
|
|
306
|
+
function toward(from, to, distance) {
|
|
307
|
+
const length = Math.hypot(to.x - from.x, to.y - from.y) || 1;
|
|
308
|
+
return {
|
|
309
|
+
x: from.x + ((to.x - from.x) / length) * distance,
|
|
310
|
+
y: from.y + ((to.y - from.y) / length) * distance,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* A connection's line as an SVG path, stopping short of each device, with its middle and a unit
|
|
315
|
+
* vector across it there. A bent line leaves each device towards its bend.
|
|
316
|
+
*/
|
|
317
|
+
function route(drawn, gapFrom, gapTo) {
|
|
318
|
+
const { from, to, bend } = drawn;
|
|
319
|
+
const line = span(from, to, gapFrom, gapTo);
|
|
320
|
+
const n = (value) => value.toFixed(1);
|
|
321
|
+
if (!bend) {
|
|
322
|
+
return {
|
|
323
|
+
d: `M${n(line.x1)} ${n(line.y1)}L${n(line.x2)} ${n(line.y2)}`,
|
|
324
|
+
mid: { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 },
|
|
325
|
+
nx: line.nx,
|
|
326
|
+
ny: line.ny,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
const start = toward(from, bend, radiusOf(from) + gapFrom);
|
|
330
|
+
const end = toward(to, bend, radiusOf(to) + gapTo);
|
|
331
|
+
return {
|
|
332
|
+
d: `M${n(start.x)} ${n(start.y)}Q${n(bend.x)} ${n(bend.y)} ${n(end.x)} ${n(end.y)}`,
|
|
333
|
+
// At its middle a bent line runs parallel to the straight one.
|
|
334
|
+
mid: (0, edge_route_1.pointOnCurve)(from, bend, to, 0.5),
|
|
335
|
+
nx: line.nx,
|
|
336
|
+
ny: line.ny,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* A connection: its line and arrowheads, the dots for data moving on it, and a wide invisible
|
|
341
|
+
* line to hover and click.
|
|
342
|
+
*/
|
|
343
|
+
function Edge(props) {
|
|
344
|
+
const { edge, view, health, from, to } = props.drawn;
|
|
345
|
+
const chosen = view.aPrefersB || view.bPrefersA;
|
|
346
|
+
// An arrowhead needs room to stop short of the device it points at.
|
|
347
|
+
const path = route(props.drawn, view.bPrefersA ? 6 : 3, view.aPrefersB ? 6 : 3);
|
|
348
|
+
// A healthy line between two other devices gets a quieter arrowhead, like its line.
|
|
349
|
+
const arrow = props.on ? "on" : health === "ok" && !edge.own ? "faint" : health;
|
|
350
|
+
const marker = `url(#peers-net-arrow-${arrow})`;
|
|
351
|
+
const out = edge.own ? (0, network_graph_model_1.trafficStep)(edge.sendBps) : 0;
|
|
352
|
+
const into = edge.own ? (0, network_graph_model_1.trafficStep)(edge.receiveBps) : 0;
|
|
353
|
+
// Two streams run either side of the line, each on the right of its own direction.
|
|
354
|
+
const beside = out && into ? 4.5 : 0;
|
|
355
|
+
const dots = span(from, to, 14, 14);
|
|
356
|
+
const className = `peers-net-e${edge.own ? "" : " r2"}${chosen ? "" : " is-un"}` +
|
|
357
|
+
`${health === "ok" ? "" : ` is-${health}`}${props.on ? " is-on" : ""}` +
|
|
358
|
+
`${view.inFilter ? "" : " is-dim"}${props.selected ? " is-sel" : ""}`;
|
|
359
|
+
return ((0, jsx_runtime_1.jsxs)("g", { className: className, children: [(0, jsx_runtime_1.jsx)("path", { className: "peers-net-el", d: path.d, markerStart: view.bPrefersA ? marker : undefined, markerEnd: view.aPrefersB ? marker : undefined }), out ? ((0, jsx_runtime_1.jsx)("line", { className: `peers-net-dots s${out}`, x1: (dots.x1 + dots.nx * beside).toFixed(1), y1: (dots.y1 + dots.ny * beside).toFixed(1), x2: (dots.x2 + dots.nx * beside).toFixed(1), y2: (dots.y2 + dots.ny * beside).toFixed(1) })) : null, into ? ((0, jsx_runtime_1.jsx)("line", { className: `peers-net-dots s${into}`, x1: (dots.x2 - dots.nx * beside).toFixed(1), y1: (dots.y2 - dots.ny * beside).toFixed(1), x2: (dots.x1 - dots.nx * beside).toFixed(1), y2: (dots.y1 - dots.ny * beside).toFixed(1) })) : null, (0, jsx_runtime_1.jsx)("path", { className: "peers-net-hit", role: "button", tabIndex: 0, "aria-label": props.label, "aria-pressed": props.selected, d: path.d, onClick: props.onSelect, onKeyDown: (event) => {
|
|
360
|
+
if (event.key !== "Enter" && event.key !== " ")
|
|
361
|
+
return;
|
|
362
|
+
event.preventDefault();
|
|
363
|
+
props.onSelect();
|
|
364
|
+
}, onPointerEnter: () => props.onHover(true), onPointerLeave: () => props.onHover(false), onFocus: () => props.onHover(true), onBlur: () => props.onHover(false) })] }));
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* The words beside a connection: nothing while it's healthy and unremarkable, "Slow · 379 ms"
|
|
368
|
+
* when it isn't, and its numbers while it's highlighted.
|
|
369
|
+
*/
|
|
370
|
+
function EdgeNote(props) {
|
|
371
|
+
const { edge, health } = props.drawn;
|
|
372
|
+
if (props.faded || (!props.on && health === "ok"))
|
|
373
|
+
return null;
|
|
374
|
+
const line = route(props.drawn, 0, 0);
|
|
375
|
+
const left = props.cx + line.mid.x;
|
|
376
|
+
const topAt = props.cy + line.mid.y;
|
|
377
|
+
if (!props.on) {
|
|
378
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `peers-net-flag is-${health}`, style: { left: left + line.nx * 14, top: topAt + line.ny * 14 }, children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-exclamation-triangle-fill" }), health === "slow" ? "Slow" : "Failing", " \u00B7 ", (0, network_graph_model_1.formatLatency)(edge.latencyMs)] }));
|
|
379
|
+
}
|
|
380
|
+
const parts = [(0, network_graph_model_1.formatLatency)(edge.latencyMs)];
|
|
381
|
+
if (edge.own) {
|
|
382
|
+
if (props.drawn.transport)
|
|
383
|
+
parts.push(props.drawn.transport);
|
|
384
|
+
const rates = [
|
|
385
|
+
(0, network_graph_model_1.trafficStep)(edge.sendBps) ? `↑ ${(0, network_graph_model_1.formatRate)(edge.sendBps)}` : "",
|
|
386
|
+
(0, network_graph_model_1.trafficStep)(edge.receiveBps) ? `↓ ${(0, network_graph_model_1.formatRate)(edge.receiveBps)}` : "",
|
|
387
|
+
].filter(Boolean);
|
|
388
|
+
if (rates.length)
|
|
389
|
+
parts.push(rates.join(" "));
|
|
390
|
+
}
|
|
391
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: `peers-net-chip${health === "ok" ? "" : ` is-${health}`}`, style: { left, top: topAt }, children: parts.join(" · ") }));
|
|
392
|
+
}
|
|
393
|
+
/** A device: its circle and its name. */
|
|
394
|
+
function Node(props) {
|
|
395
|
+
const { placed, node, desktop, labelSide } = props;
|
|
396
|
+
const r = radiusOf(placed);
|
|
397
|
+
const isCenter = placed.ring === 0;
|
|
398
|
+
const className = `peers-net-n ring-${Math.min(placed.ring, 2)} k-${node.kind}` +
|
|
399
|
+
`${node.offline ? " is-offline" : ""}${props.dim ? " is-dim" : ""}` +
|
|
400
|
+
`${props.selected ? " is-sel" : ""}${props.state}`;
|
|
401
|
+
const label = node.kind === "self"
|
|
402
|
+
? `${node.name}, this device`
|
|
403
|
+
: `${node.name}${node.kind === "mine" ? ", yours" : node.owner ? `, ${node.owner}'s` : ""}` +
|
|
404
|
+
`${node.offline ? ", not connected" : ""}`;
|
|
405
|
+
return ((0, jsx_runtime_1.jsxs)("g", { className: className, role: "button", tabIndex: 0, "aria-label": label, "aria-pressed": isCenter ? undefined : props.selected, style: { transform: at(placed) }, onClick: props.onSelect, onKeyDown: (event) => {
|
|
406
|
+
if (event.key !== "Enter" && event.key !== " ")
|
|
407
|
+
return;
|
|
408
|
+
event.preventDefault();
|
|
409
|
+
props.onSelect();
|
|
410
|
+
}, onPointerEnter: () => props.onHover(true), onPointerLeave: () => props.onHover(false), onFocus: () => props.onHover(true), onBlur: () => props.onHover(false), children: [(0, jsx_runtime_1.jsx)("circle", { className: "peers-net-nh", r: Math.max(r + 6, 18) }), (0, jsx_runtime_1.jsx)("circle", { className: "peers-net-ns", r: r }), (0, jsx_runtime_1.jsx)("text", { className: `peers-net-nl is-${labelSide}`, x: labelSide === "right" ? r + 4 : labelSide === "left" ? -(r + 4) : 0, y: labelSide === "above"
|
|
411
|
+
? -(r + (isCenter ? 8 : 7))
|
|
412
|
+
: labelSide === "below"
|
|
413
|
+
? r + (isCenter ? 17 : 15)
|
|
414
|
+
: 4, children: nodeLabelText(node, placed, desktop, props.more) })] }));
|
|
415
|
+
}
|
|
416
|
+
/** What the shapes and lines mean. */
|
|
417
|
+
function Legend() {
|
|
418
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-net-legend", "aria-hidden": "true", children: [(0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)("i", { className: "peers-net-lg is-mine" }), "Yours"] }), (0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)("i", { className: "peers-net-lg" }), "Someone else's"] }), (0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)("i", { className: "peers-net-lg is-service" }), "peers.app"] }), (0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsxs)("svg", { width: "26", height: "10", viewBox: "0 0 26 10", "aria-hidden": "true", children: [(0, jsx_runtime_1.jsx)("path", { className: "peers-net-lg-line", d: "M1 5H18" }), (0, jsx_runtime_1.jsx)("path", { className: "peers-net-lg-head", d: "M17 1L25 5L17 9z" })] }), "Chose it to sync with"] }), (0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)("svg", { width: "22", height: "10", viewBox: "0 0 22 10", "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("path", { className: "peers-net-lg-dotted", d: "M1 5H21" }) }), "Connected only"] }), (0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsxs)("svg", { width: "30", height: "10", viewBox: "0 0 30 10", "aria-hidden": "true", children: [(0, jsx_runtime_1.jsx)("circle", { className: "peers-net-lg-head", cx: "4", cy: "5", r: "1.75" }), (0, jsx_runtime_1.jsx)("circle", { className: "peers-net-lg-head", cx: "13", cy: "5", r: "2.75" }), (0, jsx_runtime_1.jsx)("circle", { className: "peers-net-lg-head", cx: "24", cy: "5", r: "4" })] }), "Data moving: under 10 KB/s, under 1 MB/s, more"] })] }));
|
|
419
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Network Viewer screen.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Opens on the graph: this device, the devices it's connected to, and the devices those are
|
|
5
|
+
* connected to. The list keeps the tables of connections, group sync and disconnected devices.
|
|
6
|
+
* It also hosts the Sync Recovery pane selected from the network status indicator.
|
|
6
7
|
*/
|
|
7
8
|
export declare function NetworkViewerList(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,11 +6,16 @@ const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const loading_indicator_1 = require("../../components/loading-indicator");
|
|
8
8
|
const trust_level_badge_1 = require("../../components/trust-level-badge");
|
|
9
|
+
const globals_1 = require("../../globals");
|
|
9
10
|
const hooks_1 = require("../../hooks");
|
|
10
11
|
const local_network_offer_1 = require("../../local-network/local-network-offer");
|
|
11
12
|
const ui_loader_1 = require("../../ui-router/ui-loader");
|
|
12
13
|
const connection_troubleshooter_1 = require("./connection-troubleshooter");
|
|
13
14
|
const device_details_modal_1 = require("./device-details-modal");
|
|
15
|
+
const network_graph_1 = require("./graph/network-graph");
|
|
16
|
+
const network_graph_controls_1 = require("./graph/network-graph-controls");
|
|
17
|
+
const network_graph_model_1 = require("./graph/network-graph-model");
|
|
18
|
+
const network_graph_settings_1 = require("./graph/network-graph-settings");
|
|
14
19
|
const group_details_modal_1 = require("./group-details-modal");
|
|
15
20
|
const network_viewer_ipc_1 = require("./network-viewer-ipc");
|
|
16
21
|
const network_viewer_section_1 = require("./network-viewer-section");
|
|
@@ -37,11 +42,16 @@ function formatRate(mbps) {
|
|
|
37
42
|
}
|
|
38
43
|
return `${mbps.toFixed(2)} MB/s`;
|
|
39
44
|
}
|
|
45
|
+
/** How often the graph asks for fresh numbers, in milliseconds. Its reads call no other device. */
|
|
46
|
+
const GRAPH_REFRESH_MS = 2000;
|
|
47
|
+
/** How often the list asks for fresh numbers, in milliseconds. */
|
|
48
|
+
const LIST_REFRESH_MS = 5000;
|
|
40
49
|
/**
|
|
41
50
|
* Network Viewer screen.
|
|
42
51
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
52
|
+
* Opens on the graph: this device, the devices it's connected to, and the devices those are
|
|
53
|
+
* connected to. The list keeps the tables of connections, group sync and disconnected devices.
|
|
54
|
+
* It also hosts the Sync Recovery pane selected from the network status indicator.
|
|
45
55
|
*/
|
|
46
56
|
function NetworkViewerList() {
|
|
47
57
|
const [overview, setOverview] = (0, react_1.useState)(null);
|
|
@@ -55,15 +65,34 @@ function NetworkViewerList() {
|
|
|
55
65
|
const [connecting, setConnecting] = (0, react_1.useState)(new Set());
|
|
56
66
|
const [showTroubleshooter, setShowTroubleshooter] = (0, react_1.useState)(false);
|
|
57
67
|
const [viewerSection] = (0, hooks_1.useObservable)(network_viewer_section_1.networkViewerSection);
|
|
68
|
+
const [view] = (0, hooks_1.useObservable)(network_graph_settings_1.networkViewerView);
|
|
69
|
+
const [desktop] = (0, hooks_1.useObservable)(globals_1.isDesktop);
|
|
70
|
+
const [topology, setTopology] = (0, react_1.useState)();
|
|
71
|
+
// An older host doesn't provide the topology tool; ask once, then draw without it.
|
|
72
|
+
const topologyUnsupported = (0, react_1.useRef)(false);
|
|
58
73
|
const loadData = (0, react_1.useCallback)(async () => {
|
|
59
74
|
try {
|
|
60
75
|
const diagnostics = await (0, network_viewer_ipc_1.getNetworkDiagnosticsConsumer)();
|
|
61
|
-
const
|
|
76
|
+
const readTopology = async () => {
|
|
77
|
+
if (topologyUnsupported.current)
|
|
78
|
+
return undefined;
|
|
79
|
+
try {
|
|
80
|
+
return (await diagnostics.tools.getTopology()).topology;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (String(error).includes("does not provide tool"))
|
|
84
|
+
topologyUnsupported.current = true;
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const [{ overview: overviewData }, { connections: connectionsData }, { groups: groupSyncData }, { devices: disconnectedData }, topologyData,] = await Promise.all([
|
|
62
89
|
diagnostics.tools.getOverview(),
|
|
63
90
|
diagnostics.tools.getConnections(),
|
|
64
91
|
diagnostics.tools.getGroupSyncStatus(),
|
|
65
92
|
diagnostics.tools.getDisconnectedDevices(),
|
|
93
|
+
readTopology(),
|
|
66
94
|
]);
|
|
95
|
+
setTopology(topologyData);
|
|
67
96
|
setOverview(overviewData);
|
|
68
97
|
setConnections(connectionsData);
|
|
69
98
|
setGroupSyncInfo(groupSyncData);
|
|
@@ -158,10 +187,22 @@ function NetworkViewerList() {
|
|
|
158
187
|
};
|
|
159
188
|
(0, react_1.useEffect)(() => {
|
|
160
189
|
loadData();
|
|
161
|
-
//
|
|
162
|
-
const interval = setInterval(
|
|
190
|
+
// Refresh while the window is showing; a hidden one has nobody to refresh for.
|
|
191
|
+
const interval = setInterval(() => {
|
|
192
|
+
if (document.visibilityState !== "hidden")
|
|
193
|
+
loadData();
|
|
194
|
+
}, view === "graph" ? GRAPH_REFRESH_MS : LIST_REFRESH_MS);
|
|
163
195
|
return () => clearInterval(interval);
|
|
164
|
-
}, [loadData]);
|
|
196
|
+
}, [loadData, view]);
|
|
197
|
+
const graph = (0, react_1.useMemo)(() => overview
|
|
198
|
+
? (0, network_graph_model_1.buildNetworkGraph)({
|
|
199
|
+
overview,
|
|
200
|
+
connections,
|
|
201
|
+
groupSync: groupSyncInfo,
|
|
202
|
+
disconnected: disconnectedDevices,
|
|
203
|
+
topology,
|
|
204
|
+
})
|
|
205
|
+
: undefined, [overview, connections, groupSyncInfo, disconnectedDevices, topology]);
|
|
165
206
|
(0, react_1.useEffect)(() => {
|
|
166
207
|
if (viewerSection === "sync-recovery") {
|
|
167
208
|
setShowTroubleshooter(false);
|
|
@@ -179,7 +220,23 @@ function NetworkViewerList() {
|
|
|
179
220
|
if (showTroubleshooter) {
|
|
180
221
|
return (0, jsx_runtime_1.jsx)(connection_troubleshooter_1.ConnectionTroubleshooter, { onBack: () => setShowTroubleshooter(false) });
|
|
181
222
|
}
|
|
182
|
-
|
|
223
|
+
const modals = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [selectedDeviceId && ((0, jsx_runtime_1.jsx)(device_details_modal_1.DeviceDetailsModal, { deviceId: selectedDeviceId, onClose: () => setSelectedDeviceId(null), onDisconnect: loadData })), selectedGroupId && ((0, jsx_runtime_1.jsx)(group_details_modal_1.GroupDetailsModal, { groupId: selectedGroupId, onClose: () => setSelectedGroupId(null) }))] }));
|
|
224
|
+
if (view === "graph" && graph) {
|
|
225
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `peers-net${desktop ? "" : " is-phone"}`, children: [(0, jsx_runtime_1.jsx)("h2", { className: "visually-hidden", children: "Network Viewer" }), (0, jsx_runtime_1.jsx)(network_graph_controls_1.TopBar, { graph: graph, desktop: desktop, actions: {
|
|
226
|
+
onRefresh: handleRefresh,
|
|
227
|
+
refreshing,
|
|
228
|
+
onTroubleshoot: (0, network_viewer_ipc_1.getNetworkViewerPlatformApi)()?.runDiagnostics
|
|
229
|
+
? () => setShowTroubleshooter(true)
|
|
230
|
+
: undefined,
|
|
231
|
+
onSyncRecovery: () => (0, network_viewer_section_1.networkViewerSection)("sync-recovery"),
|
|
232
|
+
} }), (0, jsx_runtime_1.jsx)(network_graph_1.NetworkGraphStage, { graph: graph, overview: overview, desktop: desktop, actions: {
|
|
233
|
+
onViewDetails: handleViewDetails,
|
|
234
|
+
onDisconnect: handleDisconnect,
|
|
235
|
+
onConnect: handleConnectToDevice,
|
|
236
|
+
connecting,
|
|
237
|
+
} }), modals] }));
|
|
238
|
+
}
|
|
239
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-between align-items-center mb-4 flex-wrap gap-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center gap-3 peers-net-scope", children: [(0, jsx_runtime_1.jsx)("h2", { className: "mb-0", children: "Network Viewer" }), (0, jsx_runtime_1.jsx)(network_graph_controls_1.ViewSwitch, {})] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, network_viewer_ipc_1.getNetworkViewerPlatformApi)()?.runDiagnostics && ((0, jsx_runtime_1.jsxs)("button", { className: "btn btn-sm btn-outline-warning", onClick: () => setShowTroubleshooter(true), title: "Run connection diagnostics", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-stethoscope me-1" }), "Troubleshoot"] })), (0, jsx_runtime_1.jsx)("button", { className: "btn btn-sm btn-outline-secondary", onClick: () => (0, network_viewer_section_1.networkViewerSection)("sync-recovery"), title: "Records that could not be materialized", children: "Sync recovery" }), (0, jsx_runtime_1.jsxs)("button", { className: "btn btn-sm btn-primary", onClick: handleRefresh, disabled: refreshing, children: [(0, jsx_runtime_1.jsx)("i", { className: `bi bi-arrow-clockwise ${refreshing ? "spin" : ""}` }), refreshing ? " Refreshing..." : " Refresh"] })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "card mb-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsx)("h5", { className: "card-title", children: "Local Device" }), (0, jsx_runtime_1.jsxs)("div", { className: "row", children: [(0, jsx_runtime_1.jsxs)("div", { className: "col-md-6", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Device ID:" }), " ", (0, jsx_runtime_1.jsx)("code", { className: "text-muted small", children: overview.localDeviceId })] }), (0, jsx_runtime_1.jsxs)("div", { className: "col-md-6", children: [(0, jsx_runtime_1.jsx)("strong", { children: "User ID:" }), " ", (0, jsx_runtime_1.jsx)("code", { className: "text-muted small", children: overview.localUserId })] })] }), (0, jsx_runtime_1.jsx)(local_network_offer_1.LocalNetworkRow, {})] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "row mb-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "col-md-4", children: (0, jsx_runtime_1.jsx)("div", { className: "card", style: { height: "100%" }, children: (0, jsx_runtime_1.jsx)("div", { className: "card-body p-2", children: (0, jsx_runtime_1.jsx)(usage_graph_1.UsageGraph, { label: "Connections", fetchUsage: async () => {
|
|
183
240
|
const diagnostics = await (0, network_viewer_ipc_1.getNetworkDiagnosticsConsumer)();
|
|
184
241
|
const { overview: currentOverview } = await diagnostics.tools.getOverview();
|
|
185
242
|
return currentOverview.totalConnections;
|
|
@@ -227,7 +284,7 @@ function NetworkViewerList() {
|
|
|
227
284
|
? new Date(group.lastSyncTimestamp).toLocaleString()
|
|
228
285
|
: "Never" }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("button", { className: "btn btn-sm btn-outline-primary", onClick: () => setSelectedGroupId(group.groupId), title: "View Group Details", children: group.totalMembers }) })] }, group.groupId))) })] }) }))] }) }), (0, jsx_runtime_1.jsx)("div", { className: "card", children: (0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsx)("h5", { className: "card-title", children: "Disconnected Devices" }), disconnectedDevices.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: "text-muted", children: "No known disconnected devices" })) : ((0, jsx_runtime_1.jsx)("div", { className: "table-responsive", children: (0, jsx_runtime_1.jsxs)("table", { className: "table table-hover", children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { children: "User" }), (0, jsx_runtime_1.jsx)("th", { children: "Trust Level" }), (0, jsx_runtime_1.jsx)("th", { children: "Device ID" }), (0, jsx_runtime_1.jsx)("th", { children: "Device Name" }), (0, jsx_runtime_1.jsx)("th", { children: "First Seen" }), (0, jsx_runtime_1.jsx)("th", { children: "Last Seen" }), (0, jsx_runtime_1.jsx)("th", { children: "Actions" })] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: disconnectedDevices
|
|
229
286
|
.sort((a, b) => new Date(b.lastSeen).getTime() - new Date(a.lastSeen).getTime())
|
|
230
|
-
.map((device) => ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsxs)("td", { children: [device.userName || device.userId, !device.userName && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("small", { className: "text-muted", children: device.userId })] }))] }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)(trust_level_badge_1.TrustLevelBadge, { level: device.trustLevel || peers_sdk_1.TrustLevel.Unknown }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("code", { className: "text-muted small", children: device.deviceId }) }), (0, jsx_runtime_1.jsx)("td", { children: device.name || (0, jsx_runtime_1.jsx)("span", { className: "text-muted", children: "-" }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("small", { children: new Date(device.firstSeen).toLocaleString() }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("small", { children: new Date(device.lastSeen).toLocaleString() }) }), (0, jsx_runtime_1.jsxs)("td", { children: [(0, jsx_runtime_1.jsx)("button", { className: "btn btn-sm btn-outline-success me-2", onClick: () => handleConnectToDevice(device.deviceId), disabled: connecting.has(device.deviceId), title: "Connect to device", children: connecting.has(device.deviceId) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "spinner-border spinner-border-sm me-1", role: "status", "aria-hidden": "true" }), "Connecting..."] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-arrow-right-circle" }), " Connect"] })) }), (0, jsx_runtime_1.jsx)("button", { className: "btn btn-sm btn-outline-danger", onClick: () => handleDeleteDevice(device.deviceId), title: "Forget this device", children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-trash" }) })] })] }, device.deviceId))) })] }) }))] }) }),
|
|
287
|
+
.map((device) => ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsxs)("td", { children: [device.userName || device.userId, !device.userName && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("small", { className: "text-muted", children: device.userId })] }))] }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)(trust_level_badge_1.TrustLevelBadge, { level: device.trustLevel || peers_sdk_1.TrustLevel.Unknown }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("code", { className: "text-muted small", children: device.deviceId }) }), (0, jsx_runtime_1.jsx)("td", { children: device.name || (0, jsx_runtime_1.jsx)("span", { className: "text-muted", children: "-" }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("small", { children: new Date(device.firstSeen).toLocaleString() }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("small", { children: new Date(device.lastSeen).toLocaleString() }) }), (0, jsx_runtime_1.jsxs)("td", { children: [(0, jsx_runtime_1.jsx)("button", { className: "btn btn-sm btn-outline-success me-2", onClick: () => handleConnectToDevice(device.deviceId), disabled: connecting.has(device.deviceId), title: "Connect to device", children: connecting.has(device.deviceId) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "spinner-border spinner-border-sm me-1", role: "status", "aria-hidden": "true" }), "Connecting..."] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-arrow-right-circle" }), " Connect"] })) }), (0, jsx_runtime_1.jsx)("button", { className: "btn btn-sm btn-outline-danger", onClick: () => handleDeleteDevice(device.deviceId), title: "Forget this device", children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-trash" }) })] })] }, device.deviceId))) })] }) }))] }) }), modals] }));
|
|
231
288
|
}
|
|
232
289
|
(0, ui_loader_1.registerInternalPeersUI)({
|
|
233
290
|
peersUIId: "network-viewer-list-ui",
|