@peers-app/peers-ui 0.33.20 → 0.33.21
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/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 +635 -0
- package/package.json +3 -3
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ring layout for a graph drawn around one node: the center, what it connects to on the first
|
|
3
|
+
* ring, what those connect to on the second, and so on. Plain math with no rendering, so each
|
|
4
|
+
* view draws its own nodes and edges. Lifted from the Notes package's Graph view.
|
|
5
|
+
*/
|
|
6
|
+
/** A node's place: its ring (0 is the center), angle, and the slice of circle it owns. */
|
|
7
|
+
export interface RingPlaced {
|
|
8
|
+
key: string;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
/** How many steps from the center. */
|
|
12
|
+
ring: number;
|
|
13
|
+
/** Direction from the center, in radians; straight up is `-Math.PI / 2`. */
|
|
14
|
+
angle: number;
|
|
15
|
+
/** The arc this node owns; its own neighbors fan out inside it. */
|
|
16
|
+
span: number;
|
|
17
|
+
/** The node it was reached from. */
|
|
18
|
+
parent?: string;
|
|
19
|
+
}
|
|
20
|
+
/** What {@link layoutRings} needs. */
|
|
21
|
+
export interface RingLayoutOptions {
|
|
22
|
+
/** The node at the center. */
|
|
23
|
+
center: string;
|
|
24
|
+
/** A node's neighbors, in the order to place them. Unknown keys return an empty list. */
|
|
25
|
+
neighbors: (key: string) => readonly string[];
|
|
26
|
+
/** How many rings; 0 for as many as there are. */
|
|
27
|
+
steps: number;
|
|
28
|
+
/** How far the outer ring reaches across. */
|
|
29
|
+
rx: number;
|
|
30
|
+
/** How far the outer ring reaches up and down. */
|
|
31
|
+
ry: number;
|
|
32
|
+
/** The most nodes to place, center included. 60 unless set. */
|
|
33
|
+
maxNodes?: number;
|
|
34
|
+
}
|
|
35
|
+
/** A laid-out graph. */
|
|
36
|
+
export interface RingLayout {
|
|
37
|
+
/** The placed nodes, center first, then ring by ring. */
|
|
38
|
+
nodes: RingPlaced[];
|
|
39
|
+
/** For a node whose neighbors didn't all fit under the cap, how many were left out. */
|
|
40
|
+
more: Map<string, number>;
|
|
41
|
+
}
|
|
42
|
+
/** The most nodes a layout places unless told otherwise. */
|
|
43
|
+
export declare const RING_LAYOUT_MAX_NODES = 60;
|
|
44
|
+
/**
|
|
45
|
+
* Lay a graph out in rings around the center, one step per ring. The first ring shares the
|
|
46
|
+
* whole circle; each node's own neighbors fan out inside its slice. A node is placed once, on
|
|
47
|
+
* the first ring that reaches it. Nodes with no path to the center are left out.
|
|
48
|
+
*
|
|
49
|
+
* @param options - The center, the neighbors of each node, and the room there is.
|
|
50
|
+
* @returns Each placed node, and how many neighbors the cap left out per node.
|
|
51
|
+
*/
|
|
52
|
+
export declare function layoutRings(options: RingLayoutOptions): RingLayout;
|
|
53
|
+
/**
|
|
54
|
+
* Fit a layout to the space it has: center its nodes in it, and stretch each direction (up to
|
|
55
|
+
* half again) to fill it. Rings are laid out around the center, so a graph that grows one way
|
|
56
|
+
* would otherwise leave the other side empty.
|
|
57
|
+
*
|
|
58
|
+
* @param nodes - The laid-out nodes; they're moved in place.
|
|
59
|
+
* @param width - The room across, after margins for labels.
|
|
60
|
+
* @param height - The room up and down, after margins for labels.
|
|
61
|
+
*/
|
|
62
|
+
export declare function fitRingLayout(nodes: RingPlaced[], width: number, height: number): void;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ring layout for a graph drawn around one node: the center, what it connects to on the first
|
|
4
|
+
* ring, what those connect to on the second, and so on. Plain math with no rendering, so each
|
|
5
|
+
* view draws its own nodes and edges. Lifted from the Notes package's Graph view.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.RING_LAYOUT_MAX_NODES = void 0;
|
|
9
|
+
exports.layoutRings = layoutRings;
|
|
10
|
+
exports.fitRingLayout = fitRingLayout;
|
|
11
|
+
/** The most nodes a layout places unless told otherwise. */
|
|
12
|
+
exports.RING_LAYOUT_MAX_NODES = 60;
|
|
13
|
+
/**
|
|
14
|
+
* Lay a graph out in rings around the center, one step per ring. The first ring shares the
|
|
15
|
+
* whole circle; each node's own neighbors fan out inside its slice. A node is placed once, on
|
|
16
|
+
* the first ring that reaches it. Nodes with no path to the center are left out.
|
|
17
|
+
*
|
|
18
|
+
* @param options - The center, the neighbors of each node, and the room there is.
|
|
19
|
+
* @returns Each placed node, and how many neighbors the cap left out per node.
|
|
20
|
+
*/
|
|
21
|
+
function layoutRings(options) {
|
|
22
|
+
const { center, neighbors, steps, rx, ry } = options;
|
|
23
|
+
const maxNodes = options.maxNodes ?? exports.RING_LAYOUT_MAX_NODES;
|
|
24
|
+
const placed = new Map([
|
|
25
|
+
[center, { key: center, x: 0, y: 0, ring: 0, angle: -Math.PI / 2, span: 2 * Math.PI }],
|
|
26
|
+
]);
|
|
27
|
+
const more = new Map();
|
|
28
|
+
const rings = [[center]];
|
|
29
|
+
const last = steps === 0 ? Number.POSITIVE_INFINITY : steps;
|
|
30
|
+
for (let ring = 1; ring <= last; ring++) {
|
|
31
|
+
const next = [];
|
|
32
|
+
for (const parentKey of rings[ring - 1]) {
|
|
33
|
+
const parent = placed.get(parentKey);
|
|
34
|
+
const wanted = [...new Set(neighbors(parentKey))].filter((key) => !placed.has(key));
|
|
35
|
+
const kids = wanted.slice(0, Math.max(0, maxNodes - placed.size));
|
|
36
|
+
if (kids.length < wanted.length)
|
|
37
|
+
more.set(parentKey, wanted.length - kids.length);
|
|
38
|
+
if (!kids.length)
|
|
39
|
+
continue;
|
|
40
|
+
const span = ring === 1 ? 2 * Math.PI : parent.span * 0.9;
|
|
41
|
+
kids.forEach((key, index) => {
|
|
42
|
+
const angle = ring === 1
|
|
43
|
+
? -Math.PI / 2 + (index * span) / kids.length
|
|
44
|
+
: parent.angle - span / 2 + ((index + 0.5) * span) / kids.length;
|
|
45
|
+
placed.set(key, {
|
|
46
|
+
key,
|
|
47
|
+
x: 0,
|
|
48
|
+
y: 0,
|
|
49
|
+
ring,
|
|
50
|
+
angle,
|
|
51
|
+
span: span / kids.length,
|
|
52
|
+
parent: parentKey,
|
|
53
|
+
});
|
|
54
|
+
next.push(key);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (!next.length)
|
|
58
|
+
break;
|
|
59
|
+
rings.push(next);
|
|
60
|
+
}
|
|
61
|
+
const deepest = rings.length - 1;
|
|
62
|
+
for (const node of placed.values()) {
|
|
63
|
+
if (!node.ring)
|
|
64
|
+
continue;
|
|
65
|
+
const f = (node.ring / deepest) ** 0.85;
|
|
66
|
+
// A single ring stays close to the center instead of spreading to the edges.
|
|
67
|
+
const fx = deepest === 1 ? Math.min(270, rx * 0.78) : rx * f;
|
|
68
|
+
const fy = deepest === 1 ? Math.min(220, ry * 0.78) : ry * f;
|
|
69
|
+
node.x = Math.cos(node.angle) * fx;
|
|
70
|
+
node.y = Math.sin(node.angle) * fy;
|
|
71
|
+
}
|
|
72
|
+
return { nodes: [...placed.values()], more };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Fit a layout to the space it has: center its nodes in it, and stretch each direction (up to
|
|
76
|
+
* half again) to fill it. Rings are laid out around the center, so a graph that grows one way
|
|
77
|
+
* would otherwise leave the other side empty.
|
|
78
|
+
*
|
|
79
|
+
* @param nodes - The laid-out nodes; they're moved in place.
|
|
80
|
+
* @param width - The room across, after margins for labels.
|
|
81
|
+
* @param height - The room up and down, after margins for labels.
|
|
82
|
+
*/
|
|
83
|
+
function fitRingLayout(nodes, width, height) {
|
|
84
|
+
if (nodes.length < 2)
|
|
85
|
+
return;
|
|
86
|
+
const xs = nodes.map((node) => node.x);
|
|
87
|
+
const ys = nodes.map((node) => node.y);
|
|
88
|
+
const minX = Math.min(...xs);
|
|
89
|
+
const maxX = Math.max(...xs);
|
|
90
|
+
const minY = Math.min(...ys);
|
|
91
|
+
const maxY = Math.max(...ys);
|
|
92
|
+
const sx = maxX > minX ? Math.min(1.5, width / (maxX - minX)) : 1;
|
|
93
|
+
const sy = maxY > minY ? Math.min(1.5, height / (maxY - minY)) : 1;
|
|
94
|
+
const midX = (minX + maxX) / 2;
|
|
95
|
+
const midY = (minY + maxY) / 2;
|
|
96
|
+
for (const node of nodes) {
|
|
97
|
+
node.x = (node.x - midX) * sx;
|
|
98
|
+
node.y = (node.y - midY) * sy;
|
|
99
|
+
}
|
|
100
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./components/sortable-list";
|
|
|
13
13
|
export * from "./components/tabs";
|
|
14
14
|
export { Typeahead, type TypeaheadItem } from "./components/typeahead";
|
|
15
15
|
export { isDesktop, mainContentPath } from "./globals";
|
|
16
|
+
export * from "./graph/ring-layout";
|
|
16
17
|
export * from "./groups";
|
|
17
18
|
export * from "./hooks";
|
|
18
19
|
export { openLink } from "./host-shell/host-shell-consumer";
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var globals_1 = require("./globals");
|
|
|
35
35
|
Object.defineProperty(exports, "isDesktop", { enumerable: true, get: function () { return globals_1.isDesktop; } });
|
|
36
36
|
Object.defineProperty(exports, "mainContentPath", { enumerable: true, get: function () { return globals_1.mainContentPath; } });
|
|
37
37
|
// Groups: names, colors and icons from System Groups, and the dialog that edits a group's look.
|
|
38
|
+
__exportStar(require("./graph/ring-layout"), exports);
|
|
38
39
|
__exportStar(require("./groups"), exports);
|
|
39
40
|
__exportStar(require("./hooks"), exports);
|
|
40
41
|
var host_shell_consumer_1 = require("./host-shell/host-shell-consumer");
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** A point on the stage. */
|
|
2
|
+
export interface RoutePoint {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
/** A device on the stage: where it is and how big its circle is. */
|
|
7
|
+
export interface RouteNode extends RoutePoint {
|
|
8
|
+
key: string;
|
|
9
|
+
/** The circle's radius. */
|
|
10
|
+
r: number;
|
|
11
|
+
}
|
|
12
|
+
/** The room kept between a line and a circle it goes around, in pixels. */
|
|
13
|
+
export declare const ROUTE_MARGIN = 16;
|
|
14
|
+
/**
|
|
15
|
+
* Where to bend the line between two devices so it passes no other device's circle. The line
|
|
16
|
+
* becomes a quadratic curve through the returned control point. Of the gentle bends that clear
|
|
17
|
+
* every circle, it takes the one that leaves each end at the widest angle from that end's other
|
|
18
|
+
* lines, so it neither runs along one of them nor looks like it carries on from one; the gentler
|
|
19
|
+
* bend wins a near tie. With no other lines it bends just enough.
|
|
20
|
+
*
|
|
21
|
+
* @param from - One end.
|
|
22
|
+
* @param to - The other end.
|
|
23
|
+
* @param nodes - Every device on the stage; the two ends are skipped.
|
|
24
|
+
* @param linesAt - Where each device's lines go: the far end of each.
|
|
25
|
+
* @returns The control point, or undefined when the straight line is clear.
|
|
26
|
+
*/
|
|
27
|
+
export declare function bendAround(from: RouteNode, to: RouteNode, nodes: readonly RouteNode[], linesAt?: (key: string) => readonly RoutePoint[]): RoutePoint | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* A point on the curve from `from` to `to` through `control`.
|
|
30
|
+
*
|
|
31
|
+
* @param t - How far along, 0 to 1.
|
|
32
|
+
*/
|
|
33
|
+
export declare function pointOnCurve(from: RoutePoint, control: RoutePoint, to: RoutePoint, t: number): RoutePoint;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Where a line between two devices goes: straight, or bent around a device it would otherwise
|
|
3
|
+
// pass over. A straight line through a device reads as a connection through it.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.ROUTE_MARGIN = void 0;
|
|
6
|
+
exports.bendAround = bendAround;
|
|
7
|
+
exports.pointOnCurve = pointOnCurve;
|
|
8
|
+
/** The room kept between a line and a circle it goes around, in pixels. */
|
|
9
|
+
exports.ROUTE_MARGIN = 16;
|
|
10
|
+
/** Bends whose end angles differ by less than this, in radians, count as equally clear. */
|
|
11
|
+
const ANGLE_TIE = Math.PI / 180;
|
|
12
|
+
/** How many bends are tried on each side, from the least that clears to the gentlest limit. */
|
|
13
|
+
const STEPS = 32;
|
|
14
|
+
/**
|
|
15
|
+
* The most a line bows to keep its ends clear of other lines, as control-point depth over its
|
|
16
|
+
* length: the curve's middle then sits at most an eighth of the length out. It bows further only
|
|
17
|
+
* when it must, to clear a circle.
|
|
18
|
+
*/
|
|
19
|
+
const GENTLE = 0.25;
|
|
20
|
+
/**
|
|
21
|
+
* Where to bend the line between two devices so it passes no other device's circle. The line
|
|
22
|
+
* becomes a quadratic curve through the returned control point. Of the gentle bends that clear
|
|
23
|
+
* every circle, it takes the one that leaves each end at the widest angle from that end's other
|
|
24
|
+
* lines, so it neither runs along one of them nor looks like it carries on from one; the gentler
|
|
25
|
+
* bend wins a near tie. With no other lines it bends just enough.
|
|
26
|
+
*
|
|
27
|
+
* @param from - One end.
|
|
28
|
+
* @param to - The other end.
|
|
29
|
+
* @param nodes - Every device on the stage; the two ends are skipped.
|
|
30
|
+
* @param linesAt - Where each device's lines go: the far end of each.
|
|
31
|
+
* @returns The control point, or undefined when the straight line is clear.
|
|
32
|
+
*/
|
|
33
|
+
function bendAround(from, to, nodes, linesAt = () => []) {
|
|
34
|
+
const dx = to.x - from.x;
|
|
35
|
+
const dy = to.y - from.y;
|
|
36
|
+
const length = Math.hypot(dx, dy);
|
|
37
|
+
if (length < 1)
|
|
38
|
+
return undefined;
|
|
39
|
+
const ux = dx / length;
|
|
40
|
+
const uy = dy / length;
|
|
41
|
+
// A unit vector across the line.
|
|
42
|
+
const nx = -uy;
|
|
43
|
+
const ny = ux;
|
|
44
|
+
const hits = [];
|
|
45
|
+
for (const node of nodes) {
|
|
46
|
+
if (node.key === from.key || node.key === to.key)
|
|
47
|
+
continue;
|
|
48
|
+
const rx = node.x - from.x;
|
|
49
|
+
const ry = node.y - from.y;
|
|
50
|
+
// How far along the line the circle sits, 0 to 1; one right at an end can't be bent around.
|
|
51
|
+
const t = (rx * ux + ry * uy) / length;
|
|
52
|
+
if (t < 0.08 || t > 0.92)
|
|
53
|
+
continue;
|
|
54
|
+
const side = rx * nx + ry * ny;
|
|
55
|
+
const room = node.r + exports.ROUTE_MARGIN;
|
|
56
|
+
if (Math.abs(side) < room)
|
|
57
|
+
hits.push({ t, side, room });
|
|
58
|
+
}
|
|
59
|
+
if (!hits.length)
|
|
60
|
+
return undefined;
|
|
61
|
+
// A curve through control offset `depth` sits 2t(1-t)·depth from the straight line at t.
|
|
62
|
+
const leastDepth = (direction) => {
|
|
63
|
+
let depth = 0;
|
|
64
|
+
for (const hit of hits) {
|
|
65
|
+
const towards = hit.side * direction;
|
|
66
|
+
// Bowing away from a circle needs room minus how far it already is; bowing towards one
|
|
67
|
+
// has to pass all the way beyond it.
|
|
68
|
+
const away = towards > 0 ? towards + hit.room : hit.room + towards;
|
|
69
|
+
depth = Math.max(depth, away / (2 * hit.t * (1 - hit.t)));
|
|
70
|
+
}
|
|
71
|
+
return depth;
|
|
72
|
+
};
|
|
73
|
+
const controlFor = (direction, depth) => ({
|
|
74
|
+
x: (from.x + to.x) / 2 + nx * direction * depth,
|
|
75
|
+
y: (from.y + to.y) / 2 + ny * direction * depth,
|
|
76
|
+
});
|
|
77
|
+
// Never more than 40% of the length out at the middle, so it stays an arc and never a loop.
|
|
78
|
+
const most = 0.8 * length;
|
|
79
|
+
let best;
|
|
80
|
+
for (const direction of [1, -1]) {
|
|
81
|
+
const least = leastDepth(direction);
|
|
82
|
+
if (least > most)
|
|
83
|
+
continue;
|
|
84
|
+
const gentlest = Math.max(least, GENTLE * length);
|
|
85
|
+
for (let step = 0; step <= STEPS; step++) {
|
|
86
|
+
const depth = least + ((gentlest - least) * step) / STEPS;
|
|
87
|
+
const control = controlFor(direction, depth);
|
|
88
|
+
const angle = clearance(from, to, control, linesAt);
|
|
89
|
+
if (!best ||
|
|
90
|
+
angle > best.angle + ANGLE_TIE ||
|
|
91
|
+
(angle > best.angle - ANGLE_TIE && depth < best.depth)) {
|
|
92
|
+
best = { control, angle, depth };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Nothing within reach clears every circle: bend as far as allowed, on the easier side.
|
|
97
|
+
return best?.control ?? controlFor(leastDepth(-1) < leastDepth(1) ? -1 : 1, most);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The smallest angle, in radians, between the way a bent line leaves either end and that end's
|
|
101
|
+
* other lines.
|
|
102
|
+
*/
|
|
103
|
+
function clearance(from, to, control, linesAt) {
|
|
104
|
+
let least = Math.PI;
|
|
105
|
+
for (const [end, other] of [
|
|
106
|
+
[from, to],
|
|
107
|
+
[to, from],
|
|
108
|
+
]) {
|
|
109
|
+
const leaving = Math.atan2(control.y - end.y, control.x - end.x);
|
|
110
|
+
for (const far of linesAt(end.key)) {
|
|
111
|
+
if (far.x === other.x && far.y === other.y)
|
|
112
|
+
continue;
|
|
113
|
+
const along = Math.atan2(far.y - end.y, far.x - end.x);
|
|
114
|
+
const gap = Math.abs(((leaving - along + 3 * Math.PI) % (2 * Math.PI)) - Math.PI);
|
|
115
|
+
least = Math.min(least, gap);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return least;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A point on the curve from `from` to `to` through `control`.
|
|
122
|
+
*
|
|
123
|
+
* @param t - How far along, 0 to 1.
|
|
124
|
+
*/
|
|
125
|
+
function pointOnCurve(from, control, to, t) {
|
|
126
|
+
const a = (1 - t) * (1 - t);
|
|
127
|
+
const b = 2 * t * (1 - t);
|
|
128
|
+
const c = t * t;
|
|
129
|
+
return {
|
|
130
|
+
x: a * from.x + b * control.x + c * to.x,
|
|
131
|
+
y: a * from.y + b * control.y + c * to.y,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Where a device's name sits around its circle. */
|
|
2
|
+
export type LabelSide = "below" | "above" | "right" | "left";
|
|
3
|
+
/** A device whose name needs a place, with its circle and the size of its name. */
|
|
4
|
+
export interface LabelNode {
|
|
5
|
+
key: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
/** The circle's radius. */
|
|
9
|
+
r: number;
|
|
10
|
+
/** The name's width and height, estimated. */
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
/** A line drawn between two devices, and which of its ends carry an arrowhead. */
|
|
15
|
+
export interface LabelSegment {
|
|
16
|
+
a: string;
|
|
17
|
+
b: string;
|
|
18
|
+
x1: number;
|
|
19
|
+
y1: number;
|
|
20
|
+
x2: number;
|
|
21
|
+
y2: number;
|
|
22
|
+
arrowAtA: boolean;
|
|
23
|
+
arrowAtB: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** A rectangle, as its left, top, right and bottom edges. */
|
|
26
|
+
export interface LabelBox {
|
|
27
|
+
x0: number;
|
|
28
|
+
y0: number;
|
|
29
|
+
x1: number;
|
|
30
|
+
y1: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Estimate how much room a device's name takes, for a font size in pixels.
|
|
34
|
+
*
|
|
35
|
+
* SVG text can't be measured before it is drawn, so this uses an average character width,
|
|
36
|
+
* a little wider for bold.
|
|
37
|
+
*/
|
|
38
|
+
export declare function estimateLabelSize(text: string, fontSize: number, bold?: boolean): {
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
};
|
|
42
|
+
/** The rectangle a device's name covers on one side of its circle. */
|
|
43
|
+
export declare function labelBox(node: LabelNode, side: LabelSide): LabelBox;
|
|
44
|
+
/** Whether a line passes through a rectangle (Liang–Barsky clipping). */
|
|
45
|
+
export declare function segmentCrossesBox(segment: Pick<LabelSegment, "x1" | "y1" | "x2" | "y2">, box: LabelBox): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Choose a side for each device's name, where it hides the least.
|
|
48
|
+
*
|
|
49
|
+
* Each name tries below, above, right and left of its circle, in that order of preference,
|
|
50
|
+
* and takes the side with the least in the way: arrowheads pointing at its own device count
|
|
51
|
+
* most, then other circles, names already placed, and lines. Devices are placed in the order
|
|
52
|
+
* given, so put the ones whose names matter most first.
|
|
53
|
+
*/
|
|
54
|
+
export declare function placeLabels(nodes: readonly LabelNode[], segments: readonly LabelSegment[]): Map<string, LabelSide>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.estimateLabelSize = estimateLabelSize;
|
|
4
|
+
exports.labelBox = labelBox;
|
|
5
|
+
exports.segmentCrossesBox = segmentCrossesBox;
|
|
6
|
+
exports.placeLabels = placeLabels;
|
|
7
|
+
/** The space between a circle and its name. */
|
|
8
|
+
const GAP = 4;
|
|
9
|
+
/** The sides tried, with what each costs before anything is in its way: below reads best. */
|
|
10
|
+
const SIDES = [
|
|
11
|
+
["below", 0],
|
|
12
|
+
["above", 0.5],
|
|
13
|
+
["right", 2.5],
|
|
14
|
+
["left", 3],
|
|
15
|
+
];
|
|
16
|
+
/** What one thing in a name's way costs. */
|
|
17
|
+
const COST = {
|
|
18
|
+
/** An arrowhead pointing at this device: the name's outline would hide it. */
|
|
19
|
+
arrowHere: 4,
|
|
20
|
+
/** Another device's circle. */
|
|
21
|
+
circle: 5,
|
|
22
|
+
/** A name already placed. */
|
|
23
|
+
label: 3,
|
|
24
|
+
/** One of this device's own lines. */
|
|
25
|
+
ownLine: 1.5,
|
|
26
|
+
/** Any other line. */
|
|
27
|
+
line: 1,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Estimate how much room a device's name takes, for a font size in pixels.
|
|
31
|
+
*
|
|
32
|
+
* SVG text can't be measured before it is drawn, so this uses an average character width,
|
|
33
|
+
* a little wider for bold.
|
|
34
|
+
*/
|
|
35
|
+
function estimateLabelSize(text, fontSize, bold = false) {
|
|
36
|
+
return { width: text.length * fontSize * (bold ? 0.62 : 0.56), height: fontSize + 2 };
|
|
37
|
+
}
|
|
38
|
+
/** The rectangle a device's name covers on one side of its circle. */
|
|
39
|
+
function labelBox(node, side) {
|
|
40
|
+
const { x, y, r, width, height } = node;
|
|
41
|
+
switch (side) {
|
|
42
|
+
case "below":
|
|
43
|
+
return { x0: x - width / 2, y0: y + r + GAP, x1: x + width / 2, y1: y + r + GAP + height };
|
|
44
|
+
case "above":
|
|
45
|
+
return { x0: x - width / 2, y0: y - r - GAP - height, x1: x + width / 2, y1: y - r - GAP };
|
|
46
|
+
case "right":
|
|
47
|
+
return { x0: x + r + GAP, y0: y - height / 2, x1: x + r + GAP + width, y1: y + height / 2 };
|
|
48
|
+
case "left":
|
|
49
|
+
return { x0: x - r - GAP - width, y0: y - height / 2, x1: x - r - GAP, y1: y + height / 2 };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Whether a line passes through a rectangle (Liang–Barsky clipping). */
|
|
53
|
+
function segmentCrossesBox(segment, box) {
|
|
54
|
+
const dx = segment.x2 - segment.x1;
|
|
55
|
+
const dy = segment.y2 - segment.y1;
|
|
56
|
+
const p = [-dx, dx, -dy, dy];
|
|
57
|
+
const q = [segment.x1 - box.x0, box.x1 - segment.x1, segment.y1 - box.y0, box.y1 - segment.y1];
|
|
58
|
+
let t0 = 0;
|
|
59
|
+
let t1 = 1;
|
|
60
|
+
for (let i = 0; i < 4; i++) {
|
|
61
|
+
if (p[i] === 0) {
|
|
62
|
+
if (q[i] < 0)
|
|
63
|
+
return false;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const t = q[i] / p[i];
|
|
67
|
+
if (p[i] < 0) {
|
|
68
|
+
if (t > t1)
|
|
69
|
+
return false;
|
|
70
|
+
if (t > t0)
|
|
71
|
+
t0 = t;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
if (t < t0)
|
|
75
|
+
return false;
|
|
76
|
+
if (t < t1)
|
|
77
|
+
t1 = t;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
function circleTouchesBox(node, box) {
|
|
83
|
+
const nearestX = Math.max(box.x0, Math.min(node.x, box.x1));
|
|
84
|
+
const nearestY = Math.max(box.y0, Math.min(node.y, box.y1));
|
|
85
|
+
return Math.hypot(node.x - nearestX, node.y - nearestY) < node.r;
|
|
86
|
+
}
|
|
87
|
+
function boxesOverlap(a, b) {
|
|
88
|
+
return a.x0 < b.x1 && b.x0 < a.x1 && a.y0 < b.y1 && b.y0 < a.y1;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Choose a side for each device's name, where it hides the least.
|
|
92
|
+
*
|
|
93
|
+
* Each name tries below, above, right and left of its circle, in that order of preference,
|
|
94
|
+
* and takes the side with the least in the way: arrowheads pointing at its own device count
|
|
95
|
+
* most, then other circles, names already placed, and lines. Devices are placed in the order
|
|
96
|
+
* given, so put the ones whose names matter most first.
|
|
97
|
+
*/
|
|
98
|
+
function placeLabels(nodes, segments) {
|
|
99
|
+
const sides = new Map();
|
|
100
|
+
const placed = [];
|
|
101
|
+
for (const node of nodes) {
|
|
102
|
+
let best = "below";
|
|
103
|
+
let bestCost = Number.POSITIVE_INFINITY;
|
|
104
|
+
let bestBox = labelBox(node, best);
|
|
105
|
+
for (const [side, preference] of SIDES) {
|
|
106
|
+
const box = labelBox(node, side);
|
|
107
|
+
let cost = preference;
|
|
108
|
+
for (const segment of segments) {
|
|
109
|
+
if (!segmentCrossesBox(segment, box))
|
|
110
|
+
continue;
|
|
111
|
+
const arrowHere = (segment.a === node.key && segment.arrowAtA) ||
|
|
112
|
+
(segment.b === node.key && segment.arrowAtB);
|
|
113
|
+
const own = segment.a === node.key || segment.b === node.key;
|
|
114
|
+
cost += arrowHere ? COST.arrowHere : own ? COST.ownLine : COST.line;
|
|
115
|
+
}
|
|
116
|
+
for (const other of nodes) {
|
|
117
|
+
if (other !== node && circleTouchesBox(other, box))
|
|
118
|
+
cost += COST.circle;
|
|
119
|
+
}
|
|
120
|
+
for (const taken of placed) {
|
|
121
|
+
if (boxesOverlap(taken, box))
|
|
122
|
+
cost += COST.label;
|
|
123
|
+
}
|
|
124
|
+
if (cost < bestCost) {
|
|
125
|
+
best = side;
|
|
126
|
+
bestCost = cost;
|
|
127
|
+
bestBox = box;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
sides.set(node.key, best);
|
|
131
|
+
placed.push(bestBox);
|
|
132
|
+
}
|
|
133
|
+
return sides;
|
|
134
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { INetworkOverview } from "@peers-app/peers-sdk";
|
|
2
|
+
import { type EdgeHealth, type NetEdge, type NetGraph } from "./network-graph-model";
|
|
3
|
+
/** What the card's buttons do. */
|
|
4
|
+
export interface NetworkGraphCardActions {
|
|
5
|
+
onViewDetails: (deviceId: string) => void;
|
|
6
|
+
onDisconnect: (deviceId: string) => void;
|
|
7
|
+
onConnect: (deviceId: string) => void;
|
|
8
|
+
/** Devices being dialed now. */
|
|
9
|
+
connecting: ReadonlySet<string>;
|
|
10
|
+
/** Select a device, from a connection's card. */
|
|
11
|
+
onSelectNode: (deviceId: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/** What the card is about: a device, a connection, or (with neither) this device. */
|
|
14
|
+
export type NetSelection = {
|
|
15
|
+
kind: "node";
|
|
16
|
+
key: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "edge";
|
|
19
|
+
key: string;
|
|
20
|
+
};
|
|
21
|
+
/** The floating card: this device, the selected device, or the selected connection. */
|
|
22
|
+
export declare function NetworkGraphCard(props: {
|
|
23
|
+
graph: NetGraph;
|
|
24
|
+
overview: INetworkOverview;
|
|
25
|
+
selection: NetSelection | undefined;
|
|
26
|
+
selectedGroupIds: readonly string[];
|
|
27
|
+
health: (edge: NetEdge) => EdgeHealth;
|
|
28
|
+
actions: NetworkGraphCardActions;
|
|
29
|
+
onClose: () => void;
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NetworkGraphCard = NetworkGraphCard;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const network_graph_model_1 = require("./network-graph-model");
|
|
6
|
+
const HEALTH_WORD = { ok: "Normal", slow: "Slow", failing: "Failing" };
|
|
7
|
+
function ago(ms) {
|
|
8
|
+
const seconds = Math.round(ms / 1000);
|
|
9
|
+
return seconds < 90 ? `${seconds} s ago` : `${Math.round(seconds / 60)} min ago`;
|
|
10
|
+
}
|
|
11
|
+
function Rows({ rows }) {
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "peers-net-rows", children: rows.map(([label, value]) => ((0, jsx_runtime_1.jsxs)("div", { className: "peers-net-row", children: [(0, jsx_runtime_1.jsx)("span", { children: label }), (0, jsx_runtime_1.jsx)("span", { children: value })] }, label))) }));
|
|
13
|
+
}
|
|
14
|
+
/** The floating card: this device, the selected device, or the selected connection. */
|
|
15
|
+
function NetworkGraphCard(props) {
|
|
16
|
+
const { graph, selection } = props;
|
|
17
|
+
const edge = selection?.kind === "edge" ? graph.edges.find((item) => item.key === selection.key) : undefined;
|
|
18
|
+
const node = selection?.kind === "node" ? graph.nodes.get(selection.key) : undefined;
|
|
19
|
+
let body;
|
|
20
|
+
let label;
|
|
21
|
+
if (edge) {
|
|
22
|
+
body = (0, jsx_runtime_1.jsx)(EdgeCard, { ...props, edge: edge });
|
|
23
|
+
label = "Details for the connection";
|
|
24
|
+
}
|
|
25
|
+
else if (node && node.kind !== "self") {
|
|
26
|
+
body = (0, jsx_runtime_1.jsx)(DeviceCard, { ...props, node: node });
|
|
27
|
+
label = `Details for ${node.name}`;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
body = (0, jsx_runtime_1.jsx)(SelfCard, { ...props });
|
|
31
|
+
label = "Details";
|
|
32
|
+
}
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)("aside", { className: "peers-net-card", "aria-label": label, "aria-live": "polite", children: [edge || (node && node.kind !== "self") ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "peers-net-card-close", "aria-label": "Close details", onClick: props.onClose, children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-x", "aria-hidden": "true" }) })) : null, body] }));
|
|
34
|
+
}
|
|
35
|
+
function SelfCard(props) {
|
|
36
|
+
const { graph, overview, selectedGroupIds } = props;
|
|
37
|
+
const self = graph.nodes.get(graph.selfId);
|
|
38
|
+
const summary = (0, network_graph_model_1.syncSummary)(graph, graph.selfId, selectedGroupIds);
|
|
39
|
+
const filtered = selectedGroupIds.length > 0;
|
|
40
|
+
const groupNames = (0, network_graph_model_1.listNames)(graph.groups.filter((g) => selectedGroupIds.includes(g.groupId)).map((g) => g.groupName));
|
|
41
|
+
const where = filtered && groupNames ? `In ${groupNames} it` : "It";
|
|
42
|
+
const sentences = [
|
|
43
|
+
summary.chose.length
|
|
44
|
+
? `${where} syncs with ${(0, network_graph_model_1.listNames)(summary.chose)}.`
|
|
45
|
+
: `${where} hasn't chosen a device to sync with.`,
|
|
46
|
+
summary.chosenBy.length ? `Chosen by ${(0, network_graph_model_1.listNames)(summary.chosenBy)}.` : "",
|
|
47
|
+
summary.connectedOnly.length
|
|
48
|
+
? `${(0, network_graph_model_1.listNames)(summary.connectedOnly)} ${summary.connectedOnly.length === 1 ? "is" : "are"} connected, not chosen.`
|
|
49
|
+
: "",
|
|
50
|
+
].filter(Boolean);
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "peers-net-card-kind", children: (0, network_graph_model_1.ownerLabel)(self) }), (0, jsx_runtime_1.jsx)("h3", { className: "peers-net-card-title", children: self.name }), (0, jsx_runtime_1.jsxs)("div", { className: "peers-net-card-about", children: [overview.totalConnections, " of ", overview.maxConnections, " connections \u00B7 CPU", " ", Math.round(overview.cpuPercent), "% \u00B7 memory ", Math.round(overview.memPercent), "%"] }), (0, jsx_runtime_1.jsx)("div", { className: "peers-net-card-meta", children: sentences.join(" ") }), graph.hasTopology ? null : ((0, jsx_runtime_1.jsx)("div", { className: "peers-net-card-meta", children: "This device's app can't yet report what other devices are connected to. Update it to see the outer ring." }))] }));
|
|
52
|
+
}
|
|
53
|
+
function DeviceCard(props) {
|
|
54
|
+
const { graph, node, actions } = props;
|
|
55
|
+
const self = graph.nodes.get(graph.selfId);
|
|
56
|
+
const connection = node.connection;
|
|
57
|
+
const own = graph.edges.find((edge) => edge.own && edge.b === node.key);
|
|
58
|
+
const others = graph.edges
|
|
59
|
+
.filter((edge) => !edge.own && (edge.a === node.key || edge.b === node.key))
|
|
60
|
+
.map((edge) => ({
|
|
61
|
+
edge,
|
|
62
|
+
other: graph.nodes.get(edge.a === node.key ? edge.b : edge.a),
|
|
63
|
+
}));
|
|
64
|
+
const health = own ? props.health(own) : "ok";
|
|
65
|
+
const trust = connection && node.kind !== "service" ? (0, network_graph_model_1.trustName)(connection.deviceTrustLevel) : undefined;
|
|
66
|
+
const dialing = actions.connecting.has(node.key);
|
|
67
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "peers-net-card-kind", children: [(0, network_graph_model_1.ownerLabel)(node), trust ? ` · ${trust}` : ""] }), (0, jsx_runtime_1.jsx)("h3", { className: "peers-net-card-title", children: node.name }), own && connection ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: `peers-net-card-state is-${health}`, children: [health === "ok" ? "" : `${HEALTH_WORD[health]} · `, (0, network_graph_model_1.formatLatency)(own.latencyMs), " \u00B7 ", (0, network_graph_model_1.formatErrors)(own.errorRate)] }), (0, jsx_runtime_1.jsxs)("h4", { className: "peers-net-card-head", children: ["Connection to ", self.name] }), (0, jsx_runtime_1.jsx)(Rows, { rows: [
|
|
68
|
+
["Route", (0, network_graph_model_1.routeOf)(connection.connectionAddress, connection.pathType)],
|
|
69
|
+
["Address", (0, jsx_runtime_1.jsx)("code", { children: connection.connectionAddress || "unknown" }, "a")],
|
|
70
|
+
["Traffic", `${(0, network_graph_model_1.formatRate)(own.sendBps)} out · ${(0, network_graph_model_1.formatRate)(own.receiveBps)} in`],
|
|
71
|
+
] }), node.kind === "service" ? ((0, jsx_runtime_1.jsx)("div", { className: "peers-net-card-meta", children: "Helps devices find and reach each other. It isn't in any group and doesn't sync." })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h4", { className: "peers-net-card-head", children: "Sync choices" }), (0, jsx_runtime_1.jsx)("div", { className: "peers-net-card-lines", children: (0, network_graph_model_1.describeChoices)((0, network_graph_model_1.viewEdge)(own, props.selectedGroupIds), self.name, node.name).map((line) => ((0, jsx_runtime_1.jsx)("div", { children: line }, line))) })] }))] })) : node.offline ? ((0, jsx_runtime_1.jsxs)("div", { className: "peers-net-card-about", children: ["Not connected.", node.lastSeen ? ` Last seen ${node.lastSeen.toLocaleString()}.` : ""] })) : ((0, jsx_runtime_1.jsxs)("div", { className: "peers-net-card-about", children: ["Not connected to ", self.name, ". Reached through", " ", (0, network_graph_model_1.listNames)(others.map((item) => item.other.name)) || "another device", "."] })), others.length ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h4", { className: "peers-net-card-head", children: own ? "Its other connections" : "Its connections" }), (0, jsx_runtime_1.jsx)("div", { className: "peers-net-card-lines", children: others
|
|
72
|
+
.map((item) => `${item.other.name} ${(0, network_graph_model_1.formatLatency)(item.edge.latencyMs)}`)
|
|
73
|
+
.join(" · ") })] })) : null, node.reportAgeMs !== undefined ? ((0, jsx_runtime_1.jsxs)("div", { className: "peers-net-card-meta", children: ["From its own report, ", ago(node.reportAgeMs), "."] })) : null, (0, jsx_runtime_1.jsx)("div", { className: "peers-net-card-actions", children: connection ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "peers-net-btn is-primary", onClick: () => actions.onViewDetails(node.key), children: "Details" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "peers-net-btn is-danger", onClick: () => actions.onDisconnect(node.key), children: "Disconnect" })] })) : ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "peers-net-btn is-primary", disabled: dialing, onClick: () => actions.onConnect(node.key), children: dialing ? "Connecting…" : "Connect" })) })] }));
|
|
74
|
+
}
|
|
75
|
+
function EdgeCard(props) {
|
|
76
|
+
const { graph, edge, actions } = props;
|
|
77
|
+
const a = graph.nodes.get(edge.a);
|
|
78
|
+
const b = graph.nodes.get(edge.b);
|
|
79
|
+
const health = props.health(edge);
|
|
80
|
+
const connection = edge.own ? b.connection : undefined;
|
|
81
|
+
const rows = [
|
|
82
|
+
["Latency", `${(0, network_graph_model_1.formatLatency)(edge.latencyMs)} · ${(0, network_graph_model_1.formatErrors)(edge.errorRate)}`],
|
|
83
|
+
];
|
|
84
|
+
if (connection) {
|
|
85
|
+
rows.unshift(["Route", (0, network_graph_model_1.routeOf)(connection.connectionAddress, connection.pathType)]);
|
|
86
|
+
rows.push(["Traffic", `${(0, network_graph_model_1.formatRate)(edge.sendBps)} out · ${(0, network_graph_model_1.formatRate)(edge.receiveBps)} in`]);
|
|
87
|
+
}
|
|
88
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: `peers-net-card-kind is-${health}`, children: ["Connection \u00B7 ", HEALTH_WORD[health].toLowerCase()] }), (0, jsx_runtime_1.jsxs)("h3", { className: "peers-net-card-title", children: [a.name, " and ", b.name] }), (0, jsx_runtime_1.jsx)(Rows, { rows: rows }), (0, jsx_runtime_1.jsx)("div", { className: "peers-net-card-lines", children: (0, network_graph_model_1.describeChoices)((0, network_graph_model_1.viewEdge)(edge, props.selectedGroupIds), a.name, b.name).map((line) => ((0, jsx_runtime_1.jsx)("div", { children: line }, line))) }), edge.own ? null : ((0, jsx_runtime_1.jsx)("div", { className: "peers-net-card-meta", children: "From what those devices report. Traffic and route are known only for this device's own connections." })), (0, jsx_runtime_1.jsxs)("div", { className: "peers-net-card-actions", children: [[a, b]
|
|
89
|
+
.filter((node) => node.kind !== "self")
|
|
90
|
+
.map((node) => ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "peers-net-btn", onClick: () => actions.onSelectNode(node.key), children: node.name }, node.key))), connection ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "peers-net-btn is-danger", onClick: () => actions.onDisconnect(b.key), children: "Disconnect" })) : null] })] }));
|
|
91
|
+
}
|