@multiplatform.one/node-graph 9.0.10 → 9.1.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/dist/cjs/graphLayout/GraphDots.cjs +60 -0
- package/dist/cjs/graphLayout/GraphDots.native.js +66 -0
- package/dist/cjs/graphLayout/GraphDots.native.js.map +1 -0
- package/dist/cjs/graphLayout/GraphLayout.cjs +153 -0
- package/dist/cjs/graphLayout/GraphLayout.native.js +163 -0
- package/dist/cjs/graphLayout/GraphLayout.native.js.map +1 -0
- package/dist/cjs/graphLayout/GraphSvg.cjs +68 -0
- package/dist/cjs/graphLayout/GraphSvg.native.js +73 -0
- package/dist/cjs/graphLayout/GraphSvg.native.js.map +1 -0
- package/dist/cjs/graphLayout/GraphViewport.cjs +263 -0
- package/dist/cjs/graphLayout/GraphViewport.native.js +279 -0
- package/dist/cjs/graphLayout/GraphViewport.native.js.map +1 -0
- package/dist/cjs/graphLayout/index.cjs +51 -0
- package/dist/cjs/graphLayout/index.native.js +54 -0
- package/dist/cjs/graphLayout/index.native.js.map +1 -0
- package/dist/cjs/graphLayout/ogden.fixture.cjs +30 -0
- package/dist/cjs/graphLayout/ogden.fixture.native.js +33 -0
- package/dist/cjs/graphLayout/ogden.fixture.native.js.map +1 -0
- package/dist/cjs/graphLayout/plan.cjs +263 -0
- package/dist/cjs/graphLayout/plan.native.js +372 -0
- package/dist/cjs/graphLayout/plan.native.js.map +1 -0
- package/dist/cjs/graphLayout/viewMath.cjs +142 -0
- package/dist/cjs/graphLayout/viewMath.native.js +147 -0
- package/dist/cjs/graphLayout/viewMath.native.js.map +1 -0
- package/dist/esm/graphLayout/GraphDots.mjs +35 -0
- package/dist/esm/graphLayout/GraphDots.mjs.map +1 -0
- package/dist/esm/graphLayout/GraphDots.native.js +38 -0
- package/dist/esm/graphLayout/GraphDots.native.js.map +1 -0
- package/dist/esm/graphLayout/GraphLayout.mjs +127 -0
- package/dist/esm/graphLayout/GraphLayout.mjs.map +1 -0
- package/dist/esm/graphLayout/GraphLayout.native.js +134 -0
- package/dist/esm/graphLayout/GraphLayout.native.js.map +1 -0
- package/dist/esm/graphLayout/GraphSvg.mjs +42 -0
- package/dist/esm/graphLayout/GraphSvg.mjs.map +1 -0
- package/dist/esm/graphLayout/GraphSvg.native.js +44 -0
- package/dist/esm/graphLayout/GraphSvg.native.js.map +1 -0
- package/dist/esm/graphLayout/GraphViewport.mjs +238 -0
- package/dist/esm/graphLayout/GraphViewport.mjs.map +1 -0
- package/dist/esm/graphLayout/GraphViewport.native.js +251 -0
- package/dist/esm/graphLayout/GraphViewport.native.js.map +1 -0
- package/dist/esm/graphLayout/index.mjs +7 -0
- package/dist/esm/graphLayout/index.mjs.map +1 -0
- package/dist/esm/graphLayout/index.native.js +7 -0
- package/dist/esm/graphLayout/index.native.js.map +1 -0
- package/dist/esm/graphLayout/ogden.fixture.mjs +4 -0
- package/dist/esm/graphLayout/ogden.fixture.mjs.map +1 -0
- package/dist/esm/graphLayout/ogden.fixture.native.js +4 -0
- package/dist/esm/graphLayout/ogden.fixture.native.js.map +1 -0
- package/dist/esm/graphLayout/plan.mjs +235 -0
- package/dist/esm/graphLayout/plan.mjs.map +1 -0
- package/dist/esm/graphLayout/plan.native.js +341 -0
- package/dist/esm/graphLayout/plan.native.js.map +1 -0
- package/dist/esm/graphLayout/viewMath.mjs +105 -0
- package/dist/esm/graphLayout/viewMath.mjs.map +1 -0
- package/dist/esm/graphLayout/viewMath.native.js +107 -0
- package/dist/esm/graphLayout/viewMath.native.js.map +1 -0
- package/dist/jsx/graphLayout/GraphDots.mjs +35 -0
- package/dist/jsx/graphLayout/GraphDots.mjs.map +1 -0
- package/dist/jsx/graphLayout/GraphDots.native.js +66 -0
- package/dist/jsx/graphLayout/GraphDots.native.js.map +1 -0
- package/dist/jsx/graphLayout/GraphLayout.mjs +127 -0
- package/dist/jsx/graphLayout/GraphLayout.mjs.map +1 -0
- package/dist/jsx/graphLayout/GraphLayout.native.js +163 -0
- package/dist/jsx/graphLayout/GraphLayout.native.js.map +1 -0
- package/dist/jsx/graphLayout/GraphSvg.mjs +42 -0
- package/dist/jsx/graphLayout/GraphSvg.mjs.map +1 -0
- package/dist/jsx/graphLayout/GraphSvg.native.js +73 -0
- package/dist/jsx/graphLayout/GraphSvg.native.js.map +1 -0
- package/dist/jsx/graphLayout/GraphViewport.mjs +238 -0
- package/dist/jsx/graphLayout/GraphViewport.mjs.map +1 -0
- package/dist/jsx/graphLayout/GraphViewport.native.js +279 -0
- package/dist/jsx/graphLayout/GraphViewport.native.js.map +1 -0
- package/dist/jsx/graphLayout/index.mjs +7 -0
- package/dist/jsx/graphLayout/index.mjs.map +1 -0
- package/dist/jsx/graphLayout/index.native.js +54 -0
- package/dist/jsx/graphLayout/index.native.js.map +1 -0
- package/dist/jsx/graphLayout/ogden.fixture.mjs +4 -0
- package/dist/jsx/graphLayout/ogden.fixture.mjs.map +1 -0
- package/dist/jsx/graphLayout/ogden.fixture.native.js +33 -0
- package/dist/jsx/graphLayout/ogden.fixture.native.js.map +1 -0
- package/dist/jsx/graphLayout/plan.mjs +235 -0
- package/dist/jsx/graphLayout/plan.mjs.map +1 -0
- package/dist/jsx/graphLayout/plan.native.js +372 -0
- package/dist/jsx/graphLayout/plan.native.js.map +1 -0
- package/dist/jsx/graphLayout/viewMath.mjs +105 -0
- package/dist/jsx/graphLayout/viewMath.mjs.map +1 -0
- package/dist/jsx/graphLayout/viewMath.native.js +147 -0
- package/dist/jsx/graphLayout/viewMath.native.js.map +1 -0
- package/graph-layout.ts +1 -0
- package/package.json +21 -6
- package/src/graphLayout/GraphDots.tsx +32 -0
- package/src/graphLayout/GraphLayout.stories.tsx +86 -0
- package/src/graphLayout/GraphLayout.tsx +152 -0
- package/src/graphLayout/GraphSvg.native.tsx +31 -0
- package/src/graphLayout/GraphSvg.tsx +45 -0
- package/src/graphLayout/GraphViewport.native.tsx +231 -0
- package/src/graphLayout/GraphViewport.tsx +246 -0
- package/src/graphLayout/index.ts +31 -0
- package/src/graphLayout/ogden.fixture.ts +120 -0
- package/src/graphLayout/plan.spec.ts +202 -0
- package/src/graphLayout/plan.ts +223 -0
- package/src/graphLayout/purity.spec.ts +67 -0
- package/src/graphLayout/viewMath.spec.ts +185 -0
- package/src/graphLayout/viewMath.ts +151 -0
- package/types/graphLayout/GraphDots.d.ts +9 -0
- package/types/graphLayout/GraphDots.d.ts.map +1 -0
- package/types/graphLayout/GraphLayout.d.ts +22 -0
- package/types/graphLayout/GraphLayout.d.ts.map +1 -0
- package/types/graphLayout/GraphSvg.d.ts +17 -0
- package/types/graphLayout/GraphSvg.d.ts.map +1 -0
- package/types/graphLayout/GraphSvg.native.d.ts +5 -0
- package/types/graphLayout/GraphSvg.native.d.ts.map +1 -0
- package/types/graphLayout/GraphViewport.d.ts +11 -0
- package/types/graphLayout/GraphViewport.d.ts.map +1 -0
- package/types/graphLayout/GraphViewport.native.d.ts +4 -0
- package/types/graphLayout/GraphViewport.native.d.ts.map +1 -0
- package/types/graphLayout/index.d.ts +11 -0
- package/types/graphLayout/index.d.ts.map +1 -0
- package/types/graphLayout/ogden.fixture.d.ts +3 -0
- package/types/graphLayout/ogden.fixture.d.ts.map +1 -0
- package/types/graphLayout/plan.d.ts +52 -0
- package/types/graphLayout/plan.d.ts.map +1 -0
- package/types/graphLayout/viewMath.d.ts +47 -0
- package/types/graphLayout/viewMath.d.ts.map +1 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import type { EdgeObstacle } from "../edges/edgeRoute";
|
|
2
|
+
import { edgeClearance } from "../edges/edgeRoute";
|
|
3
|
+
import { buildEdgePath } from "../edges/edgePath";
|
|
4
|
+
import type { PathGeometry } from "../edges/edgePath";
|
|
5
|
+
import { resolveEdgeStyle } from "../edges/edgeStyle";
|
|
6
|
+
import { layoutWithDagre } from "../layout/dagre";
|
|
7
|
+
import type { XY } from "../model/document";
|
|
8
|
+
import { Position } from "../react-flow/xyPaths";
|
|
9
|
+
|
|
10
|
+
export type GraphDirection = "LR" | "TB";
|
|
11
|
+
|
|
12
|
+
export interface GraphLayoutNode {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly width: number;
|
|
15
|
+
readonly height: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface GraphLayoutEdge {
|
|
19
|
+
readonly id?: string;
|
|
20
|
+
readonly source: string;
|
|
21
|
+
readonly target: string;
|
|
22
|
+
readonly kind?: string;
|
|
23
|
+
readonly emphasis?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface GraphPlanInput {
|
|
27
|
+
readonly nodes: readonly GraphLayoutNode[];
|
|
28
|
+
readonly edges: readonly GraphLayoutEdge[];
|
|
29
|
+
readonly direction: GraphDirection;
|
|
30
|
+
readonly nodeSpacing: number;
|
|
31
|
+
readonly rankSpacing: number;
|
|
32
|
+
readonly margin: number;
|
|
33
|
+
readonly strokeWidth: number;
|
|
34
|
+
readonly wrapWidth?: number;
|
|
35
|
+
readonly positions?: Readonly<Record<string, XY>>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface PlannedNode extends GraphLayoutNode {
|
|
39
|
+
readonly x: number;
|
|
40
|
+
readonly y: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface PlannedEdge {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly source: string;
|
|
46
|
+
readonly target: string;
|
|
47
|
+
readonly d: string;
|
|
48
|
+
readonly head: string;
|
|
49
|
+
readonly tip: XY;
|
|
50
|
+
readonly stroke: string;
|
|
51
|
+
readonly dash?: string;
|
|
52
|
+
readonly emphasis: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface GraphPlan {
|
|
56
|
+
readonly width: number;
|
|
57
|
+
readonly height: number;
|
|
58
|
+
readonly nodes: readonly PlannedNode[];
|
|
59
|
+
readonly edges: readonly PlannedEdge[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const sides: Record<GraphDirection, { readonly out: Position; readonly in: Position }> = {
|
|
63
|
+
LR: { out: Position.Right, in: Position.Left },
|
|
64
|
+
TB: { out: Position.Bottom, in: Position.Top },
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const inward: Record<Position, XY> = {
|
|
68
|
+
[Position.Left]: { x: 1, y: 0 },
|
|
69
|
+
[Position.Right]: { x: -1, y: 0 },
|
|
70
|
+
[Position.Top]: { x: 0, y: 1 },
|
|
71
|
+
[Position.Bottom]: { x: 0, y: -1 },
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export function graphEdgeId(edge: GraphLayoutEdge): string {
|
|
75
|
+
return edge.id ?? `${edge.source}\n${edge.target}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function usableEdges(
|
|
79
|
+
nodes: readonly GraphLayoutNode[],
|
|
80
|
+
edges: readonly GraphLayoutEdge[],
|
|
81
|
+
): GraphLayoutEdge[] {
|
|
82
|
+
const known = new Set(nodes.map((node) => node.id));
|
|
83
|
+
const seen = new Set<string>();
|
|
84
|
+
const kept: GraphLayoutEdge[] = [];
|
|
85
|
+
for (const edge of edges) {
|
|
86
|
+
if (edge.source === edge.target || !known.has(edge.source) || !known.has(edge.target)) continue;
|
|
87
|
+
const id = graphEdgeId(edge);
|
|
88
|
+
if (seen.has(id)) continue;
|
|
89
|
+
seen.add(id);
|
|
90
|
+
kept.push(edge);
|
|
91
|
+
}
|
|
92
|
+
return kept;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function placeNodes(input: GraphPlanInput, edges: readonly GraphLayoutEdge[]): Map<string, XY> {
|
|
96
|
+
const placed = new Map<string, XY>();
|
|
97
|
+
if (input.positions) {
|
|
98
|
+
for (const node of input.nodes) placed.set(node.id, input.positions[node.id] ?? { x: 0, y: 0 });
|
|
99
|
+
return placed;
|
|
100
|
+
}
|
|
101
|
+
const linked = new Set(edges.flatMap((edge) => [edge.source, edge.target]));
|
|
102
|
+
const graphNodes = input.nodes.filter((node) => linked.has(node.id));
|
|
103
|
+
const isolated = input.nodes.filter((node) => !linked.has(node.id));
|
|
104
|
+
let dagWidth = 0;
|
|
105
|
+
let dagHeight = 0;
|
|
106
|
+
if (graphNodes.length > 0) {
|
|
107
|
+
const result = layoutWithDagre({
|
|
108
|
+
nodes: graphNodes.map((node) => ({ ...node, position: { x: 0, y: 0 } })),
|
|
109
|
+
edges: edges.map((edge) => ({
|
|
110
|
+
id: graphEdgeId(edge),
|
|
111
|
+
source: edge.source,
|
|
112
|
+
target: edge.target,
|
|
113
|
+
})),
|
|
114
|
+
options: {
|
|
115
|
+
direction: input.direction,
|
|
116
|
+
nodeSpacing: input.nodeSpacing,
|
|
117
|
+
rankSpacing: input.rankSpacing,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
for (const node of graphNodes) {
|
|
121
|
+
const at = result.positions[node.id] ?? { x: 0, y: 0 };
|
|
122
|
+
placed.set(node.id, at);
|
|
123
|
+
dagWidth = Math.max(dagWidth, at.x + node.width);
|
|
124
|
+
dagHeight = Math.max(dagHeight, at.y + node.height);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const wrap = Math.max(dagWidth, input.wrapWidth ?? 0, ...isolated.map((node) => node.width));
|
|
128
|
+
let x = 0;
|
|
129
|
+
let y = graphNodes.length > 0 ? dagHeight + input.rankSpacing : 0;
|
|
130
|
+
let rowHeight = 0;
|
|
131
|
+
for (const node of isolated) {
|
|
132
|
+
if (x > 0 && x + node.width > wrap) {
|
|
133
|
+
x = 0;
|
|
134
|
+
y += rowHeight + input.nodeSpacing;
|
|
135
|
+
rowHeight = 0;
|
|
136
|
+
}
|
|
137
|
+
placed.set(node.id, { x, y });
|
|
138
|
+
x += node.width + input.nodeSpacing;
|
|
139
|
+
rowHeight = Math.max(rowHeight, node.height);
|
|
140
|
+
}
|
|
141
|
+
return placed;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function anchor(node: PlannedNode, side: Position): XY {
|
|
145
|
+
switch (side) {
|
|
146
|
+
case Position.Left:
|
|
147
|
+
return { x: node.x, y: node.y + node.height / 2 };
|
|
148
|
+
case Position.Right:
|
|
149
|
+
return { x: node.x + node.width, y: node.y + node.height / 2 };
|
|
150
|
+
case Position.Top:
|
|
151
|
+
return { x: node.x + node.width / 2, y: node.y };
|
|
152
|
+
default:
|
|
153
|
+
return { x: node.x + node.width / 2, y: node.y + node.height };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function round(value: number): number {
|
|
158
|
+
return Math.round(value * 100) / 100;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function arrowHead(tip: XY, side: Position, strokeWidth: number): string {
|
|
162
|
+
const into = inward[side];
|
|
163
|
+
const length = strokeWidth * 4;
|
|
164
|
+
const half = (strokeWidth * 3) / 2;
|
|
165
|
+
const base = { x: tip.x - into.x * length, y: tip.y - into.y * length };
|
|
166
|
+
const across = { x: -into.y, y: into.x };
|
|
167
|
+
const a = { x: base.x + across.x * half, y: base.y + across.y * half };
|
|
168
|
+
const b = { x: base.x - across.x * half, y: base.y - across.y * half };
|
|
169
|
+
return `M ${round(tip.x)} ${round(tip.y)} L ${round(a.x)} ${round(a.y)} L ${round(b.x)} ${round(b.y)} Z`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function planGraphLayout(input: GraphPlanInput): GraphPlan {
|
|
173
|
+
const edges = usableEdges(input.nodes, input.edges);
|
|
174
|
+
const placed = placeNodes(input, edges);
|
|
175
|
+
const { margin } = input;
|
|
176
|
+
const nodes: PlannedNode[] = input.nodes.map((node) => {
|
|
177
|
+
const at = placed.get(node.id) ?? { x: 0, y: 0 };
|
|
178
|
+
return { ...node, x: round(at.x + margin), y: round(at.y + margin) };
|
|
179
|
+
});
|
|
180
|
+
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
181
|
+
const boxes: EdgeObstacle[] = nodes.map((node) => ({
|
|
182
|
+
id: node.id,
|
|
183
|
+
x: node.x,
|
|
184
|
+
y: node.y,
|
|
185
|
+
width: node.width,
|
|
186
|
+
height: node.height,
|
|
187
|
+
}));
|
|
188
|
+
const side = sides[input.direction];
|
|
189
|
+
const planned: PlannedEdge[] = edges.map((edge) => {
|
|
190
|
+
const source = byId.get(edge.source)!;
|
|
191
|
+
const target = byId.get(edge.target)!;
|
|
192
|
+
const from = anchor(source, side.out);
|
|
193
|
+
const tip = anchor(target, side.in);
|
|
194
|
+
const style = resolveEdgeStyle({
|
|
195
|
+
kind: edge.kind ?? "flow",
|
|
196
|
+
borderWidth: "small",
|
|
197
|
+
animation: "none",
|
|
198
|
+
});
|
|
199
|
+
const geometry: PathGeometry = {
|
|
200
|
+
sourceX: from.x,
|
|
201
|
+
sourceY: from.y,
|
|
202
|
+
targetX: tip.x,
|
|
203
|
+
targetY: tip.y,
|
|
204
|
+
sourcePosition: side.out,
|
|
205
|
+
targetPosition: side.in,
|
|
206
|
+
};
|
|
207
|
+
const [d] = buildEdgePath(style.path, geometry, { boxes, clearance: edgeClearance });
|
|
208
|
+
return {
|
|
209
|
+
id: graphEdgeId(edge),
|
|
210
|
+
source: edge.source,
|
|
211
|
+
target: edge.target,
|
|
212
|
+
d,
|
|
213
|
+
head: arrowHead(tip, side.in, input.strokeWidth * (edge.emphasis ? 2 : 1)),
|
|
214
|
+
tip,
|
|
215
|
+
stroke: edge.emphasis ? "$accentColor" : style.stroke,
|
|
216
|
+
...(style.strokeDasharray ? { dash: style.strokeDasharray } : {}),
|
|
217
|
+
emphasis: edge.emphasis ?? false,
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
const width = nodes.reduce((most, node) => Math.max(most, node.x + node.width), 0) + margin;
|
|
221
|
+
const height = nodes.reduce((most, node) => Math.max(most, node.y + node.height), 0) + margin;
|
|
222
|
+
return { width: round(width), height: round(height), nodes, edges: planned };
|
|
223
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const src = path.resolve(here, "..");
|
|
8
|
+
const candidates = [".ts", ".tsx", ".native.ts", ".native.tsx", "/index.ts", "/index.native.ts"];
|
|
9
|
+
|
|
10
|
+
function resolveLocal(from: string, specifier: string): string[] {
|
|
11
|
+
const base = path.resolve(path.dirname(from), specifier);
|
|
12
|
+
return candidates.map((suffix) => base + suffix).filter((file) => existsSync(file));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function walk(): { files: Set<string>; packages: Set<string> } {
|
|
16
|
+
const files = new Set<string>();
|
|
17
|
+
const packages = new Set<string>();
|
|
18
|
+
const queue = readdirSync(here)
|
|
19
|
+
.filter(
|
|
20
|
+
(name) => /\.tsx?$/.test(name) && !name.includes(".spec.") && !name.includes(".fixture."),
|
|
21
|
+
)
|
|
22
|
+
.map((name) => path.join(here, name));
|
|
23
|
+
while (queue.length > 0) {
|
|
24
|
+
const file = queue.pop()!;
|
|
25
|
+
if (files.has(file)) continue;
|
|
26
|
+
files.add(file);
|
|
27
|
+
const text = readFileSync(file, "utf8");
|
|
28
|
+
for (const match of text.matchAll(/(?:from|import)\s*\(?\s*"([^"]+)"/g)) {
|
|
29
|
+
const specifier = match[1]!;
|
|
30
|
+
if (specifier.startsWith(".")) queue.push(...resolveLocal(file, specifier));
|
|
31
|
+
else packages.add(specifier);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { files, packages };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe("the graph-layout entry's import graph (FZ-8149, LC-294)", () => {
|
|
38
|
+
const { files, packages } = walk();
|
|
39
|
+
const relative = [...files].map((file) => path.relative(src, file)).sort();
|
|
40
|
+
|
|
41
|
+
it("never reaches React Flow's React runtime, its store or the webview", () => {
|
|
42
|
+
expect(
|
|
43
|
+
[...packages].filter(
|
|
44
|
+
(name) => name === "@xyflow/react" || name.startsWith("react-native-webview"),
|
|
45
|
+
),
|
|
46
|
+
).toEqual([]);
|
|
47
|
+
expect(
|
|
48
|
+
relative.filter(
|
|
49
|
+
(file) =>
|
|
50
|
+
file === "react-flow/xy.ts" ||
|
|
51
|
+
file.startsWith("dom/") ||
|
|
52
|
+
file.includes("useEdgeObstacles"),
|
|
53
|
+
),
|
|
54
|
+
).toEqual([]);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("draws through NodeGraph's own layout engine and edge path, so there is one of each", () => {
|
|
58
|
+
for (const shared of [
|
|
59
|
+
"layout/dagre.ts",
|
|
60
|
+
"edges/edgePath.ts",
|
|
61
|
+
"edges/edgeRoute.ts",
|
|
62
|
+
"edges/edgeStyle.ts",
|
|
63
|
+
]) {
|
|
64
|
+
expect(relative).toContain(shared);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
clampOffset,
|
|
4
|
+
clampView,
|
|
5
|
+
dotPhase,
|
|
6
|
+
dotPitch,
|
|
7
|
+
graphZoom,
|
|
8
|
+
keyedView,
|
|
9
|
+
leastScale,
|
|
10
|
+
toggledView,
|
|
11
|
+
zoomAt,
|
|
12
|
+
dotArea,
|
|
13
|
+
dotPath,
|
|
14
|
+
} from "./viewMath";
|
|
15
|
+
|
|
16
|
+
const viewport = { width: 390, height: 700 };
|
|
17
|
+
const tall = { width: 830, height: 4300 };
|
|
18
|
+
|
|
19
|
+
describe("the graph's zoom (FZ-8449)", () => {
|
|
20
|
+
it("zooms out no further than the whole graph on screen, and never in past 1:1", () => {
|
|
21
|
+
const least = leastScale(tall, viewport);
|
|
22
|
+
expect(least).toBeCloseTo(Math.min(390 / 830, 700 / 4300));
|
|
23
|
+
expect(tall.width * least).toBeLessThanOrEqual(viewport.width + 1e-6);
|
|
24
|
+
expect(tall.height * least).toBeLessThanOrEqual(viewport.height + 1e-6);
|
|
25
|
+
expect(leastScale({ width: 300, height: 600 }, viewport)).toBe(1);
|
|
26
|
+
expect(leastScale({ width: 400, height: 100_000 }, viewport)).toBe(graphZoom.floor);
|
|
27
|
+
const view = { scale: 1, x: 0, y: 0 };
|
|
28
|
+
expect(zoomAt(view, 0.01, { x: 0, y: 0 }, tall, viewport).scale).toBeCloseTo(least);
|
|
29
|
+
expect(zoomAt(view, 3, { x: 0, y: 0 }, tall, viewport).scale).toBe(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("keeps the point under the fingers where it is", () => {
|
|
33
|
+
const view = { scale: 1, x: -200, y: -1500 };
|
|
34
|
+
const focal = { x: 180, y: 320 };
|
|
35
|
+
const next = zoomAt(view, 0.5, focal, tall, viewport);
|
|
36
|
+
const before = { x: (focal.x - view.x) / view.scale, y: (focal.y - view.y) / view.scale };
|
|
37
|
+
const after = { x: (focal.x - next.x) / next.scale, y: (focal.y - next.y) / next.scale };
|
|
38
|
+
expect(after.x).toBeCloseTo(before.x);
|
|
39
|
+
expect(after.y).toBeCloseTo(before.y);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it.each([1, 0.6, 0.3, 0.17])(
|
|
43
|
+
"stops a pan at the outermost apps at scale %s, never past them into empty space",
|
|
44
|
+
(scale) => {
|
|
45
|
+
for (const [x, y] of [
|
|
46
|
+
[10_000, 10_000],
|
|
47
|
+
[-10_000, -10_000],
|
|
48
|
+
[-123, -456],
|
|
49
|
+
]) {
|
|
50
|
+
const view = clampView({ scale, x, y }, tall, viewport);
|
|
51
|
+
const wide = tall.width * view.scale;
|
|
52
|
+
const high = tall.height * view.scale;
|
|
53
|
+
if (wide > viewport.width) {
|
|
54
|
+
expect(view.x).toBeLessThanOrEqual(0);
|
|
55
|
+
expect(view.x + wide).toBeGreaterThanOrEqual(viewport.width);
|
|
56
|
+
} else expect(view.x).toBeCloseTo((viewport.width - wide) / 2);
|
|
57
|
+
if (high > viewport.height) {
|
|
58
|
+
expect(view.y).toBeLessThanOrEqual(0);
|
|
59
|
+
expect(view.y + high).toBeGreaterThanOrEqual(viewport.height);
|
|
60
|
+
} else expect(view.y).toBeCloseTo((viewport.height - high) / 2);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
it("centres a graph smaller than the screen on that axis", () => {
|
|
66
|
+
expect(clampOffset(-50, 200, 390)).toBe(95);
|
|
67
|
+
expect(clampOffset(50, 800, 390)).toBe(0);
|
|
68
|
+
expect(clampOffset(-900, 800, 390)).toBe(-410);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("double-tap from 1:1 shows the whole graph, and from anywhere zoomed out comes back to 1:1 at the tap", () => {
|
|
72
|
+
const out = toggledView({ scale: 1, x: 0, y: -900 }, { x: 100, y: 100 }, tall, viewport);
|
|
73
|
+
expect(out.scale).toBeCloseTo(leastScale(tall, viewport));
|
|
74
|
+
const tap = { x: 120, y: 400 };
|
|
75
|
+
const back = toggledView({ scale: 0.4, x: 10, y: -300 }, tap, tall, viewport);
|
|
76
|
+
expect(back.scale).toBe(1);
|
|
77
|
+
const under = { x: (tap.x - 10) / 0.4, y: (tap.y + 300) / 0.4 };
|
|
78
|
+
expect(back.x).toBeCloseTo(Math.min(0, Math.max(viewport.width - tall.width, tap.x - under.x)));
|
|
79
|
+
expect(back.y).toBeCloseTo(
|
|
80
|
+
Math.min(0, Math.max(viewport.height - tall.height, tap.y - under.y)),
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("zooms with + and - on a keyboard and comes back to 1:1 on 0", () => {
|
|
85
|
+
const start = { scale: 1, x: 0, y: 0 };
|
|
86
|
+
const out = keyedView("-", start, tall, viewport)!;
|
|
87
|
+
expect(out.scale).toBeCloseTo(1 / graphZoom.step);
|
|
88
|
+
expect(keyedView("+", out, tall, viewport)!.scale).toBeCloseTo(1);
|
|
89
|
+
expect(keyedView("+", start, tall, viewport)!.scale).toBe(1);
|
|
90
|
+
expect(keyedView("0", { scale: 0.3, x: 0, y: 0 }, tall, viewport)!.scale).toBe(1);
|
|
91
|
+
expect(keyedView("a", start, tall, viewport)).toBeUndefined();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("thins the dot grid as it zooms out, so dots stay apart on screen", () => {
|
|
95
|
+
const pitch = 22;
|
|
96
|
+
for (const scale of [1, 0.8, 0.5, 0.3, 0.17, 0.1]) {
|
|
97
|
+
const spaced = dotPitch(pitch, scale);
|
|
98
|
+
expect(spaced * scale).toBeGreaterThanOrEqual(pitch / 2);
|
|
99
|
+
expect(spaced * scale).toBeLessThanOrEqual(pitch);
|
|
100
|
+
expect(Math.log2(spaced / pitch) % 1).toBe(0);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("puts the first dot on the canvas's own grid, one step at most before the screen's edge", () => {
|
|
105
|
+
const pitch = 22;
|
|
106
|
+
for (const [offset, scale] of [
|
|
107
|
+
[0, 1],
|
|
108
|
+
[-345.5, 1],
|
|
109
|
+
[-1200, 0.4],
|
|
110
|
+
[37, 0.2],
|
|
111
|
+
]) {
|
|
112
|
+
const spaced = dotPitch(pitch, scale);
|
|
113
|
+
const phase = dotPhase(offset, scale, pitch, spaced);
|
|
114
|
+
expect(phase).toBeLessThan(1e-9);
|
|
115
|
+
expect(phase).toBeGreaterThanOrEqual(-spaced * scale - 1e-9);
|
|
116
|
+
const content = (phase - offset) / scale - pitch / 2;
|
|
117
|
+
expect(Math.abs(content / spaced - Math.round(content / spaced))).toBeLessThan(1e-6);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const canvas = { width: 900, height: 5000 };
|
|
123
|
+
const pitch = 22;
|
|
124
|
+
const chunk = pitch * 4;
|
|
125
|
+
|
|
126
|
+
const dots = (path: string) =>
|
|
127
|
+
[...path.matchAll(/M([-\d.]+) ([-\d.]+)h0\.01/g)].map((match) => ({
|
|
128
|
+
x: Number(match[1]),
|
|
129
|
+
y: Number(match[2]),
|
|
130
|
+
}));
|
|
131
|
+
|
|
132
|
+
describe("the graph's dot grid (FZ-8138)", () => {
|
|
133
|
+
it.each([
|
|
134
|
+
{ x: 0, y: 0 },
|
|
135
|
+
{ x: 130, y: 2400 },
|
|
136
|
+
{ x: canvas.width - viewport.width, y: canvas.height - viewport.height },
|
|
137
|
+
])("covers the screen and a margin round it wherever the canvas is panned to (%o)", (offset) => {
|
|
138
|
+
const area = dotArea(offset, viewport, canvas, chunk);
|
|
139
|
+
expect(area.x).toBeLessThanOrEqual(Math.max(0, offset.x - chunk / 2));
|
|
140
|
+
expect(area.y).toBeLessThanOrEqual(Math.max(0, offset.y - chunk / 2));
|
|
141
|
+
expect(area.x + area.width).toBeGreaterThanOrEqual(
|
|
142
|
+
Math.min(canvas.width, offset.x + viewport.width + chunk),
|
|
143
|
+
);
|
|
144
|
+
expect(area.y + area.height).toBeGreaterThanOrEqual(
|
|
145
|
+
Math.min(canvas.height, offset.y + viewport.height + chunk),
|
|
146
|
+
);
|
|
147
|
+
expect(area.x + area.width).toBeLessThanOrEqual(canvas.width);
|
|
148
|
+
expect(area.y + area.height).toBeLessThanOrEqual(canvas.height);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("keeps the same area for small pans, so a scroll does not redraw it every frame", () => {
|
|
152
|
+
const first = dotArea({ x: 0, y: 1000 }, viewport, canvas, chunk);
|
|
153
|
+
const areas = new Set<string>();
|
|
154
|
+
for (let y = 1000; y < 1000 + chunk / 2; y += 3)
|
|
155
|
+
areas.add(JSON.stringify(dotArea({ x: 0, y }, viewport, canvas, chunk)));
|
|
156
|
+
expect(areas.size).toBeLessThanOrEqual(2);
|
|
157
|
+
expect(areas.has(JSON.stringify(first))).toBe(true);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("puts every dot on the canvas's own grid, so dots line up as the area moves", () => {
|
|
161
|
+
for (const offset of [
|
|
162
|
+
{ x: 0, y: 0 },
|
|
163
|
+
{ x: 200, y: 1300 },
|
|
164
|
+
]) {
|
|
165
|
+
const area = dotArea(offset, viewport, canvas, chunk);
|
|
166
|
+
const placed = dots(dotPath(area, pitch));
|
|
167
|
+
expect(placed.length).toBeGreaterThan(100);
|
|
168
|
+
for (const dot of placed) {
|
|
169
|
+
const x = area.x + dot.x - pitch / 2;
|
|
170
|
+
const y = area.y + dot.y - pitch / 2;
|
|
171
|
+
expect(Math.abs(x / pitch - Math.round(x / pitch))).toBeLessThan(1e-6);
|
|
172
|
+
expect(Math.abs(y / pitch - Math.round(y / pitch))).toBeLessThan(1e-6);
|
|
173
|
+
expect(dot.x).toBeGreaterThanOrEqual(0);
|
|
174
|
+
expect(dot.y).toBeGreaterThanOrEqual(0);
|
|
175
|
+
expect(dot.x).toBeLessThan(area.width);
|
|
176
|
+
expect(dot.y).toBeLessThan(area.height);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("draws dots only, no lines", () => {
|
|
182
|
+
const path = dotPath({ x: 0, y: 0, width: 200, height: 200 }, pitch);
|
|
183
|
+
expect(path.replace(/M[-\d.]+ [-\d.]+h0\.01/g, "")).toBe("");
|
|
184
|
+
});
|
|
185
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export interface Extent {
|
|
2
|
+
readonly width: number;
|
|
3
|
+
readonly height: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface GraphView {
|
|
7
|
+
readonly scale: number;
|
|
8
|
+
readonly x: number;
|
|
9
|
+
readonly y: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DotArea {
|
|
13
|
+
readonly x: number;
|
|
14
|
+
readonly y: number;
|
|
15
|
+
readonly width: number;
|
|
16
|
+
readonly height: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface GraphDots {
|
|
20
|
+
readonly pitch: number;
|
|
21
|
+
readonly dot: number;
|
|
22
|
+
readonly color: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const graphZoom = {
|
|
26
|
+
floor: 0.1,
|
|
27
|
+
step: 1.25,
|
|
28
|
+
settleMs: 220,
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
export function leastScale(content: Extent, viewport: Extent): number {
|
|
32
|
+
"worklet";
|
|
33
|
+
if (content.width <= 0 || content.height <= 0 || viewport.width <= 0 || viewport.height <= 0)
|
|
34
|
+
return 1;
|
|
35
|
+
const fit = Math.min(viewport.width / content.width, viewport.height / content.height);
|
|
36
|
+
return Math.min(1, Math.max(graphZoom.floor, fit));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function clampOffset(offset: number, content: number, viewport: number): number {
|
|
40
|
+
"worklet";
|
|
41
|
+
if (content <= viewport) return (viewport - content) / 2;
|
|
42
|
+
return Math.min(0, Math.max(viewport - content, offset));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function clampView(view: GraphView, content: Extent, viewport: Extent): GraphView {
|
|
46
|
+
"worklet";
|
|
47
|
+
const scale = Math.min(1, Math.max(leastScale(content, viewport), view.scale));
|
|
48
|
+
return {
|
|
49
|
+
scale,
|
|
50
|
+
x: clampOffset(view.x, content.width * scale, viewport.width),
|
|
51
|
+
y: clampOffset(view.y, content.height * scale, viewport.height),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function zoomAt(
|
|
56
|
+
view: GraphView,
|
|
57
|
+
scale: number,
|
|
58
|
+
focal: { readonly x: number; readonly y: number },
|
|
59
|
+
content: Extent,
|
|
60
|
+
viewport: Extent,
|
|
61
|
+
): GraphView {
|
|
62
|
+
"worklet";
|
|
63
|
+
const next = Math.min(1, Math.max(leastScale(content, viewport), scale));
|
|
64
|
+
const ratio = next / view.scale;
|
|
65
|
+
return clampView(
|
|
66
|
+
{
|
|
67
|
+
scale: next,
|
|
68
|
+
x: focal.x - (focal.x - view.x) * ratio,
|
|
69
|
+
y: focal.y - (focal.y - view.y) * ratio,
|
|
70
|
+
},
|
|
71
|
+
content,
|
|
72
|
+
viewport,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function fittedView(content: Extent, viewport: Extent): GraphView {
|
|
77
|
+
"worklet";
|
|
78
|
+
return clampView({ scale: leastScale(content, viewport), x: 0, y: 0 }, content, viewport);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function toggledView(
|
|
82
|
+
view: GraphView,
|
|
83
|
+
at: { readonly x: number; readonly y: number },
|
|
84
|
+
content: Extent,
|
|
85
|
+
viewport: Extent,
|
|
86
|
+
): GraphView {
|
|
87
|
+
"worklet";
|
|
88
|
+
const least = leastScale(content, viewport);
|
|
89
|
+
return view.scale < 1 - 1e-3
|
|
90
|
+
? zoomAt(view, 1, at, content, viewport)
|
|
91
|
+
: zoomAt(view, least, at, content, viewport);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function keyedView(
|
|
95
|
+
key: string,
|
|
96
|
+
view: GraphView,
|
|
97
|
+
content: Extent,
|
|
98
|
+
viewport: Extent,
|
|
99
|
+
): GraphView | undefined {
|
|
100
|
+
const centre = { x: viewport.width / 2, y: viewport.height / 2 };
|
|
101
|
+
if (key === "+" || key === "=")
|
|
102
|
+
return zoomAt(view, view.scale * graphZoom.step, centre, content, viewport);
|
|
103
|
+
if (key === "-" || key === "_")
|
|
104
|
+
return zoomAt(view, view.scale / graphZoom.step, centre, content, viewport);
|
|
105
|
+
if (key === "0") return zoomAt(view, 1, centre, content, viewport);
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function dotPitch(pitch: number, scale: number): number {
|
|
110
|
+
"worklet";
|
|
111
|
+
let spaced = pitch;
|
|
112
|
+
while (spaced * scale < pitch / 2) spaced *= 2;
|
|
113
|
+
return spaced;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function dotPhase(offset: number, scale: number, pitch: number, spaced: number): number {
|
|
117
|
+
"worklet";
|
|
118
|
+
const step = spaced * scale;
|
|
119
|
+
const start = offset + (pitch / 2) * scale;
|
|
120
|
+
return (((start % step) + step) % step) - step;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function reachOf(offset: number, view: number, total: number, chunk: number): [number, number] {
|
|
124
|
+
const start = Math.max(0, Math.floor(offset / chunk) * chunk - chunk);
|
|
125
|
+
return [start, Math.max(0, Math.min(view + chunk * 3, total - start))];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function dotArea(
|
|
129
|
+
offset: { readonly x: number; readonly y: number },
|
|
130
|
+
viewport: Extent,
|
|
131
|
+
canvas: Extent,
|
|
132
|
+
chunk: number,
|
|
133
|
+
): DotArea {
|
|
134
|
+
const [x, width] = reachOf(offset.x, viewport.width, canvas.width, chunk);
|
|
135
|
+
const [y, height] = reachOf(offset.y, viewport.height, canvas.height, chunk);
|
|
136
|
+
return { x, y, width, height };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function dotPath(area: DotArea, pitch: number): string {
|
|
140
|
+
const runs: string[] = [];
|
|
141
|
+
const first = (start: number) =>
|
|
142
|
+
Math.ceil((start - pitch / 2) / pitch) * pitch + pitch / 2 - start;
|
|
143
|
+
for (let y = first(area.y); y < area.height; y += pitch) {
|
|
144
|
+
for (let x = first(area.x); x < area.width; x += pitch) runs.push(`M${x} ${y}h0.01`);
|
|
145
|
+
}
|
|
146
|
+
return runs.join("");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function sameArea(a: DotArea, b: DotArea): boolean {
|
|
150
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
151
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DotArea } from "./viewMath";
|
|
2
|
+
export interface GraphDotsProps {
|
|
3
|
+
readonly area: DotArea;
|
|
4
|
+
readonly pitch: number;
|
|
5
|
+
readonly dot: number;
|
|
6
|
+
readonly color: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function GraphDots({ area, pitch, dot, color }: GraphDotsProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=GraphDots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphDots.d.ts","sourceRoot":"","sources":["../../src/graphLayout/GraphDots.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,cAAc,2CAkBpE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { XY } from "../model/document";
|
|
3
|
+
import type { GraphDirection, GraphLayoutEdge, GraphLayoutNode } from "./plan";
|
|
4
|
+
import type { Extent } from "./viewMath";
|
|
5
|
+
export type GraphSpaceToken = `$${number}`;
|
|
6
|
+
export interface GraphLayoutProps {
|
|
7
|
+
readonly nodes: readonly GraphLayoutNode[];
|
|
8
|
+
readonly edges: readonly GraphLayoutEdge[];
|
|
9
|
+
readonly renderNode: (id: string) => ReactNode;
|
|
10
|
+
readonly direction?: GraphDirection | "auto";
|
|
11
|
+
readonly positions?: Readonly<Record<string, XY>>;
|
|
12
|
+
readonly spacing?: {
|
|
13
|
+
readonly node?: GraphSpaceToken;
|
|
14
|
+
readonly rank?: GraphSpaceToken;
|
|
15
|
+
};
|
|
16
|
+
readonly dots?: boolean;
|
|
17
|
+
readonly frozen?: boolean;
|
|
18
|
+
readonly testID?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function resolveGraphDirection(direction: GraphDirection | "auto", viewport: Extent): GraphDirection;
|
|
21
|
+
export declare function GraphLayout({ nodes, edges, renderNode, direction, positions, spacing, dots, frozen, testID, }: GraphLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
//# sourceMappingURL=GraphLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphLayout.d.ts","sourceRoot":"","sources":["../../src/graphLayout/GraphLayout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAI5C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,eAAe,GAAG,IAAI,MAAM,EAAE,CAAC;AAE3C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,SAAS,CAAC;IAC/C,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,CAAA;KAAE,CAAC;IACxF,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,cAAc,GAAG,MAAM,EAClC,QAAQ,EAAE,MAAM,GACf,cAAc,CAGhB;AAqBD,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,UAAU,EACV,SAAkB,EAClB,SAAS,EACT,OAAO,EACP,IAAW,EACX,MAAM,EACN,MAAuB,GACxB,EAAE,gBAAgB,2CAuFlB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface GraphSvgProps {
|
|
3
|
+
readonly width: number;
|
|
4
|
+
readonly height: number;
|
|
5
|
+
readonly children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface GraphPathProps {
|
|
8
|
+
readonly d: string;
|
|
9
|
+
readonly stroke?: string;
|
|
10
|
+
readonly strokeWidth?: number;
|
|
11
|
+
readonly dash?: string;
|
|
12
|
+
readonly fill?: string;
|
|
13
|
+
readonly round?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function GraphSvg({ width, height, children }: GraphSvgProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function GraphPath({ d, stroke, strokeWidth, dash, fill, round }: GraphPathProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=GraphSvg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphSvg.d.ts","sourceRoot":"","sources":["../../src/graphLayout/GraphSvg.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,aAAa,2CAWlE;AAED,wBAAgB,SAAS,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,cAAc,2CActF"}
|