@g9tm/lynxcontrols-graph 0.0.0-stage → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -2
- package/catalog/cards/G9GraphCanvas.md +17 -0
- package/catalog/catalog.json +981 -0
- package/catalog/index.md +5 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/canvas.d.ts +122 -0
- package/dist/canvas.d.ts.map +1 -0
- package/dist/canvas.jsx +889 -0
- package/dist/core.d.ts +151 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +325 -0
- package/dist/core.js.map +1 -0
- package/dist/core.jsx +323 -0
- package/dist/graph.css +142 -0
- package/dist/graph.css.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.jsx +2 -0
- package/dist/mt.d.ts +26 -0
- package/dist/mt.d.ts.map +1 -0
- package/dist/mt.jsx +91 -0
- package/package.json +36 -4
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/** A point or a size in world units (the graph's own space, before the zoom). */
|
|
2
|
+
export interface G9GraphPoint {
|
|
3
|
+
readonly x: number;
|
|
4
|
+
readonly y: number;
|
|
5
|
+
}
|
|
6
|
+
/** A rect in world units. */
|
|
7
|
+
export interface G9GraphRect {
|
|
8
|
+
readonly x: number;
|
|
9
|
+
readonly y: number;
|
|
10
|
+
readonly width: number;
|
|
11
|
+
readonly height: number;
|
|
12
|
+
}
|
|
13
|
+
/** How the world is shown: screen = world × zoom + (x, y). */
|
|
14
|
+
export interface G9GraphView {
|
|
15
|
+
readonly zoom: number;
|
|
16
|
+
readonly x: number;
|
|
17
|
+
readonly y: number;
|
|
18
|
+
}
|
|
19
|
+
/** A port on a node's side; `offset` 0..1 along the side (default spread evenly among that side's ports). */
|
|
20
|
+
export interface G9GraphPort {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly side: 'left' | 'right';
|
|
23
|
+
readonly offset?: number;
|
|
24
|
+
}
|
|
25
|
+
/** A node as the canvas needs it: where, how big, its ports. The app draws its card. */
|
|
26
|
+
export interface G9GraphNode {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly x: number;
|
|
29
|
+
readonly y: number;
|
|
30
|
+
readonly width: number;
|
|
31
|
+
readonly height: number;
|
|
32
|
+
readonly ports?: readonly G9GraphPort[];
|
|
33
|
+
/** Whether it may be dragged (default true). */
|
|
34
|
+
readonly draggable?: boolean;
|
|
35
|
+
/** Whether it takes a drop of this external drag payload (`G9DragPayload` of `@g9tm/lynxcontrols/pointer`). */
|
|
36
|
+
readonly acceptsDrop?: (payload: {
|
|
37
|
+
readonly kind: string;
|
|
38
|
+
readonly data: unknown;
|
|
39
|
+
}) => boolean;
|
|
40
|
+
}
|
|
41
|
+
/** An end of an edge: a node, and one of its ports (default: the right side's middle for a source, left for a target). */
|
|
42
|
+
export interface G9GraphEnd {
|
|
43
|
+
readonly node: string;
|
|
44
|
+
readonly port?: string;
|
|
45
|
+
}
|
|
46
|
+
/** How an edge is drawn. */
|
|
47
|
+
export type G9GraphEdgeStyle = 'solid' | 'dashed' | 'active';
|
|
48
|
+
/** An edge between two node ports. */
|
|
49
|
+
export interface G9GraphEdge {
|
|
50
|
+
readonly id: string;
|
|
51
|
+
readonly from: G9GraphEnd;
|
|
52
|
+
readonly to: G9GraphEnd;
|
|
53
|
+
readonly label?: string;
|
|
54
|
+
/** `'active'` is dashed and moving. Default `'solid'`. */
|
|
55
|
+
readonly style?: G9GraphEdgeStyle;
|
|
56
|
+
/** A colour of the app's own (default the theme's outline; active: primary). */
|
|
57
|
+
readonly color?: string;
|
|
58
|
+
readonly width?: number;
|
|
59
|
+
}
|
|
60
|
+
/** A titled background area (a lane, a pillar) at an app-given rect. */
|
|
61
|
+
export interface G9GraphGroup {
|
|
62
|
+
readonly id: string;
|
|
63
|
+
readonly title?: string;
|
|
64
|
+
readonly x: number;
|
|
65
|
+
readonly y: number;
|
|
66
|
+
readonly width: number;
|
|
67
|
+
readonly height: number;
|
|
68
|
+
/** A colour of the app's own for its fill (default the theme's container colour). */
|
|
69
|
+
readonly color?: string;
|
|
70
|
+
}
|
|
71
|
+
/** The identity view. */
|
|
72
|
+
export declare const G9_GRAPH_IDENTITY: G9GraphView;
|
|
73
|
+
/** Keeps `zoom` within [min, max]. */
|
|
74
|
+
export declare function clampZoom(zoom: number, min: number, max: number): number;
|
|
75
|
+
/** The world point under a screen point (relative to the canvas). */
|
|
76
|
+
export declare function toWorld(view: G9GraphView, sx: number, sy: number): G9GraphPoint;
|
|
77
|
+
/** The screen point (relative to the canvas) of a world point. */
|
|
78
|
+
export declare function toScreen(view: G9GraphView, wx: number, wy: number): G9GraphPoint;
|
|
79
|
+
/** Zooms by `factor` keeping the world point under the screen point (sx, sy) still: wheel and pinch around the pointer. */
|
|
80
|
+
export declare function zoomAt(view: G9GraphView, factor: number, sx: number, sy: number, min: number, max: number): G9GraphView;
|
|
81
|
+
/** Moves the view by a screen delta. */
|
|
82
|
+
export declare function panBy(view: G9GraphView, dx: number, dy: number): G9GraphView;
|
|
83
|
+
/** The rect around every node and group; null when there is nothing. */
|
|
84
|
+
export declare function contentBounds(nodes: readonly G9GraphRect[], groups?: readonly G9GraphRect[]): G9GraphRect | null;
|
|
85
|
+
/** The view that shows `bounds` whole inside a viewport of `width` × `height`, centred, with `padding` (screen px). */
|
|
86
|
+
export declare function fitView(bounds: G9GraphRect | null, width: number, height: number, options?: {
|
|
87
|
+
readonly padding?: number;
|
|
88
|
+
readonly minZoom?: number;
|
|
89
|
+
readonly maxZoom?: number;
|
|
90
|
+
}): G9GraphView;
|
|
91
|
+
/** The world rect the viewport shows, grown by `margin` (a share of the viewport on each side) for culling. */
|
|
92
|
+
export declare function visibleWorld(view: G9GraphView, width: number, height: number, margin?: number): G9GraphRect;
|
|
93
|
+
/** True when two rects overlap (touching counts). */
|
|
94
|
+
export declare function intersects(a: G9GraphRect, b: G9GraphRect): boolean;
|
|
95
|
+
/** Where an edge end sits: its port's point on the node's side, in world units. */
|
|
96
|
+
export declare function portPoint(node: G9GraphNode, end: G9GraphEnd | undefined, role: 'from' | 'to'): G9GraphPoint;
|
|
97
|
+
/** The bezier of an edge leaving `a` to the right and entering `b` from the left (both sides honoured). */
|
|
98
|
+
export declare function edgeCurve(a: G9GraphPoint, b: G9GraphPoint, aSide?: 'left' | 'right', bSide?: 'left' | 'right', curvature?: number): {
|
|
99
|
+
readonly c1: G9GraphPoint;
|
|
100
|
+
readonly c2: G9GraphPoint;
|
|
101
|
+
};
|
|
102
|
+
/** The SVG path data of an edge's bezier. */
|
|
103
|
+
export declare function edgePathData(a: G9GraphPoint, b: G9GraphPoint, c1: G9GraphPoint, c2: G9GraphPoint): string;
|
|
104
|
+
/** The bezier's point at t (the label sits at t = 0.5). */
|
|
105
|
+
export declare function bezierPoint(a: G9GraphPoint, c1: G9GraphPoint, c2: G9GraphPoint, b: G9GraphPoint, t: number): G9GraphPoint;
|
|
106
|
+
/** An edge laid out: its path, label point and bounding rect, or null when an end's node is missing. */
|
|
107
|
+
export interface G9EdgeGeometry {
|
|
108
|
+
readonly id: string;
|
|
109
|
+
readonly d: string;
|
|
110
|
+
readonly mid: G9GraphPoint;
|
|
111
|
+
readonly box: G9GraphRect;
|
|
112
|
+
}
|
|
113
|
+
/** Lays out an edge between its nodes. */
|
|
114
|
+
export declare function edgeGeometry(edge: G9GraphEdge, byId: ReadonlyMap<string, G9GraphNode>, curvature?: number): G9EdgeGeometry | null;
|
|
115
|
+
/** What is drawn of the graph in the visible world: node ids and edges whose box meets it. */
|
|
116
|
+
export declare function cullGraph(nodes: readonly G9GraphNode[], edges: readonly G9EdgeGeometry[], visible: G9GraphRect): {
|
|
117
|
+
readonly nodes: ReadonlySet<string>;
|
|
118
|
+
readonly edges: ReadonlySet<string>;
|
|
119
|
+
};
|
|
120
|
+
/** Rounds to the grid (no grid: unchanged). */
|
|
121
|
+
export declare function snapTo(v: number, grid: number | undefined): number;
|
|
122
|
+
/** The topmost node (the last drawn) under a world point, or null. */
|
|
123
|
+
export declare function nodeAt(nodes: readonly G9GraphNode[], wx: number, wy: number): G9GraphNode | null;
|
|
124
|
+
/** The selection after a click on `id` (null: on empty space). `additive` (Shift / Ctrl / ⌘) toggles it. */
|
|
125
|
+
export declare function nextSelection(selection: readonly string[], id: string | null, additive: boolean): string[];
|
|
126
|
+
/** An arrow key's direction. */
|
|
127
|
+
export type G9GraphDirection = 'left' | 'right' | 'up' | 'down';
|
|
128
|
+
/**
|
|
129
|
+
* The node an arrow moves the focus to: the nearest centre in that direction, weighing the sideways distance double;
|
|
130
|
+
* null when there is none that way (or no node is focused and there are none).
|
|
131
|
+
*/
|
|
132
|
+
export declare function nodeInDirection(nodes: readonly G9GraphNode[], from: string | null, dir: G9GraphDirection): string | null;
|
|
133
|
+
/** Options of {@link layeredLayout}. */
|
|
134
|
+
export interface G9LayeredLayoutOptions {
|
|
135
|
+
/** `'right'` (default): layers run left to right; `'down'`: top to bottom. */
|
|
136
|
+
readonly direction?: 'right' | 'down';
|
|
137
|
+
/** Between layers (world units). Default 80. */
|
|
138
|
+
readonly layerGap?: number;
|
|
139
|
+
/** Between nodes of a layer. Default 24. */
|
|
140
|
+
readonly nodeGap?: number;
|
|
141
|
+
/** Ordering sweeps that reduce crossings. Default 4. */
|
|
142
|
+
readonly sweeps?: number;
|
|
143
|
+
/** Where the first layer starts. Default (0, 0). */
|
|
144
|
+
readonly origin?: G9GraphPoint;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A simple layered auto-layout (longest-path layers, barycentre ordering): sources first, each node one layer past its
|
|
148
|
+
* deepest predecessor; cycles are broken at the edge that closes them. Answers each node's top-left; the app applies it.
|
|
149
|
+
*/
|
|
150
|
+
export declare function layeredLayout(nodes: readonly Pick<G9GraphNode, 'id' | 'width' | 'height'>[], edges: readonly Pick<G9GraphEdge, 'from' | 'to'>[], options?: G9LayeredLayoutOptions): Map<string, G9GraphPoint>;
|
|
151
|
+
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,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,OAAO,GAAG,QAAQ,CAAC,EAAE,EAC9D,KAAK,EAAE,SAAS,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,EAClD,OAAO,GAAE,sBAA2B,GACnC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CA0F3B"}
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
const G9_GRAPH_IDENTITY = Object.freeze({
|
|
2
|
+
zoom: 1,
|
|
3
|
+
x: 0,
|
|
4
|
+
y: 0
|
|
5
|
+
});
|
|
6
|
+
function clampZoom(zoom, min, max) {
|
|
7
|
+
if (!Number.isFinite(zoom)) return 1;
|
|
8
|
+
return Math.min(max, Math.max(min, zoom));
|
|
9
|
+
}
|
|
10
|
+
function toWorld(view, sx, sy) {
|
|
11
|
+
return {
|
|
12
|
+
x: (sx - view.x) / view.zoom,
|
|
13
|
+
y: (sy - view.y) / view.zoom
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function toScreen(view, wx, wy) {
|
|
17
|
+
return {
|
|
18
|
+
x: wx * view.zoom + view.x,
|
|
19
|
+
y: wy * view.zoom + view.y
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function zoomAt(view, factor, sx, sy, min, max) {
|
|
23
|
+
const zoom = clampZoom(view.zoom * factor, min, max);
|
|
24
|
+
const k = zoom / view.zoom;
|
|
25
|
+
return {
|
|
26
|
+
zoom,
|
|
27
|
+
x: sx - (sx - view.x) * k,
|
|
28
|
+
y: sy - (sy - view.y) * k
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function panBy(view, dx, dy) {
|
|
32
|
+
return {
|
|
33
|
+
zoom: view.zoom,
|
|
34
|
+
x: view.x + dx,
|
|
35
|
+
y: view.y + dy
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function contentBounds(nodes, groups = []) {
|
|
39
|
+
let x0 = 1 / 0;
|
|
40
|
+
let y0 = 1 / 0;
|
|
41
|
+
let x1 = -1 / 0;
|
|
42
|
+
let y1 = -1 / 0;
|
|
43
|
+
for (const r of nodes.concat(groups)){
|
|
44
|
+
x0 = Math.min(x0, r.x);
|
|
45
|
+
y0 = Math.min(y0, r.y);
|
|
46
|
+
x1 = Math.max(x1, r.x + r.width);
|
|
47
|
+
y1 = Math.max(y1, r.y + r.height);
|
|
48
|
+
}
|
|
49
|
+
return Number.isFinite(x0) ? {
|
|
50
|
+
x: x0,
|
|
51
|
+
y: y0,
|
|
52
|
+
width: x1 - x0,
|
|
53
|
+
height: y1 - y0
|
|
54
|
+
} : null;
|
|
55
|
+
}
|
|
56
|
+
function fitView(bounds, width, height, options = {}) {
|
|
57
|
+
var _options_padding, _options_minZoom, _options_maxZoom;
|
|
58
|
+
if (!bounds || width <= 0 || height <= 0) return G9_GRAPH_IDENTITY;
|
|
59
|
+
const pad = null != (_options_padding = options.padding) ? _options_padding : 32;
|
|
60
|
+
const zx = (width - 2 * pad) / Math.max(1, bounds.width);
|
|
61
|
+
const zy = (height - 2 * pad) / Math.max(1, bounds.height);
|
|
62
|
+
const zoom = clampZoom(Math.min(zx, zy), null != (_options_minZoom = options.minZoom) ? _options_minZoom : 0.1, null != (_options_maxZoom = options.maxZoom) ? _options_maxZoom : 1);
|
|
63
|
+
return {
|
|
64
|
+
zoom,
|
|
65
|
+
x: (width - bounds.width * zoom) / 2 - bounds.x * zoom,
|
|
66
|
+
y: (height - bounds.height * zoom) / 2 - bounds.y * zoom
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function visibleWorld(view, width, height, margin = 0.5) {
|
|
70
|
+
const tl = toWorld(view, -width * margin, -height * margin);
|
|
71
|
+
return {
|
|
72
|
+
x: tl.x + 0,
|
|
73
|
+
y: tl.y + 0,
|
|
74
|
+
width: width * (1 + 2 * margin) / view.zoom,
|
|
75
|
+
height: height * (1 + 2 * margin) / view.zoom
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function intersects(a, b) {
|
|
79
|
+
return a.x <= b.x + b.width && b.x <= a.x + a.width && a.y <= b.y + b.height && b.y <= a.y + a.height;
|
|
80
|
+
}
|
|
81
|
+
function portPoint(node, end, role) {
|
|
82
|
+
var _node_ports, _ref;
|
|
83
|
+
const ports = null != (_node_ports = node.ports) ? _node_ports : [];
|
|
84
|
+
const port = (null == end ? void 0 : end.port) !== void 0 ? ports.find((p)=>p.id === end.port) : void 0;
|
|
85
|
+
const side = null != (_ref = null == port ? void 0 : port.side) ? _ref : 'from' === role ? 'right' : 'left';
|
|
86
|
+
let offset = null == port ? void 0 : port.offset;
|
|
87
|
+
if (port && void 0 === offset) {
|
|
88
|
+
const same = ports.filter((p)=>p.side === side);
|
|
89
|
+
offset = (same.indexOf(port) + 1) / (same.length + 1);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
x: 'right' === side ? node.x + node.width : node.x,
|
|
93
|
+
y: node.y + node.height * (null != offset ? offset : 0.5)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function edgeCurve(a, b, aSide = 'right', bSide = 'left', curvature = 0.5) {
|
|
97
|
+
const d = Math.max(40, Math.abs(b.x - a.x) * curvature);
|
|
98
|
+
return {
|
|
99
|
+
c1: {
|
|
100
|
+
x: a.x + ('right' === aSide ? d : -d),
|
|
101
|
+
y: a.y
|
|
102
|
+
},
|
|
103
|
+
c2: {
|
|
104
|
+
x: b.x + ('left' === bSide ? -d : d),
|
|
105
|
+
y: b.y
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const r1 = (v)=>Math.round(10 * v) / 10;
|
|
110
|
+
function edgePathData(a, b, c1, c2) {
|
|
111
|
+
return `M${r1(a.x)} ${r1(a.y)}C${r1(c1.x)} ${r1(c1.y)} ${r1(c2.x)} ${r1(c2.y)} ${r1(b.x)} ${r1(b.y)}`;
|
|
112
|
+
}
|
|
113
|
+
function bezierPoint(a, c1, c2, b, t) {
|
|
114
|
+
const u = 1 - t;
|
|
115
|
+
const w0 = u * u * u;
|
|
116
|
+
const w1 = 3 * u * u * t;
|
|
117
|
+
const w2 = 3 * u * t * t;
|
|
118
|
+
const w3 = t * t * t;
|
|
119
|
+
return {
|
|
120
|
+
x: w0 * a.x + w1 * c1.x + w2 * c2.x + w3 * b.x,
|
|
121
|
+
y: w0 * a.y + w1 * c1.y + w2 * c2.y + w3 * b.y
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function edgeGeometry(edge, byId, curvature = 0.5) {
|
|
125
|
+
const na = byId.get(edge.from.node);
|
|
126
|
+
const nb = byId.get(edge.to.node);
|
|
127
|
+
if (!na || !nb) return null;
|
|
128
|
+
const a = portPoint(na, edge.from, 'from');
|
|
129
|
+
const b = portPoint(nb, edge.to, 'to');
|
|
130
|
+
const sideOf = (n, end, role)=>{
|
|
131
|
+
var _ref;
|
|
132
|
+
var _n_ports_find, _n_ports;
|
|
133
|
+
return null != (_ref = null == (_n_ports = n.ports) ? void 0 : null == (_n_ports_find = _n_ports.find((p)=>p.id === end.port)) ? void 0 : _n_ports_find.side) ? _ref : 'from' === role ? 'right' : 'left';
|
|
134
|
+
};
|
|
135
|
+
const { c1, c2 } = edgeCurve(a, b, sideOf(na, edge.from, 'from'), sideOf(nb, edge.to, 'to'), curvature);
|
|
136
|
+
const xs = [
|
|
137
|
+
a.x,
|
|
138
|
+
b.x,
|
|
139
|
+
c1.x,
|
|
140
|
+
c2.x
|
|
141
|
+
];
|
|
142
|
+
const ys = [
|
|
143
|
+
a.y,
|
|
144
|
+
b.y,
|
|
145
|
+
c1.y,
|
|
146
|
+
c2.y
|
|
147
|
+
];
|
|
148
|
+
const x0 = Math.min(...xs);
|
|
149
|
+
const y0 = Math.min(...ys);
|
|
150
|
+
return {
|
|
151
|
+
id: edge.id,
|
|
152
|
+
d: edgePathData(a, b, c1, c2),
|
|
153
|
+
mid: bezierPoint(a, c1, c2, b, 0.5),
|
|
154
|
+
box: {
|
|
155
|
+
x: x0,
|
|
156
|
+
y: y0,
|
|
157
|
+
width: Math.max(...xs) - x0,
|
|
158
|
+
height: Math.max(...ys) - y0
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function cullGraph(nodes, edges, visible) {
|
|
163
|
+
const n = new Set();
|
|
164
|
+
for (const node of nodes)if (intersects(node, visible)) n.add(node.id);
|
|
165
|
+
const e = new Set();
|
|
166
|
+
for (const edge of edges)if (intersects(edge.box, visible)) e.add(edge.id);
|
|
167
|
+
return {
|
|
168
|
+
nodes: n,
|
|
169
|
+
edges: e
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function snapTo(v, grid) {
|
|
173
|
+
return grid && grid > 0 ? Math.round(v / grid) * grid : v;
|
|
174
|
+
}
|
|
175
|
+
function nodeAt(nodes, wx, wy) {
|
|
176
|
+
for(let i = nodes.length - 1; i >= 0; i--){
|
|
177
|
+
const n = nodes[i];
|
|
178
|
+
if (wx >= n.x && wx <= n.x + n.width && wy >= n.y && wy <= n.y + n.height) return n;
|
|
179
|
+
}
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
function nextSelection(selection, id, additive) {
|
|
183
|
+
if (null === id) return additive ? selection.slice() : [];
|
|
184
|
+
if (!additive) return [
|
|
185
|
+
id
|
|
186
|
+
];
|
|
187
|
+
return selection.includes(id) ? selection.filter((s)=>s !== id) : selection.concat(id);
|
|
188
|
+
}
|
|
189
|
+
function got(m, k) {
|
|
190
|
+
return m.get(k);
|
|
191
|
+
}
|
|
192
|
+
function nodeInDirection(nodes, from, dir) {
|
|
193
|
+
var _ref;
|
|
194
|
+
var _nodes_;
|
|
195
|
+
const start = from ? nodes.find((n)=>n.id === from) : void 0;
|
|
196
|
+
if (!start) return null != (_ref = null == (_nodes_ = nodes[0]) ? void 0 : _nodes_.id) ? _ref : null;
|
|
197
|
+
const cx = start.x + start.width / 2;
|
|
198
|
+
const cy = start.y + start.height / 2;
|
|
199
|
+
let best = null;
|
|
200
|
+
let score = 1 / 0;
|
|
201
|
+
for (const n of nodes){
|
|
202
|
+
if (n.id === start.id) continue;
|
|
203
|
+
const dx = n.x + n.width / 2 - cx;
|
|
204
|
+
const dy = n.y + n.height / 2 - cy;
|
|
205
|
+
const along = 'left' === dir ? -dx : 'right' === dir ? dx : 'up' === dir ? -dy : dy;
|
|
206
|
+
if (along <= 0) continue;
|
|
207
|
+
const side = 'left' === dir || 'right' === dir ? Math.abs(dy) : Math.abs(dx);
|
|
208
|
+
const s = along + 2 * side;
|
|
209
|
+
if (s < score) {
|
|
210
|
+
score = s;
|
|
211
|
+
best = n.id;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return best;
|
|
215
|
+
}
|
|
216
|
+
function layeredLayout(nodes, edges, options = {}) {
|
|
217
|
+
var _options_sweeps, _options_layerGap, _options_nodeGap, _ref, _ref1;
|
|
218
|
+
var _raw_get, _preds_get, _options_origin, _options_origin1;
|
|
219
|
+
const ids = nodes.map((n)=>n.id);
|
|
220
|
+
const known = new Set(ids);
|
|
221
|
+
const out = new Map();
|
|
222
|
+
for (const id of ids)out.set(id, []);
|
|
223
|
+
const state = new Map();
|
|
224
|
+
const raw = new Map();
|
|
225
|
+
for (const id of ids)raw.set(id, []);
|
|
226
|
+
for (const e of edges)if (known.has(e.from.node) && known.has(e.to.node) && e.from.node !== e.to.node) null == (_raw_get = raw.get(e.from.node)) || _raw_get.push(e.to.node);
|
|
227
|
+
const visit = (id)=>{
|
|
228
|
+
state.set(id, 1);
|
|
229
|
+
for (const t of got(raw, id)){
|
|
230
|
+
var _state_get;
|
|
231
|
+
var _out_get;
|
|
232
|
+
const s = null != (_state_get = state.get(t)) ? _state_get : 0;
|
|
233
|
+
if (1 !== s) {
|
|
234
|
+
null == (_out_get = out.get(id)) || _out_get.push(t);
|
|
235
|
+
if (0 === s) visit(t);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
state.set(id, 2);
|
|
239
|
+
};
|
|
240
|
+
for (const id of ids)if (!state.get(id)) visit(id);
|
|
241
|
+
const indeg = new Map(ids.map((id)=>[
|
|
242
|
+
id,
|
|
243
|
+
0
|
|
244
|
+
]));
|
|
245
|
+
for (const ts of out.values())for (const t of ts)indeg.set(t, got(indeg, t) + 1);
|
|
246
|
+
const layer = new Map(ids.map((id)=>[
|
|
247
|
+
id,
|
|
248
|
+
0
|
|
249
|
+
]));
|
|
250
|
+
const queue = ids.filter((id)=>0 === indeg.get(id));
|
|
251
|
+
for(let i = 0; i < queue.length; i++){
|
|
252
|
+
const id = queue[i];
|
|
253
|
+
for (const t of got(out, id)){
|
|
254
|
+
layer.set(t, Math.max(got(layer, t), got(layer, id) + 1));
|
|
255
|
+
indeg.set(t, got(indeg, t) - 1);
|
|
256
|
+
if (0 === indeg.get(t)) queue.push(t);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
const depth = Math.max(0, ...Array.from(layer.values()));
|
|
260
|
+
const layers = Array.from({
|
|
261
|
+
length: depth + 1
|
|
262
|
+
}, ()=>[]);
|
|
263
|
+
for (const id of ids)layers[got(layer, id)].push(id);
|
|
264
|
+
const preds = new Map(ids.map((id)=>[
|
|
265
|
+
id,
|
|
266
|
+
[]
|
|
267
|
+
]));
|
|
268
|
+
for (const [s, ts] of out)for (const t of ts)null == (_preds_get = preds.get(t)) || _preds_get.push(s);
|
|
269
|
+
const posOf = new Map();
|
|
270
|
+
const index = ()=>{
|
|
271
|
+
for (const l of layers)l.forEach((id, i)=>{
|
|
272
|
+
posOf.set(id, i);
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
index();
|
|
276
|
+
const sweeps = null != (_options_sweeps = options.sweeps) ? _options_sweeps : 4;
|
|
277
|
+
for(let s = 0; s < sweeps; s++){
|
|
278
|
+
const down = s % 2 === 0;
|
|
279
|
+
const order = down ? layers.slice(1) : layers.slice(0, -1).reverse();
|
|
280
|
+
for (const l of order){
|
|
281
|
+
const bary = new Map();
|
|
282
|
+
for (const id of l){
|
|
283
|
+
const ns = got(down ? preds : out, id);
|
|
284
|
+
bary.set(id, ns.length ? ns.reduce((a, n)=>a + got(posOf, n), 0) / ns.length : got(posOf, id));
|
|
285
|
+
}
|
|
286
|
+
l.sort((a, b)=>got(bary, a) - got(bary, b) || got(posOf, a) - got(posOf, b));
|
|
287
|
+
l.forEach((id, i)=>{
|
|
288
|
+
posOf.set(id, i);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const size = new Map(nodes.map((n)=>[
|
|
293
|
+
n.id,
|
|
294
|
+
n
|
|
295
|
+
]));
|
|
296
|
+
const across = 'down' === options.direction;
|
|
297
|
+
const layerGap = null != (_options_layerGap = options.layerGap) ? _options_layerGap : 80;
|
|
298
|
+
const nodeGap = null != (_options_nodeGap = options.nodeGap) ? _options_nodeGap : 24;
|
|
299
|
+
const ox = null != (_ref = null == (_options_origin = options.origin) ? void 0 : _options_origin.x) ? _ref : 0;
|
|
300
|
+
const oy = null != (_ref1 = null == (_options_origin1 = options.origin) ? void 0 : _options_origin1.y) ? _ref1 : 0;
|
|
301
|
+
const extent = (l)=>l.reduce((a, id)=>a + (across ? got(size, id).width : got(size, id).height), 0) + nodeGap * Math.max(0, l.length - 1);
|
|
302
|
+
const widest = Math.max(0, ...layers.map(extent));
|
|
303
|
+
const result = new Map();
|
|
304
|
+
let along = 0;
|
|
305
|
+
for (const l of layers){
|
|
306
|
+
const thick = Math.max(0, ...l.map((id)=>across ? got(size, id).height : got(size, id).width));
|
|
307
|
+
let cross = (widest - extent(l)) / 2;
|
|
308
|
+
for (const id of l){
|
|
309
|
+
const n = size.get(id);
|
|
310
|
+
result.set(id, across ? {
|
|
311
|
+
x: ox + cross,
|
|
312
|
+
y: oy + along
|
|
313
|
+
} : {
|
|
314
|
+
x: ox + along,
|
|
315
|
+
y: oy + cross
|
|
316
|
+
});
|
|
317
|
+
cross += (across ? n.width : n.height) + nodeGap;
|
|
318
|
+
}
|
|
319
|
+
along += thick + layerGap;
|
|
320
|
+
}
|
|
321
|
+
return result;
|
|
322
|
+
}
|
|
323
|
+
export { G9_GRAPH_IDENTITY, bezierPoint, clampZoom, contentBounds, cullGraph, edgeCurve, edgeGeometry, edgePathData, fitView, intersects, layeredLayout, nextSelection, nodeAt, nodeInDirection, panBy, portPoint, snapTo, toScreen, toWorld, visibleWorld, zoomAt };
|
|
324
|
+
|
|
325
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../src/core.ts"],"sourcesContent":["// The plain-TypeScript core of G9GraphCanvas (2.9.0, G9ProxyManager): the view (pan and zoom), ports and bezier edges,\n// bounds and fit, off-screen culling, snapping, selection, keyboard navigation between nodes and a simple layered\n// auto-layout. No JSX and no runtime import, so Node tests it whole and the canvas's main-thread code mirrors it. The\n// functions named `…MT` are the main-thread twins (a worklet may only call other worklets).\n\n/** A point or a size in world units (the graph's own space, before the zoom). */\nexport interface G9GraphPoint {\n readonly x: number;\n readonly y: number;\n}\n\n/** A rect in world units. */\nexport interface G9GraphRect {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** How the world is shown: screen = world × zoom + (x, y). */\nexport interface G9GraphView {\n readonly zoom: number;\n readonly x: number;\n readonly y: number;\n}\n\n/** A port on a node's side; `offset` 0..1 along the side (default spread evenly among that side's ports). */\nexport interface G9GraphPort {\n readonly id: string;\n readonly side: 'left' | 'right';\n readonly offset?: number;\n}\n\n/** A node as the canvas needs it: where, how big, its ports. The app draws its card. */\nexport interface G9GraphNode {\n readonly id: string;\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n readonly ports?: readonly G9GraphPort[];\n /** Whether it may be dragged (default true). */\n readonly draggable?: boolean;\n /** Whether it takes a drop of this external drag payload (`G9DragPayload` of `@g9tm/lynxcontrols/pointer`). */\n readonly acceptsDrop?: (payload: { readonly kind: string; readonly data: unknown }) => boolean;\n}\n\n/** An end of an edge: a node, and one of its ports (default: the right side's middle for a source, left for a target). */\nexport interface G9GraphEnd {\n readonly node: string;\n readonly port?: string;\n}\n\n/** How an edge is drawn. */\nexport type G9GraphEdgeStyle = 'solid' | 'dashed' | 'active';\n\n/** An edge between two node ports. */\nexport interface G9GraphEdge {\n readonly id: string;\n readonly from: G9GraphEnd;\n readonly to: G9GraphEnd;\n readonly label?: string;\n /** `'active'` is dashed and moving. Default `'solid'`. */\n readonly style?: G9GraphEdgeStyle;\n /** A colour of the app's own (default the theme's outline; active: primary). */\n readonly color?: string;\n readonly width?: number;\n}\n\n/** A titled background area (a lane, a pillar) at an app-given rect. */\nexport interface G9GraphGroup {\n readonly id: string;\n readonly title?: string;\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n /** A colour of the app's own for its fill (default the theme's container colour). */\n readonly color?: string;\n}\n\n/** The identity view. */\nexport const G9_GRAPH_IDENTITY: G9GraphView = Object.freeze({ zoom: 1, x: 0, y: 0 });\n\n/** Keeps `zoom` within [min, max]. */\nexport function clampZoom(zoom: number, min: number, max: number): number {\n if (!Number.isFinite(zoom)) return 1;\n return Math.min(max, Math.max(min, zoom));\n}\n\n/** The world point under a screen point (relative to the canvas). */\nexport function toWorld(view: G9GraphView, sx: number, sy: number): G9GraphPoint {\n return { x: (sx - view.x) / view.zoom, y: (sy - view.y) / view.zoom };\n}\n\n/** The screen point (relative to the canvas) of a world point. */\nexport function toScreen(view: G9GraphView, wx: number, wy: number): G9GraphPoint {\n return { x: wx * view.zoom + view.x, y: wy * view.zoom + view.y };\n}\n\n/** Zooms by `factor` keeping the world point under the screen point (sx, sy) still: wheel and pinch around the pointer. */\nexport function zoomAt(\n view: G9GraphView,\n factor: number,\n sx: number,\n sy: number,\n min: number,\n max: number,\n): G9GraphView {\n const zoom = clampZoom(view.zoom * factor, min, max);\n const k = zoom / view.zoom;\n return { zoom, x: sx - (sx - view.x) * k, y: sy - (sy - view.y) * k };\n}\n\n/** Moves the view by a screen delta. */\nexport function panBy(view: G9GraphView, dx: number, dy: number): G9GraphView {\n return { zoom: view.zoom, x: view.x + dx, y: view.y + dy };\n}\n\n/** The rect around every node and group; null when there is nothing. */\nexport function contentBounds(nodes: readonly G9GraphRect[], groups: readonly G9GraphRect[] = []): G9GraphRect | null {\n let x0 = Number.POSITIVE_INFINITY;\n let y0 = Number.POSITIVE_INFINITY;\n let x1 = Number.NEGATIVE_INFINITY;\n let y1 = Number.NEGATIVE_INFINITY;\n for (const r of nodes.concat(groups)) {\n x0 = Math.min(x0, r.x);\n y0 = Math.min(y0, r.y);\n x1 = Math.max(x1, r.x + r.width);\n y1 = Math.max(y1, r.y + r.height);\n }\n return Number.isFinite(x0) ? { x: x0, y: y0, width: x1 - x0, height: y1 - y0 } : null;\n}\n\n/** The view that shows `bounds` whole inside a viewport of `width` × `height`, centred, with `padding` (screen px). */\nexport function fitView(\n bounds: G9GraphRect | null,\n width: number,\n height: number,\n options: { readonly padding?: number; readonly minZoom?: number; readonly maxZoom?: number } = {},\n): G9GraphView {\n if (!bounds || width <= 0 || height <= 0) return G9_GRAPH_IDENTITY;\n const pad = options.padding ?? 32;\n const zx = (width - pad * 2) / Math.max(1, bounds.width);\n const zy = (height - pad * 2) / Math.max(1, bounds.height);\n const zoom = clampZoom(Math.min(zx, zy), options.minZoom ?? 0.1, options.maxZoom ?? 1);\n return {\n zoom,\n x: (width - bounds.width * zoom) / 2 - bounds.x * zoom,\n y: (height - bounds.height * zoom) / 2 - bounds.y * zoom,\n };\n}\n\n/** The world rect the viewport shows, grown by `margin` (a share of the viewport on each side) for culling. */\nexport function visibleWorld(view: G9GraphView, width: number, height: number, margin = 0.5): G9GraphRect {\n const tl = toWorld(view, -width * margin, -height * margin);\n return {\n x: tl.x + 0,\n y: tl.y + 0,\n width: (width * (1 + margin * 2)) / view.zoom,\n height: (height * (1 + margin * 2)) / view.zoom,\n };\n}\n\n/** True when two rects overlap (touching counts). */\nexport function intersects(a: G9GraphRect, b: G9GraphRect): boolean {\n return a.x <= b.x + b.width && b.x <= a.x + a.width && a.y <= b.y + b.height && b.y <= a.y + a.height;\n}\n\n/** Where an edge end sits: its port's point on the node's side, in world units. */\nexport function portPoint(node: G9GraphNode, end: G9GraphEnd | undefined, role: 'from' | 'to'): G9GraphPoint {\n const ports = node.ports ?? [];\n const port = end?.port !== undefined ? ports.find((p) => p.id === end.port) : undefined;\n const side = port?.side ?? (role === 'from' ? 'right' : 'left');\n let offset = port?.offset;\n if (port && offset === undefined) {\n const same = ports.filter((p) => p.side === side);\n offset = (same.indexOf(port) + 1) / (same.length + 1);\n }\n return { x: side === 'right' ? node.x + node.width : node.x, y: node.y + node.height * (offset ?? 0.5) };\n}\n\n/** The bezier of an edge leaving `a` to the right and entering `b` from the left (both sides honoured). */\nexport function edgeCurve(\n a: G9GraphPoint,\n b: G9GraphPoint,\n aSide: 'left' | 'right' = 'right',\n bSide: 'left' | 'right' = 'left',\n curvature = 0.5,\n): { readonly c1: G9GraphPoint; readonly c2: G9GraphPoint } {\n const d = Math.max(40, Math.abs(b.x - a.x) * curvature);\n return {\n c1: { x: a.x + (aSide === 'right' ? d : -d), y: a.y },\n c2: { x: b.x + (bSide === 'left' ? -d : d), y: b.y },\n };\n}\n\nconst r1 = (v: number) => Math.round(v * 10) / 10;\n\n/** The SVG path data of an edge's bezier. */\nexport function edgePathData(a: G9GraphPoint, b: G9GraphPoint, c1: G9GraphPoint, c2: G9GraphPoint): string {\n return `M${r1(a.x)} ${r1(a.y)}C${r1(c1.x)} ${r1(c1.y)} ${r1(c2.x)} ${r1(c2.y)} ${r1(b.x)} ${r1(b.y)}`;\n}\n\n/** The bezier's point at t (the label sits at t = 0.5). */\nexport function bezierPoint(\n a: G9GraphPoint,\n c1: G9GraphPoint,\n c2: G9GraphPoint,\n b: G9GraphPoint,\n t: number,\n): G9GraphPoint {\n const u = 1 - t;\n const w0 = u * u * u;\n const w1 = 3 * u * u * t;\n const w2 = 3 * u * t * t;\n const w3 = t * t * t;\n return { x: w0 * a.x + w1 * c1.x + w2 * c2.x + w3 * b.x, y: w0 * a.y + w1 * c1.y + w2 * c2.y + w3 * b.y };\n}\n\n/** An edge laid out: its path, label point and bounding rect, or null when an end's node is missing. */\nexport interface G9EdgeGeometry {\n readonly id: string;\n readonly d: string;\n readonly mid: G9GraphPoint;\n readonly box: G9GraphRect;\n}\n\n/** Lays out an edge between its nodes. */\nexport function edgeGeometry(\n edge: G9GraphEdge,\n byId: ReadonlyMap<string, G9GraphNode>,\n curvature = 0.5,\n): G9EdgeGeometry | null {\n const na = byId.get(edge.from.node);\n const nb = byId.get(edge.to.node);\n if (!na || !nb) return null;\n const a = portPoint(na, edge.from, 'from');\n const b = portPoint(nb, edge.to, 'to');\n const sideOf = (n: G9GraphNode, end: G9GraphEnd, role: 'from' | 'to') =>\n n.ports?.find((p) => p.id === end.port)?.side ?? (role === 'from' ? 'right' : 'left');\n const { c1, c2 } = edgeCurve(a, b, sideOf(na, edge.from, 'from'), sideOf(nb, edge.to, 'to'), curvature);\n const xs = [a.x, b.x, c1.x, c2.x];\n const ys = [a.y, b.y, c1.y, c2.y];\n const x0 = Math.min(...xs);\n const y0 = Math.min(...ys);\n return {\n id: edge.id,\n d: edgePathData(a, b, c1, c2),\n mid: bezierPoint(a, c1, c2, b, 0.5),\n box: { x: x0, y: y0, width: Math.max(...xs) - x0, height: Math.max(...ys) - y0 },\n };\n}\n\n/** What is drawn of the graph in the visible world: node ids and edges whose box meets it. */\nexport function cullGraph(\n nodes: readonly G9GraphNode[],\n edges: readonly G9EdgeGeometry[],\n visible: G9GraphRect,\n): { readonly nodes: ReadonlySet<string>; readonly edges: ReadonlySet<string> } {\n const n = new Set<string>();\n for (const node of nodes) if (intersects(node, visible)) n.add(node.id);\n const e = new Set<string>();\n for (const edge of edges) if (intersects(edge.box, visible)) e.add(edge.id);\n return { nodes: n, edges: e };\n}\n\n/** Rounds to the grid (no grid: unchanged). */\nexport function snapTo(v: number, grid: number | undefined): number {\n return grid && grid > 0 ? Math.round(v / grid) * grid : v;\n}\n\n/** The topmost node (the last drawn) under a world point, or null. */\nexport function nodeAt(nodes: readonly G9GraphNode[], wx: number, wy: number): G9GraphNode | null {\n for (let i = nodes.length - 1; i >= 0; i--) {\n const n = nodes[i] as G9GraphNode;\n if (wx >= n.x && wx <= n.x + n.width && wy >= n.y && wy <= n.y + n.height) return n;\n }\n return null;\n}\n\n/** The selection after a click on `id` (null: on empty space). `additive` (Shift / Ctrl / ⌘) toggles it. */\nexport function nextSelection(selection: readonly string[], id: string | null, additive: boolean): string[] {\n if (id === null) return additive ? selection.slice() : [];\n if (!additive) return [id];\n return selection.includes(id) ? selection.filter((s) => s !== id) : selection.concat(id);\n}\n\n/** An arrow key's direction. */\nexport type G9GraphDirection = 'left' | 'right' | 'up' | 'down';\n\n/** A lookup in a map that holds every id (the layout fills each map for every node first): it never misses. */\nfunction got<T>(m: ReadonlyMap<string, T>, k: string): T {\n return m.get(k) as T;\n}\n\n/**\n * The node an arrow moves the focus to: the nearest centre in that direction, weighing the sideways distance double;\n * null when there is none that way (or no node is focused and there are none).\n */\nexport function nodeInDirection(\n nodes: readonly G9GraphNode[],\n from: string | null,\n dir: G9GraphDirection,\n): string | null {\n const start = from ? nodes.find((n) => n.id === from) : undefined;\n if (!start) return nodes[0]?.id ?? null;\n const cx = start.x + start.width / 2;\n const cy = start.y + start.height / 2;\n let best: string | null = null;\n let score = Number.POSITIVE_INFINITY;\n for (const n of nodes) {\n if (n.id === start.id) continue;\n const dx = n.x + n.width / 2 - cx;\n const dy = n.y + n.height / 2 - cy;\n const along = dir === 'left' ? -dx : dir === 'right' ? dx : dir === 'up' ? -dy : dy;\n if (along <= 0) continue;\n const side = dir === 'left' || dir === 'right' ? Math.abs(dy) : Math.abs(dx);\n const s = along + side * 2;\n if (s < score) {\n score = s;\n best = n.id;\n }\n }\n return best;\n}\n\n/** Options of {@link layeredLayout}. */\nexport interface G9LayeredLayoutOptions {\n /** `'right'` (default): layers run left to right; `'down'`: top to bottom. */\n readonly direction?: 'right' | 'down';\n /** Between layers (world units). Default 80. */\n readonly layerGap?: number;\n /** Between nodes of a layer. Default 24. */\n readonly nodeGap?: number;\n /** Ordering sweeps that reduce crossings. Default 4. */\n readonly sweeps?: number;\n /** Where the first layer starts. Default (0, 0). */\n readonly origin?: G9GraphPoint;\n}\n\n/**\n * A simple layered auto-layout (longest-path layers, barycentre ordering): sources first, each node one layer past its\n * deepest predecessor; cycles are broken at the edge that closes them. Answers each node's top-left; the app applies it.\n */\nexport function layeredLayout(\n nodes: readonly Pick<G9GraphNode, 'id' | 'width' | 'height'>[],\n edges: readonly Pick<G9GraphEdge, 'from' | 'to'>[],\n options: G9LayeredLayoutOptions = {},\n): Map<string, G9GraphPoint> {\n const ids = nodes.map((n) => n.id);\n const known = new Set(ids);\n const out = new Map<string, string[]>();\n for (const id of ids) out.set(id, []);\n // drop self loops, unknown ends and the edges that close a cycle (depth-first, in the given order)\n const state = new Map<string, 0 | 1 | 2>();\n const raw = new Map<string, string[]>();\n for (const id of ids) raw.set(id, []);\n for (const e of edges)\n if (known.has(e.from.node) && known.has(e.to.node) && e.from.node !== e.to.node)\n raw.get(e.from.node)?.push(e.to.node);\n const visit = (id: string) => {\n state.set(id, 1);\n for (const t of got(raw, id)) {\n const s = state.get(t) ?? 0;\n if (s === 1) continue; // closes a cycle\n out.get(id)?.push(t);\n if (s === 0) visit(t);\n }\n state.set(id, 2);\n };\n for (const id of ids) if (!state.get(id)) visit(id);\n // longest path from the sources\n const indeg = new Map<string, number>(ids.map((id) => [id, 0]));\n for (const ts of out.values()) for (const t of ts) indeg.set(t, got(indeg, t) + 1);\n const layer = new Map<string, number>(ids.map((id) => [id, 0]));\n const queue = ids.filter((id) => indeg.get(id) === 0);\n for (let i = 0; i < queue.length; i++) {\n const id = queue[i] as string;\n for (const t of got(out, id)) {\n layer.set(t, Math.max(got(layer, t), got(layer, id) + 1));\n indeg.set(t, got(indeg, t) - 1);\n if (indeg.get(t) === 0) queue.push(t);\n }\n }\n const depth = Math.max(0, ...Array.from(layer.values()));\n const layers: string[][] = Array.from({ length: depth + 1 }, () => []);\n for (const id of ids) (layers[got(layer, id)] as string[]).push(id);\n // barycentre sweeps\n const preds = new Map<string, string[]>(ids.map((id) => [id, []]));\n for (const [s, ts] of out) for (const t of ts) preds.get(t)?.push(s);\n const posOf = new Map<string, number>();\n const index = () => {\n for (const l of layers)\n l.forEach((id, i) => {\n posOf.set(id, i);\n });\n };\n index();\n const sweeps = options.sweeps ?? 4;\n for (let s = 0; s < sweeps; s++) {\n const down = s % 2 === 0;\n const order = down ? layers.slice(1) : layers.slice(0, -1).reverse();\n for (const l of order) {\n const bary = new Map<string, number>();\n for (const id of l) {\n const ns = got(down ? preds : out, id);\n bary.set(id, ns.length ? ns.reduce((a, n) => a + got(posOf, n), 0) / ns.length : got(posOf, id));\n }\n l.sort((a, b) => got(bary, a) - got(bary, b) || got(posOf, a) - got(posOf, b));\n l.forEach((id, i) => {\n posOf.set(id, i);\n });\n }\n }\n // coordinates: layers side by side, each centred on the tallest\n const size = new Map(nodes.map((n) => [n.id, n]));\n const across = options.direction === 'down';\n const layerGap = options.layerGap ?? 80;\n const nodeGap = options.nodeGap ?? 24;\n const ox = options.origin?.x ?? 0;\n const oy = options.origin?.y ?? 0;\n const extent = (l: string[]) =>\n l.reduce((a, id) => a + (across ? got(size, id).width : got(size, id).height), 0) +\n nodeGap * Math.max(0, l.length - 1);\n const widest = Math.max(0, ...layers.map(extent));\n const result = new Map<string, G9GraphPoint>();\n let along = 0;\n for (const l of layers) {\n const thick = Math.max(0, ...l.map((id) => (across ? got(size, id).height : got(size, id).width)));\n let cross = (widest - extent(l)) / 2;\n for (const id of l) {\n const n = size.get(id) as Pick<G9GraphNode, 'width' | 'height'>;\n result.set(id, across ? { x: ox + cross, y: oy + along } : { x: ox + along, y: oy + cross });\n cross += (across ? n.width : n.height) + nodeGap;\n }\n along += thick + layerGap;\n }\n return result;\n}\n"],"names":["G9_GRAPH_IDENTITY","Object","clampZoom","zoom","min","max","Number","Math","toWorld","view","sx","sy","toScreen","wx","wy","zoomAt","factor","k","panBy","dx","dy","contentBounds","nodes","groups","x0","y0","x1","y1","r","fitView","bounds","width","height","options","_options_padding","_options_minZoom","_options_maxZoom","pad","zx","zy","visibleWorld","margin","tl","intersects","a","b","portPoint","node","end","role","_node_ports","ports","port","undefined","p","side","offset","same","edgeCurve","aSide","bSide","curvature","d","r1","v","edgePathData","c1","c2","bezierPoint","t","u","w0","w1","w2","w3","edgeGeometry","edge","byId","na","nb","sideOf","n","_n_ports_find","xs","ys","cullGraph","edges","visible","Set","e","snapTo","grid","nodeAt","i","nextSelection","selection","id","additive","s","got","m","nodeInDirection","from","dir","_nodes_","start","cx","cy","best","score","along","layeredLayout","_options_sweeps","_options_layerGap","_options_nodeGap","_raw_get","_preds_get","_options_origin","_options_origin1","ids","known","out","Map","state","raw","visit","_state_get","_out_get","indeg","ts","layer","queue","depth","Array","layers","preds","posOf","index","l","sweeps","down","order","bary","ns","size","across","layerGap","nodeGap","ox","oy","extent","widest","result","thick","cross"],"mappings":"AAkFO,MAAMA,oBAAiCC,OAAO,MAAM,CAAC;IAAE,MAAM;IAAG,GAAG;IAAG,GAAG;AAAE;AAG3E,SAASC,UAAUC,IAAY,EAAEC,GAAW,EAAEC,GAAW;IAC9D,IAAI,CAACC,OAAO,QAAQ,CAACH,OAAO,OAAO;IACnC,OAAOI,KAAK,GAAG,CAACF,KAAKE,KAAK,GAAG,CAACH,KAAKD;AACrC;AAGO,SAASK,QAAQC,IAAiB,EAAEC,EAAU,EAAEC,EAAU;IAC/D,OAAO;QAAE,GAAID,AA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