@re-cinq/floor-graph 0.0.0-stage → 0.6.2
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/LICENSE +201 -0
- package/README.md +44 -2
- package/dist/ArrowMarkerDefs.d.ts +3 -0
- package/dist/ArrowMarkerDefs.js +16 -0
- package/dist/ControlIcon.d.ts +3 -0
- package/dist/ControlIcon.js +5 -0
- package/dist/DanglingStub.d.ts +7 -0
- package/dist/DanglingStub.js +10 -0
- package/dist/ExitDot.d.ts +8 -0
- package/dist/ExitDot.js +7 -0
- package/dist/GraphEdge.d.ts +27 -0
- package/dist/GraphEdge.js +32 -0
- package/dist/GraphNode.d.ts +43 -0
- package/dist/GraphNode.js +138 -0
- package/dist/GraphSvg.d.ts +50 -0
- package/dist/GraphSvg.js +77 -0
- package/dist/GraphViewport.d.ts +16 -0
- package/dist/GraphViewport.js +27 -0
- package/dist/NodeBadges.d.ts +8 -0
- package/dist/NodeBadges.js +19 -0
- package/dist/NodeBox.d.ts +8 -0
- package/dist/NodeBox.js +8 -0
- package/dist/NodeTitle.d.ts +8 -0
- package/dist/NodeTitle.js +7 -0
- package/dist/NodeTooltip.d.ts +9 -0
- package/dist/NodeTooltip.js +30 -0
- package/dist/RunGraphLegend.d.ts +4 -0
- package/dist/RunGraphLegend.js +20 -0
- package/dist/RunGraphView.d.ts +27 -0
- package/dist/RunGraphView.js +151 -0
- package/dist/ToggleButton.d.ts +8 -0
- package/dist/ToggleButton.js +6 -0
- package/dist/TypeGlyph.d.ts +9 -0
- package/dist/TypeGlyph.js +23 -0
- package/dist/ViewportControls.d.ts +13 -0
- package/dist/ViewportControls.js +11 -0
- package/dist/assembly-line-definition.d.ts +35 -0
- package/dist/assembly-line-definition.js +2 -0
- package/dist/elk-graph.d.ts +16 -0
- package/dist/elk-graph.js +131 -0
- package/dist/elk-layout.d.ts +46 -0
- package/dist/elk-layout.js +67 -0
- package/dist/graph-markers.d.ts +2 -0
- package/dist/graph-markers.js +10 -0
- package/dist/graph-view-model.d.ts +33 -0
- package/dist/graph-view-model.js +55 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +6 -0
- package/dist/layout-geometry.d.ts +16 -0
- package/dist/layout-geometry.js +56 -0
- package/dist/metro/declared-ids.d.ts +3 -0
- package/dist/metro/declared-ids.js +5 -0
- package/dist/metro/edge-key.d.ts +3 -0
- package/dist/metro/edge-key.js +5 -0
- package/dist/metro/layout-diff.d.ts +12 -0
- package/dist/metro/layout-diff.js +32 -0
- package/dist/metro/main-path.d.ts +8 -0
- package/dist/metro/main-path.js +26 -0
- package/dist/metro/neighbourhood.d.ts +7 -0
- package/dist/metro/neighbourhood.js +28 -0
- package/dist/metro/node-edges.d.ts +5 -0
- package/dist/metro/node-edges.js +9 -0
- package/dist/metro/pass-through.d.ts +3 -0
- package/dist/metro/pass-through.js +16 -0
- package/dist/metro/reachability.d.ts +8 -0
- package/dist/metro/reachability.js +31 -0
- package/dist/metro/removed-stations.d.ts +13 -0
- package/dist/metro/removed-stations.js +11 -0
- package/dist/metro/station-visits.d.ts +7 -0
- package/dist/metro/station-visits.js +13 -0
- package/dist/metro/step-along.d.ts +8 -0
- package/dist/metro/step-along.js +28 -0
- package/dist/metro/taken-count.d.ts +6 -0
- package/dist/metro/taken-count.js +11 -0
- package/dist/metro/taken-lines.d.ts +12 -0
- package/dist/metro/taken-lines.js +20 -0
- package/dist/metro/visited-part.d.ts +4 -0
- package/dist/metro/visited-part.js +24 -0
- package/dist/node-aria-label.d.ts +9 -0
- package/dist/node-aria-label.js +11 -0
- package/dist/node-badges.d.ts +8 -0
- package/dist/node-badges.js +20 -0
- package/dist/node-tooltip.d.ts +12 -0
- package/dist/node-tooltip.js +34 -0
- package/dist/node-type-family.d.ts +6 -0
- package/dist/node-type-family.js +18 -0
- package/dist/run-graph-drawing.d.ts +14 -0
- package/dist/run-graph-drawing.js +22 -0
- package/dist/run-graph-geometry.d.ts +18 -0
- package/dist/run-graph-geometry.js +38 -0
- package/dist/run-graph-tone-classes.d.ts +5 -0
- package/dist/run-graph-tone-classes.js +34 -0
- package/dist/run-graph.module.css +470 -0
- package/dist/run-graph.test-helpers.d.ts +4 -0
- package/dist/run-graph.test-helpers.js +11 -0
- package/dist/station-subtitle.d.ts +2 -0
- package/dist/station-subtitle.js +6 -0
- package/dist/use-element-size.d.ts +6 -0
- package/dist/use-element-size.js +17 -0
- package/dist/use-elk-layout.d.ts +5 -0
- package/dist/use-elk-layout.js +19 -0
- package/dist/use-keyboard-cursor.d.ts +10 -0
- package/dist/use-keyboard-cursor.js +39 -0
- package/dist/use-layout-changes.d.ts +11 -0
- package/dist/use-layout-changes.js +45 -0
- package/dist/use-measured-box.d.ts +3 -0
- package/dist/use-measured-box.js +13 -0
- package/dist/use-node-size.d.ts +7 -0
- package/dist/use-node-size.js +17 -0
- package/dist/use-node-tooltip.d.ts +20 -0
- package/dist/use-node-tooltip.js +74 -0
- package/dist/use-pointer-drag.d.ts +7 -0
- package/dist/use-pointer-drag.js +23 -0
- package/dist/use-redrawn.d.ts +4 -0
- package/dist/use-redrawn.js +8 -0
- package/dist/use-revealed.d.ts +4 -0
- package/dist/use-revealed.js +11 -0
- package/dist/use-run-overlay.d.ts +7 -0
- package/dist/use-run-overlay.js +11 -0
- package/dist/use-toggle.d.ts +4 -0
- package/dist/use-toggle.js +7 -0
- package/dist/use-wheel-navigation.d.ts +3 -0
- package/dist/use-wheel-navigation.js +19 -0
- package/dist/viewport-input.d.ts +16 -0
- package/dist/viewport-input.js +19 -0
- package/dist/viewport-state.d.ts +46 -0
- package/dist/viewport-state.js +48 -0
- package/dist/viewport.d.ts +27 -0
- package/dist/viewport.js +66 -0
- package/dist/viewport.module.css +67 -0
- package/package.json +69 -4
package/dist/GraphSvg.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { edgeKeyOf } from "./metro/edge-key";
|
|
3
|
+
import ArrowMarkerDefs from "./ArrowMarkerDefs";
|
|
4
|
+
import GraphEdge, { EdgeLabel } from "./GraphEdge";
|
|
5
|
+
import { markerOf } from "./graph-markers";
|
|
6
|
+
import GraphNode from "./GraphNode";
|
|
7
|
+
import { NODE_HEIGHT } from "./run-graph-geometry";
|
|
8
|
+
import styles from "./run-graph.module.css";
|
|
9
|
+
/** The graph itself. A node nothing leaves is terminal, which the plain label renders differently. `role="img"` with a `<title>`: the drawing is one picture to a screen reader, the nodes inside it focusable buttons. */
|
|
10
|
+
export default function GraphSvg(props) {
|
|
11
|
+
const { laid, name } = props;
|
|
12
|
+
const { view, titleId } = laid;
|
|
13
|
+
return (_jsxs("svg", { className: styles.svg, width: view.width, height: view.height, role: "img", "aria-labelledby": titleId, viewBox: view.viewBox, children: [_jsx("title", { id: titleId, children: `Assembly line graph: ${name}` }), _jsx(ArrowMarkerDefs, {}), _jsx(GraphEdges, { ...props }), _jsx(GraphNodes, { ...props }), _jsx(GraphEdgeLabels, { ...props })] }));
|
|
14
|
+
}
|
|
15
|
+
/** ELK lays out one path per outcome and the model has one edge per outcome: each laid-out edge draws its own path and label, matched to the model by `edgeKeyOf`. An edge with no model draws neutral rather than disappearing. */
|
|
16
|
+
function GraphEdges({ laid, selectedNodeId, selectedLineKey, onSelectLine, marks, }) {
|
|
17
|
+
const { edges } = laid.layout;
|
|
18
|
+
const { lit, mainPath, keyboard, added } = marks;
|
|
19
|
+
return edges.map((edge) => (_jsx(GraphEdge, { ...edgeProps(edge, laid, selectedNodeId), chosen: edgeKeyOf(edge) === keyboard.chosenKey, dimmed: !!lit && !lit.edges.has(edgeKeyOf(edge)), selected: edgeKeyOf(edge) === selectedLineKey, offPath: isOffPath(mainPath, "edges", edgeKeyOf(edge)), added: added.has(edgeKeyOf(edge)), taken: takenOf(marks, edgeKeyOf(edge)), takenCount: marks.taken?.get(edgeKeyOf(edge)), onSelectLine: onSelectLine }, edgeKeyOf(edge))));
|
|
20
|
+
}
|
|
21
|
+
function takenOf({ taken, takenEdgeKey }, key) {
|
|
22
|
+
if (taken)
|
|
23
|
+
return taken.has(key);
|
|
24
|
+
return key === takenEdgeKey || undefined;
|
|
25
|
+
}
|
|
26
|
+
function GraphEdgeLabels({ laid, selectedNodeId, selectedLineKey, onSelectLine, marks, }) {
|
|
27
|
+
const { edges } = laid.layout;
|
|
28
|
+
const { lit, mainPath, taken } = marks;
|
|
29
|
+
return edges.map((edge) => (_jsx(EdgeLabel, { ...edgeProps(edge, laid, selectedNodeId), dimmed: !!lit && !lit.edges.has(edgeKeyOf(edge)), selected: edgeKeyOf(edge) === selectedLineKey, offPath: isOffPath(mainPath, "edges", edgeKeyOf(edge)), takenCount: taken?.get(edgeKeyOf(edge)), onSelectLine: onSelectLine }, edgeKeyOf(edge))));
|
|
30
|
+
}
|
|
31
|
+
function edgeProps(edge, laid, selectedNodeId) {
|
|
32
|
+
return {
|
|
33
|
+
edge,
|
|
34
|
+
model: laid.edgeByKey.get(edgeKeyOf(edge)),
|
|
35
|
+
emphasis: emphasisOf(edge.from, selectedNodeId),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function emphasisOf(from, selectedNodeId) {
|
|
39
|
+
if (!selectedNodeId) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return from === selectedNodeId ? "outgoing" : "other";
|
|
43
|
+
}
|
|
44
|
+
/** Every node in the layout. A node nothing leaves is terminal — the end of a line should read as an end rather than as a step still waiting for a successor. */
|
|
45
|
+
function GraphNodes(props) {
|
|
46
|
+
const { nodes } = props.laid.layout;
|
|
47
|
+
const { removed } = props.marks;
|
|
48
|
+
return (_jsxs(_Fragment, { children: [nodes.map((node) => (_jsx(GraphStation, { node: node, ...props }, node.id))), removed.map((station) => (_jsx(RemovedStationGhost, { ...station }, station.node.id)))] }));
|
|
49
|
+
}
|
|
50
|
+
/** A station the latest layout dropped, fading out where it stood. */
|
|
51
|
+
function RemovedStationGhost({ node, model }) {
|
|
52
|
+
return _jsx(GraphNode, { node: node, model: model, height: NODE_HEIGHT, isTerminal: false, removed: true });
|
|
53
|
+
}
|
|
54
|
+
function GraphStation({ node, ...props }) {
|
|
55
|
+
const { laid, selectedNodeId, describedNode, onHover, marks } = props;
|
|
56
|
+
const { lit, mainPath } = marks;
|
|
57
|
+
const model = laid.nodeById.get(node.id);
|
|
58
|
+
return (markerOf(node, props.exit) ??
|
|
59
|
+
(model && (_jsx(GraphNode, { node: node, model: model, height: NODE_HEIGHT, isTerminal: !laid.nodesWithOutgoing.has(node.id), selected: node.id === selectedNodeId, isUnreachable: marks.unreachable.has(node.id), isStop: laid.stops.has(node.id), toneByEdge: laid.toneByEdge, onSelect: props.onSelectNode, onHover: onHover, keyboard: marks.keyboard, dimmed: !!lit && !lit.nodes.has(node.id), offPath: isOffPath(mainPath, "nodes", node.id), ...changesOf(marks, node.id), ...annotationsOf(describedNode, marks.visits, node.id) }))));
|
|
60
|
+
}
|
|
61
|
+
/** What a station says beyond its shape: the tooltip it is described by, and whether and how the run was there. */
|
|
62
|
+
function annotationsOf(describedNode, visits, nodeId) {
|
|
63
|
+
const stationVisits = visits?.get(nodeId);
|
|
64
|
+
return {
|
|
65
|
+
describedBy: describedNode?.nodeId === nodeId ? describedNode.tooltipId : undefined,
|
|
66
|
+
visited: visits && !!stationVisits,
|
|
67
|
+
outcome: stationVisits?.outcome,
|
|
68
|
+
status: stationVisits,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function isOffPath(mainPath, part, key) {
|
|
72
|
+
return !!mainPath && !mainPath[part].has(key);
|
|
73
|
+
}
|
|
74
|
+
function changesOf({ added, moved, offsets }, key) {
|
|
75
|
+
return { added: added.has(key), moved: moved.has(key), offset: moved.has(key) ? offsets.get(key) : undefined };
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=GraphSvg.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { Box } from "./elk-layout";
|
|
3
|
+
import { type Size } from "./viewport";
|
|
4
|
+
export interface GraphViewportProps {
|
|
5
|
+
drawing: Size;
|
|
6
|
+
reveal?: Box;
|
|
7
|
+
coveredBelow?: number;
|
|
8
|
+
mainPathOn?: boolean;
|
|
9
|
+
onToggleMainPath?: () => void;
|
|
10
|
+
compactStopsOn?: boolean;
|
|
11
|
+
onToggleCompactStops?: () => void;
|
|
12
|
+
wholeLineOn?: boolean;
|
|
13
|
+
onToggleWholeLine?: () => void;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export default function GraphViewport({ drawing, reveal, coveredBelow, mainPathOn, onToggleMainPath, compactStopsOn, onToggleCompactStops, wholeLineOn, onToggleWholeLine, children }: GraphViewportProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Shows the drawing inside an <svg ref={svgRef}> box through the viewport transform: fit on screen, zoom and pan.
|
|
3
|
+
import { useReducer } from "react";
|
|
4
|
+
import { svgTransformOf } from "./viewport";
|
|
5
|
+
import { useMeasuredBox } from "./use-measured-box";
|
|
6
|
+
import { usePointerDrag } from "./use-pointer-drag";
|
|
7
|
+
import { useRedrawn } from "./use-redrawn";
|
|
8
|
+
import { useRevealed } from "./use-revealed";
|
|
9
|
+
import { useWheelNavigation } from "./use-wheel-navigation";
|
|
10
|
+
import ViewportControls from "./ViewportControls";
|
|
11
|
+
import styles from "./viewport.module.css";
|
|
12
|
+
import { keyAction } from "./viewport-input";
|
|
13
|
+
import { initialViewport, viewportReducer } from "./viewport-state";
|
|
14
|
+
export default function GraphViewport({ drawing, reveal, coveredBelow, mainPathOn, onToggleMainPath, compactStopsOn, onToggleCompactStops, wholeLineOn, onToggleWholeLine, children }) {
|
|
15
|
+
const [{ transform }, dispatch] = useReducer(viewportReducer, drawing, initialViewport);
|
|
16
|
+
const svgRef = useMeasuredBox(dispatch);
|
|
17
|
+
const pointerHandlers = usePointerDrag(dispatch);
|
|
18
|
+
useWheelNavigation(svgRef, dispatch);
|
|
19
|
+
useRedrawn(drawing, dispatch);
|
|
20
|
+
useRevealed(reveal, coveredBelow, dispatch);
|
|
21
|
+
return (_jsxs("div", { className: styles.viewport, children: [_jsx("svg", { ref: svgRef, className: styles.box, role: "group", "aria-label": "Graph viewport", tabIndex: 0, onKeyDown: ({ key }) => {
|
|
22
|
+
const action = keyAction(key);
|
|
23
|
+
if (action)
|
|
24
|
+
dispatch(action);
|
|
25
|
+
}, ...pointerHandlers, children: _jsx("g", { transform: svgTransformOf(transform), children: children }) }), _jsx("div", { className: styles.controls, children: _jsx(ViewportControls, { dispatch: dispatch, mainPathOn: mainPathOn, onToggleMainPath: onToggleMainPath, compactStopsOn: compactStopsOn, onToggleCompactStops: onToggleCompactStops, wholeLineOn: wholeLineOn, onToggleWholeLine: onToggleWholeLine }) })] }));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=GraphViewport.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NodeBadge } from "./node-badges";
|
|
2
|
+
export interface NodeBadgesProps {
|
|
3
|
+
badges: readonly NodeBadge[];
|
|
4
|
+
/** The box's right edge and top. */
|
|
5
|
+
rightEdge: number;
|
|
6
|
+
top: number;
|
|
7
|
+
}
|
|
8
|
+
export default function NodeBadges({ badges, rightEdge, top }: NodeBadgesProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styles from "./run-graph.module.css";
|
|
3
|
+
const CHAR_WIDTH = 6.4;
|
|
4
|
+
const PILL_PADDING = 12;
|
|
5
|
+
const PILL_HEIGHT = 15;
|
|
6
|
+
const PILL_GAP = 4;
|
|
7
|
+
const RIGHT_INSET = 10;
|
|
8
|
+
export default function NodeBadges({ badges, rightEdge, top }) {
|
|
9
|
+
return (_jsx(_Fragment, { children: placeBadges(badges, rightEdge).map(({ badge, left, width }) => (_jsxs("g", { "data-badge": badge.kind, className: `${styles.badge} ${styles[`badge-${badge.kind}`]}`, children: [_jsx("title", { children: badge.description }), _jsx("rect", { x: left, y: top - PILL_HEIGHT / 2, width: width, height: PILL_HEIGHT, rx: PILL_HEIGHT / 2 }), _jsx("text", { x: left + width / 2, y: top + 3.5, textAnchor: "middle", children: badge.label })] }, badge.kind))) }));
|
|
10
|
+
}
|
|
11
|
+
/** Each pill's left edge, laid from the right inset leftwards in the order given. */
|
|
12
|
+
function placeBadges(badges, rightEdge) {
|
|
13
|
+
return badges.reduce((placed, badge) => {
|
|
14
|
+
const width = badge.label.length * CHAR_WIDTH + PILL_PADDING;
|
|
15
|
+
const right = placed.length === 0 ? rightEdge - RIGHT_INSET : placed[placed.length - 1].left - PILL_GAP;
|
|
16
|
+
return [...placed, { badge, left: right - width, width }];
|
|
17
|
+
}, []);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=NodeBadges.js.map
|
package/dist/NodeBox.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// The rectangle of a station card, drawn from its top-left corner.
|
|
3
|
+
import { classes } from "./run-graph-tone-classes";
|
|
4
|
+
import styles from "./run-graph.module.css";
|
|
5
|
+
export default function NodeBox({ leftEdge, top, width, height, isUnreachable, }) {
|
|
6
|
+
return (_jsx("rect", { className: classes(styles.box, isUnreachable ? styles.boxUnreachable : undefined), x: leftEdge, y: top, width: width, height: height, rx: 10 }));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=NodeBox.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface NodeTitleProps {
|
|
2
|
+
title: string;
|
|
3
|
+
subtitle: string;
|
|
4
|
+
isUnreachable?: boolean;
|
|
5
|
+
centerX: number;
|
|
6
|
+
centerY: number;
|
|
7
|
+
}
|
|
8
|
+
export default function NodeTitle({ title, subtitle, isUnreachable, centerX, centerY, }: NodeTitleProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// What a station card says: its title, and under it its subtitle.
|
|
3
|
+
import styles from "./run-graph.module.css";
|
|
4
|
+
export default function NodeTitle({ title, subtitle, isUnreachable, centerX, centerY, }) {
|
|
5
|
+
return (_jsxs(_Fragment, { children: [_jsx("text", { className: styles.nodeId, x: centerX, y: centerY - 2, textAnchor: "middle", children: title }), _jsx("text", { className: isUnreachable ? styles.nodeUnreachable : styles.nodeKind, x: centerX, y: centerY + 12, textAnchor: "middle", children: isUnreachable ? "unreachable" : subtitle })] }));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=NodeTitle.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NodeTooltip as Tooltip } from "./node-tooltip";
|
|
2
|
+
import type { TooltipAnchor } from "./use-node-tooltip";
|
|
3
|
+
interface NodeTooltipProps {
|
|
4
|
+
id: string;
|
|
5
|
+
tooltip: Tooltip;
|
|
6
|
+
anchor: TooltipAnchor;
|
|
7
|
+
}
|
|
8
|
+
export default function NodeTooltip({ id, tooltip, anchor }: NodeTooltipProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The card a hovered or focused node shows (run-viz FR4.1h): its name and kind in the family's colour, and what its station does. Fixed to the viewport so the graph's scroll box cannot clip it; above the node, or below it when the node sits near the top of the screen.
|
|
3
|
+
import { useLayoutEffect, useRef } from "react";
|
|
4
|
+
import { FAMILY_CLASS } from "./TypeGlyph";
|
|
5
|
+
import styles from "./run-graph.module.css";
|
|
6
|
+
// Room the card needs above a node before it flips below it.
|
|
7
|
+
const ROOM_ABOVE_PX = 160;
|
|
8
|
+
const GAP_PX = 8;
|
|
9
|
+
export default function NodeTooltip({ id, tooltip, anchor }) {
|
|
10
|
+
const placement = placementOf(anchor);
|
|
11
|
+
const card = usePlacedAt(anchor.left, placement.top);
|
|
12
|
+
return (_jsxs("div", { ref: card, id: id, role: "tooltip", className: `${styles.tooltip} ${FAMILY_CLASS[tooltip.family]}`, "data-placement": placement.side, children: [_jsx("strong", { className: styles.tooltipTitle, children: tooltip.title }), _jsx("span", { className: styles.tooltipKind, children: tooltip.kind }), _jsx("p", { className: styles.tooltipText, children: tooltip.description })] }));
|
|
13
|
+
}
|
|
14
|
+
/** Pins the card where the anchor says, after layout and before paint, so it never shows where it was last. */
|
|
15
|
+
function usePlacedAt(left, top) {
|
|
16
|
+
const card = useRef(null);
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
const element = card.current;
|
|
19
|
+
if (element) {
|
|
20
|
+
Object.assign(element.style, { left: `${left}px`, top: `${top}px` });
|
|
21
|
+
}
|
|
22
|
+
}, [left, top]);
|
|
23
|
+
return card;
|
|
24
|
+
}
|
|
25
|
+
function placementOf(anchor) {
|
|
26
|
+
return anchor.top >= ROOM_ABOVE_PX
|
|
27
|
+
? { side: "above", top: anchor.top - GAP_PX }
|
|
28
|
+
: { side: "below", top: anchor.bottom + GAP_PX };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=NodeTooltip.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Under the graph: what each step-type mark means, for the families this line has (run-viz FR4.1h).
|
|
3
|
+
import { FAMILY_LABEL } from "./node-type-family";
|
|
4
|
+
import TypeGlyph, { FAMILY_CLASS } from "./TypeGlyph";
|
|
5
|
+
import styles from "./run-graph.module.css";
|
|
6
|
+
const FAMILY_ORDER = [
|
|
7
|
+
"agent",
|
|
8
|
+
"service",
|
|
9
|
+
"person",
|
|
10
|
+
"marker",
|
|
11
|
+
];
|
|
12
|
+
export default function RunGraphLegend({ families, }) {
|
|
13
|
+
return (_jsx("ul", { className: styles.legend, "aria-label": "Step types", children: FAMILY_ORDER.filter((family) => families.has(family)).map((family) => (_jsxs("li", { className: styles.legendItem, children: [_jsx(LegendSwatch, { family: family }), FAMILY_LABEL[family]] }, family))) }));
|
|
14
|
+
}
|
|
15
|
+
const SWATCH_BOX = { x: 1, y: 1, width: 16, height: 12, rx: 3 };
|
|
16
|
+
/** A small box in the family's colours with its mark, as a node of this family is drawn. */
|
|
17
|
+
function LegendSwatch({ family }) {
|
|
18
|
+
return (_jsx("svg", { className: styles.legendSwatch, width: "18", height: "14", viewBox: "0 0 18 14", "aria-hidden": "true", children: _jsxs("g", { className: FAMILY_CLASS[family], children: [_jsx("rect", { className: styles.legendBox, ...SWATCH_BOX }), _jsx(TypeGlyph, { family: family, cx: 9, cy: 7 })] }) }));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=RunGraphLegend.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AssemblyLineDefinition } from "./assembly-line-definition";
|
|
2
|
+
import { type RunOverlay } from "./use-run-overlay";
|
|
3
|
+
export interface RunGraphViewProps {
|
|
4
|
+
definition: AssemblyLineDefinition;
|
|
5
|
+
onSelectNode?: (nodeId: string) => void;
|
|
6
|
+
onSelectLine?: (key: string) => void;
|
|
7
|
+
/** The line the inspector shows, drawn bold. */
|
|
8
|
+
selectedLineKey?: string | null;
|
|
9
|
+
/** The node the inspector shows, drawn with a ring; its outgoing hops draw bold. */
|
|
10
|
+
selectedNodeId?: string | null;
|
|
11
|
+
/** Height at the bottom of the graph that the inspector covers. */
|
|
12
|
+
coveredBelow?: number;
|
|
13
|
+
/** Draws the pass-through stations as small stops rather than cards. */
|
|
14
|
+
compactStops?: boolean;
|
|
15
|
+
/** Fades the stations and lines off the main line. */
|
|
16
|
+
mainPathOnly?: boolean;
|
|
17
|
+
/** The connector to draw as the one that was taken. */
|
|
18
|
+
takenEdge?: {
|
|
19
|
+
from: string;
|
|
20
|
+
to: string;
|
|
21
|
+
on: string;
|
|
22
|
+
};
|
|
23
|
+
run?: RunOverlay;
|
|
24
|
+
/** Draws the whole line or only the part the run walked; defaults to the walked part when a run is given. */
|
|
25
|
+
show?: "all" | "visited";
|
|
26
|
+
}
|
|
27
|
+
export default function RunGraphView(givenProps: RunGraphViewProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Renders an assembly line — lays out the nodes/connectors from graph-view-model and hands drawing to its sibling files; every node also says its outcomes and badges as text, so meaning never rests on color alone.
|
|
3
|
+
import { useCallback, useMemo, useState } from "react";
|
|
4
|
+
import { useToggle } from "./use-toggle";
|
|
5
|
+
import { useElkLayout } from "./use-elk-layout";
|
|
6
|
+
import { drawingOf } from "./run-graph-drawing";
|
|
7
|
+
import { mainPathOf } from "./metro/main-path";
|
|
8
|
+
import { reachabilityOf } from "./metro/reachability";
|
|
9
|
+
import { isPassThrough } from "./metro/pass-through";
|
|
10
|
+
import { neighbourhoodOf } from "./metro/neighbourhood";
|
|
11
|
+
import { visitedPartOf } from "./metro/visited-part";
|
|
12
|
+
import { typeFamilyOf } from "./node-type-family";
|
|
13
|
+
import { deriveVisibleGraph } from "./graph-view-model";
|
|
14
|
+
import GraphSvg from "./GraphSvg";
|
|
15
|
+
import { useKeyboardCursor } from "./use-keyboard-cursor";
|
|
16
|
+
import GraphViewport from "./GraphViewport";
|
|
17
|
+
import { useLayoutChanges } from "./use-layout-changes";
|
|
18
|
+
import { useStationVisits, useTakenLines, } from "./use-run-overlay";
|
|
19
|
+
import { edgeKeyOf } from "./metro/edge-key";
|
|
20
|
+
import { useNodeTooltip } from "./use-node-tooltip";
|
|
21
|
+
import NodeTooltip from "./NodeTooltip";
|
|
22
|
+
import { nodeTooltipOf } from "./node-tooltip";
|
|
23
|
+
import { useNodeSize } from "./use-node-size";
|
|
24
|
+
import RunGraphLegend from "./RunGraphLegend";
|
|
25
|
+
import { NODE_HEIGHT, revealBoxOf } from "./run-graph-geometry";
|
|
26
|
+
import styles from "./run-graph.module.css";
|
|
27
|
+
// The graph: laid out by ELK, then fitted to the panel by the viewport. Until ELK resolves, the panel and legend show with an empty canvas.
|
|
28
|
+
export default function RunGraphView(givenProps) {
|
|
29
|
+
const wholeLine = useWholeLine(givenProps);
|
|
30
|
+
const props = useMemo(() => ({ ...givenProps, ...wholeLine }), [givenProps, wholeLine]);
|
|
31
|
+
const graph = useMemo(() => deriveVisibleGraph(props.definition), [props.definition]);
|
|
32
|
+
if (graph.nodes.length === 0) {
|
|
33
|
+
return _jsx(EmptyGraph, {});
|
|
34
|
+
}
|
|
35
|
+
return (_jsxs("section", { className: styles.panel, "aria-label": `Graph of ${props.definition.name}`, children: [_jsx(GraphCanvas, { view: props, graph: graph }), _jsx(RunGraphLegend, { families: familiesOf(graph) })] }));
|
|
36
|
+
}
|
|
37
|
+
/** The whole definition or the part the run visited, and the toggle between them, offered only with a run. Until it is pressed, the default follows the props, so a run that arrives after the first draw still opens on its visited part. */
|
|
38
|
+
function useWholeLine({ definition, run, show }) {
|
|
39
|
+
const [pressedOn, setPressedOn] = useState(null);
|
|
40
|
+
const wholeLineOn = pressedOn ?? (show ?? (run ? "visited" : "all")) === "all";
|
|
41
|
+
const toggleWholeLine = useCallback(() => setPressedOn(!wholeLineOn), [wholeLineOn]);
|
|
42
|
+
const shown = useMemo(() => run && !wholeLineOn ? visitedPartOf(definition, run.visits) : definition, [definition, run, wholeLineOn]);
|
|
43
|
+
return useMemo(() => ({
|
|
44
|
+
definition: shown,
|
|
45
|
+
wholeLineOn,
|
|
46
|
+
onToggleWholeLine: run ? toggleWholeLine : undefined,
|
|
47
|
+
}), [shown, wholeLineOn, run, toggleWholeLine]);
|
|
48
|
+
}
|
|
49
|
+
/** The drawing in its viewport, and the tooltip of the node under the pointer or the focus (run-viz FR4.1h). */
|
|
50
|
+
function GraphCanvas({ view, graph }) {
|
|
51
|
+
const { laid, tooltip, marks, toggles, setHoveredId } = useGraphCanvasState(view, graph);
|
|
52
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: styles.canvas, ...tooltip.handlers, children: laid && (_jsx(GraphViewport, { drawing: laid.view, reveal: revealOf(laid, view.selectedNodeId), coveredBelow: view.coveredBelow, ...toggles, children: _jsx(GraphSvg, { laid: laid, ...drawnFrom(view), describedNode: describedNodeOf(tooltip), onHover: setHoveredId, marks: marks }) })) }), _jsx(GraphTooltip, { ...tooltip, definition: view.definition })] }));
|
|
53
|
+
}
|
|
54
|
+
/** What the drawing needs from the view: the line's name and exit, and what is selected and how to select. */
|
|
55
|
+
function drawnFrom(view) {
|
|
56
|
+
const { name, exit } = view.definition;
|
|
57
|
+
const { onSelectNode, onSelectLine, selectedLineKey, selectedNodeId } = view;
|
|
58
|
+
return {
|
|
59
|
+
name,
|
|
60
|
+
exit,
|
|
61
|
+
onSelectNode,
|
|
62
|
+
onSelectLine,
|
|
63
|
+
selectedLineKey,
|
|
64
|
+
selectedNodeId,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Everything the canvas draws from: the laid-out drawing, the tooltip, the marks on its elements and the viewport's two toggles. */
|
|
68
|
+
function useGraphCanvasState(view, graph) {
|
|
69
|
+
const { unreachable, mainPath, mainPathOnly, toggleMainPath, taken, visits } = useLineMarkings(view);
|
|
70
|
+
const { lit, setHoveredId } = useHoverNeighbourhood(view.definition);
|
|
71
|
+
const keyboard = useKeyboardCursor(view.definition);
|
|
72
|
+
const { elkLayout, changes, stops, compactStops, toggleCompactStops } = useStopsLayout(view, graph, { visits, taken });
|
|
73
|
+
const laid = useMemo(() => elkLayout && drawingOf(elkLayout, graph, view.definition.name, stops), [elkLayout, graph, view.definition.name, stops]);
|
|
74
|
+
const toggles = {
|
|
75
|
+
mainPathOn: mainPathOnly,
|
|
76
|
+
onToggleMainPath: toggleMainPath,
|
|
77
|
+
compactStopsOn: compactStops,
|
|
78
|
+
onToggleCompactStops: toggleCompactStops,
|
|
79
|
+
wholeLineOn: view.wholeLineOn,
|
|
80
|
+
onToggleWholeLine: view.onToggleWholeLine,
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
laid,
|
|
84
|
+
tooltip: useNodeTooltip(),
|
|
85
|
+
marks: { lit, mainPath, unreachable, keyboard, ...changes, taken, visits, takenEdgeKey: view.takenEdge && edgeKeyOf(view.takenEdge) },
|
|
86
|
+
toggles,
|
|
87
|
+
setHoveredId,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** The stations no start leads to, the lines a run took, and the main line of the definition while `mainPathOnly` is set (else null). */
|
|
91
|
+
function useLineMarkings({ definition, run, mainPathOnly: initialMainPathOnly, }) {
|
|
92
|
+
const [mainPathOnly, toggleMainPath] = useToggle({
|
|
93
|
+
initiallyOn: initialMainPathOnly,
|
|
94
|
+
});
|
|
95
|
+
const unreachable = useMemo(() => reachabilityOf(definition).unreachable, [definition]);
|
|
96
|
+
const mainPath = useMemo(() => (mainPathOnly ? mainPathOf(definition) : null), [definition, mainPathOnly]);
|
|
97
|
+
return {
|
|
98
|
+
unreachable,
|
|
99
|
+
mainPath,
|
|
100
|
+
mainPathOnly,
|
|
101
|
+
toggleMainPath,
|
|
102
|
+
taken: useTakenLines(definition, run),
|
|
103
|
+
visits: useStationVisits(run),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** The layout, asked to compact its stops when `compactStops` is set, and the stations drawn as stops: the pass-through ones. */
|
|
107
|
+
function useStopsLayout({ definition, compactStops: initialCompactStops }, graph, { visits, taken }) {
|
|
108
|
+
const [compactStops, toggleCompactStops] = useToggle({
|
|
109
|
+
initiallyOn: initialCompactStops,
|
|
110
|
+
});
|
|
111
|
+
const layoutOptions = useMemo(() => ({ compactStops, takenCounts: taken }), [compactStops, taken]);
|
|
112
|
+
const stops = useMemo(() => stopsOf({ definition, compactStops }, graph), [definition, compactStops, graph]);
|
|
113
|
+
const elkLayout = useElkLayout(definition, useNodeSize(definition, visits), undefined, layoutOptions);
|
|
114
|
+
return {
|
|
115
|
+
elkLayout,
|
|
116
|
+
changes: useLayoutChanges(elkLayout, graph),
|
|
117
|
+
stops,
|
|
118
|
+
compactStops,
|
|
119
|
+
toggleCompactStops,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function stopsOf({ definition, compactStops }, { nodes }) {
|
|
123
|
+
const nodeIds = nodes.map((node) => node.id);
|
|
124
|
+
return new Set(nodeIds.filter((nodeId) => compactStops && isPassThrough(definition, nodeId)));
|
|
125
|
+
}
|
|
126
|
+
/** The neighbourhood of the node under the pointer or the focus, or null while there is none. */
|
|
127
|
+
function useHoverNeighbourhood(definition) {
|
|
128
|
+
const [hoveredId, setHoveredId] = useState(null);
|
|
129
|
+
const lit = useMemo(() => (hoveredId ? neighbourhoodOf(definition, hoveredId) : null), [hoveredId, definition]);
|
|
130
|
+
return { lit, setHoveredId };
|
|
131
|
+
}
|
|
132
|
+
function revealOf(laid, selectedNodeId) {
|
|
133
|
+
const { nodes } = laid.layout;
|
|
134
|
+
const selected = nodes.find((node) => node.id === selectedNodeId);
|
|
135
|
+
return selected && revealBoxOf(selected, laid.view, NODE_HEIGHT);
|
|
136
|
+
}
|
|
137
|
+
function familiesOf(graph) {
|
|
138
|
+
return new Set(graph.nodes.map((node) => typeFamilyOf(node.type)));
|
|
139
|
+
}
|
|
140
|
+
/** The node the tooltip is up for, and the tooltip's id its group points at. */
|
|
141
|
+
function describedNodeOf({ id, anchor, }) {
|
|
142
|
+
return anchor ? { nodeId: anchor.nodeId, tooltipId: id } : null;
|
|
143
|
+
}
|
|
144
|
+
function GraphTooltip({ id, anchor, definition, }) {
|
|
145
|
+
const tooltip = anchor && nodeTooltipOf(anchor.nodeId, definition);
|
|
146
|
+
return anchor && tooltip ? (_jsx(NodeTooltip, { id: id, tooltip: tooltip, anchor: anchor })) : null;
|
|
147
|
+
}
|
|
148
|
+
function EmptyGraph() {
|
|
149
|
+
return (_jsx("p", { className: styles.empty, children: "This assembly line has no nodes to draw." }));
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=RunGraphView.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import ControlIcon from "./ControlIcon";
|
|
3
|
+
export default function ToggleButton({ label, icon, isOn, onToggle }) {
|
|
4
|
+
return (_jsx("button", { type: "button", "aria-label": label, title: label, "aria-pressed": isOn, onClick: onToggle, children: _jsx(ControlIcon, { icon: icon }) }));
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=ToggleButton.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NodeTypeFamily } from "./node-type-family";
|
|
2
|
+
export declare const FAMILY_CLASS: Record<NodeTypeFamily, string>;
|
|
3
|
+
interface TypeGlyphProps {
|
|
4
|
+
family: NodeTypeFamily;
|
|
5
|
+
cx: number;
|
|
6
|
+
cy: number;
|
|
7
|
+
}
|
|
8
|
+
export default function TypeGlyph({ family, cx, cy }: TypeGlyphProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styles from "./run-graph.module.css";
|
|
3
|
+
// Each mark drawn around its centre at scale 1 for a 10px glyph.
|
|
4
|
+
const GLYPH_PATH = {
|
|
5
|
+
// A four-point spark: the work is a model's.
|
|
6
|
+
agent: (cx, cy) => `M ${cx} ${cy - 5} Q ${cx} ${cy} ${cx + 5} ${cy} Q ${cx} ${cy} ${cx} ${cy + 5} Q ${cx} ${cy} ${cx - 5} ${cy} Q ${cx} ${cy} ${cx} ${cy - 5} Z`,
|
|
7
|
+
// A square: a machine step.
|
|
8
|
+
service: (cx, cy) => `M ${cx - 4} ${cy - 4} L ${cx + 4} ${cy - 4} L ${cx + 4} ${cy + 4} L ${cx - 4} ${cy + 4} Z`,
|
|
9
|
+
// A head and shoulders: it waits on a person.
|
|
10
|
+
person: (cx, cy) => `M ${cx - 2.5} ${cy - 2.5} A 2.5 2.5 0 1 1 ${cx + 2.5} ${cy - 2.5} A 2.5 2.5 0 1 1 ${cx - 2.5} ${cy - 2.5} Z M ${cx - 5} ${cy + 5} Q ${cx} ${cy - 1} ${cx + 5} ${cy + 5} Z`,
|
|
11
|
+
// A diamond: a point in the line with no work of its own.
|
|
12
|
+
marker: (cx, cy) => `M ${cx} ${cy - 5} L ${cx + 5} ${cy} L ${cx} ${cy + 5} L ${cx - 5} ${cy} Z`,
|
|
13
|
+
};
|
|
14
|
+
export const FAMILY_CLASS = {
|
|
15
|
+
agent: styles.familyAgent,
|
|
16
|
+
service: styles.familyService,
|
|
17
|
+
person: styles.familyPerson,
|
|
18
|
+
marker: styles.familyMarker,
|
|
19
|
+
};
|
|
20
|
+
export default function TypeGlyph({ family, cx, cy }) {
|
|
21
|
+
return (_jsx("path", { "aria-hidden": "true", className: `${styles.typeGlyph} ${FAMILY_CLASS[family]}`, d: GLYPH_PATH[family](cx, cy) }));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=TypeGlyph.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Dispatch } from "react";
|
|
2
|
+
import type { ViewportAction } from "./viewport-state";
|
|
3
|
+
interface ViewportControlsProps {
|
|
4
|
+
dispatch: Dispatch<ViewportAction>;
|
|
5
|
+
mainPathOn?: boolean;
|
|
6
|
+
onToggleMainPath?: () => void;
|
|
7
|
+
compactStopsOn?: boolean;
|
|
8
|
+
onToggleCompactStops?: () => void;
|
|
9
|
+
wholeLineOn?: boolean;
|
|
10
|
+
onToggleWholeLine?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export default function ViewportControls({ dispatch, mainPathOn, onToggleMainPath, compactStopsOn, onToggleCompactStops, wholeLineOn, onToggleWholeLine }: ViewportControlsProps): import("react").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import ControlIcon from "./ControlIcon";
|
|
3
|
+
import ToggleButton from "./ToggleButton";
|
|
4
|
+
import { viewportControls } from "./viewport-input";
|
|
5
|
+
const MAIN_PATH_ICON = "M2 8h12M2 5v6M14 5v6";
|
|
6
|
+
const WHOLE_LINE_ICON = "M4 8h8M2 8a1 1 0 1 0 2 0a1 1 0 1 0-2 0M12 8a1 1 0 1 0 2 0a1 1 0 1 0-2 0";
|
|
7
|
+
const COMPACT_STOPS_ICON = "M2 8h3M11 8h3M5 8a3 3 0 1 0 6 0a3 3 0 1 0-6 0";
|
|
8
|
+
export default function ViewportControls({ dispatch, mainPathOn, onToggleMainPath, compactStopsOn, onToggleCompactStops, wholeLineOn, onToggleWholeLine }) {
|
|
9
|
+
return (_jsxs(_Fragment, { children: [viewportControls.map(({ label, icon, action }) => (_jsx("button", { type: "button", "aria-label": label, title: label, onClick: () => dispatch(action), children: _jsx(ControlIcon, { icon: icon }) }, label))), onToggleMainPath && _jsx(ToggleButton, { label: "Main path", icon: MAIN_PATH_ICON, isOn: mainPathOn, onToggle: onToggleMainPath }), onToggleCompactStops && _jsx(ToggleButton, { label: "Compact stops", icon: COMPACT_STOPS_ICON, isOn: compactStopsOn, onToggle: onToggleCompactStops }), onToggleWholeLine && _jsx(ToggleButton, { label: "Whole line", icon: WHOLE_LINE_ICON, isOn: wholeLineOn, onToggle: onToggleWholeLine })] }));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ViewportControls.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { StationKind } from "@re-cinq/floor-contracts";
|
|
2
|
+
/** A node whose line names no station is a marker. */
|
|
3
|
+
export type DefinitionNodeKind = StationKind | "marker";
|
|
4
|
+
export interface DefinitionNode {
|
|
5
|
+
id: string;
|
|
6
|
+
type: DefinitionNodeKind;
|
|
7
|
+
station?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
/** This node reports a list and `to` then runs once per item. */
|
|
10
|
+
fanout?: {
|
|
11
|
+
over: string;
|
|
12
|
+
to: string;
|
|
13
|
+
};
|
|
14
|
+
/** The event that starts the node from outside the line's own walk. */
|
|
15
|
+
outsideStart?: string;
|
|
16
|
+
hasProblem?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface DefinitionEdge {
|
|
19
|
+
from: string;
|
|
20
|
+
to: string;
|
|
21
|
+
/** The outcome that takes this edge. */
|
|
22
|
+
on: string;
|
|
23
|
+
iterationMax?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface AssemblyLineDefinition {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
version: 1;
|
|
29
|
+
entry: string;
|
|
30
|
+
exit: string;
|
|
31
|
+
/** The node that ends the run as failed on purpose; absent when the line has none. */
|
|
32
|
+
fail?: string;
|
|
33
|
+
nodes: DefinitionNode[];
|
|
34
|
+
edges: DefinitionEdge[];
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ElkNode } from "elkjs/lib/elk-api";
|
|
2
|
+
import type { AssemblyLineDefinition } from "./assembly-line-definition";
|
|
3
|
+
/** Builds the ELK input graph for a line: one child per node, markers 22x22, others 140x60 unless sized. */
|
|
4
|
+
export interface NodeSize {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
/** A card's own width by node id; cards without one take `width`. */
|
|
8
|
+
widthOf?: (nodeId: string) => number;
|
|
9
|
+
}
|
|
10
|
+
export interface ElkGraphOptions {
|
|
11
|
+
/** Draws each pass-through station as a small stop instead of a card. */
|
|
12
|
+
compactStops?: boolean;
|
|
13
|
+
/** How many times a run took each line by edge key; a line taken twice or more reserves room for its count. */
|
|
14
|
+
takenCounts?: ReadonlyMap<string, number>;
|
|
15
|
+
}
|
|
16
|
+
export declare function elkGraphOf(definition: AssemblyLineDefinition, size?: NodeSize, options?: ElkGraphOptions): ElkNode;
|