@statelyai/graph 2.0.0 → 2.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.
Files changed (73) hide show
  1. package/README.md +67 -19
  2. package/dist/{algorithms-CsGNehct.d.mts → algorithms-D1cgly0g.d.mts} +145 -6
  3. package/dist/{algorithms-DF1pSQGv.mjs → algorithms-DBpH74hR.mjs} +673 -891
  4. package/dist/algorithms.d.mts +2 -2
  5. package/dist/algorithms.mjs +2 -2
  6. package/dist/config-Dt5u1gSf.mjs +793 -0
  7. package/dist/{converter-DyCJJfTe.mjs → converter-DB6Rg6Vd.mjs} +2 -2
  8. package/dist/formats/adjacency-list/index.d.mts +1 -1
  9. package/dist/formats/adjacency-list/index.mjs +1 -1
  10. package/dist/formats/converter/index.d.mts +1 -1
  11. package/dist/formats/converter/index.mjs +1 -1
  12. package/dist/formats/cytoscape/index.d.mts +4 -4
  13. package/dist/formats/cytoscape/index.mjs +8 -4
  14. package/dist/formats/d2/index.d.mts +1 -1
  15. package/dist/formats/d2/index.mjs +1 -1
  16. package/dist/formats/d3/index.d.mts +4 -4
  17. package/dist/formats/d3/index.mjs +8 -4
  18. package/dist/formats/dot/index.d.mts +1 -1
  19. package/dist/formats/dot/index.mjs +1 -1
  20. package/dist/formats/edge-list/index.d.mts +1 -1
  21. package/dist/formats/edge-list/index.mjs +1 -1
  22. package/dist/formats/elk/index.d.mts +1 -1
  23. package/dist/formats/elk/index.mjs +43 -11
  24. package/dist/formats/gexf/index.d.mts +1 -1
  25. package/dist/formats/gexf/index.mjs +22 -2
  26. package/dist/formats/gml/index.d.mts +4 -4
  27. package/dist/formats/gml/index.mjs +8 -4
  28. package/dist/formats/graphml/index.d.mts +1 -1
  29. package/dist/formats/graphml/index.mjs +24 -2
  30. package/dist/formats/jgf/index.d.mts +4 -4
  31. package/dist/formats/jgf/index.mjs +8 -4
  32. package/dist/formats/mermaid/index.d.mts +1 -1
  33. package/dist/formats/mermaid/index.mjs +1 -1
  34. package/dist/formats/tgf/index.d.mts +4 -4
  35. package/dist/formats/tgf/index.mjs +4 -4
  36. package/dist/formats/xyflow/index.d.mts +12 -6
  37. package/dist/formats/xyflow/index.mjs +11 -6
  38. package/dist/{index-D51lJnt2.d.mts → index-BlbSWUvH.d.mts} +1 -1
  39. package/dist/{index-DWmo1mIp.d.mts → index-CNvqxPLJ.d.mts} +82 -14
  40. package/dist/index.d.mts +6 -6
  41. package/dist/index.mjs +152 -17
  42. package/dist/layout/cytoscape.d.mts +66 -0
  43. package/dist/layout/cytoscape.mjs +114 -0
  44. package/dist/layout/d3-force.d.mts +52 -0
  45. package/dist/layout/d3-force.mjs +127 -0
  46. package/dist/layout/d3-hierarchy.d.mts +39 -0
  47. package/dist/layout/d3-hierarchy.mjs +135 -0
  48. package/dist/layout/dagre.d.mts +32 -0
  49. package/dist/layout/dagre.mjs +99 -0
  50. package/dist/layout/elk.d.mts +47 -0
  51. package/dist/layout/elk.mjs +73 -0
  52. package/dist/layout/forceatlas2.d.mts +48 -0
  53. package/dist/layout/forceatlas2.mjs +100 -0
  54. package/dist/layout/graphviz.d.mts +50 -0
  55. package/dist/layout/graphviz.mjs +179 -0
  56. package/dist/layout/index.d.mts +185 -0
  57. package/dist/layout/index.mjs +181 -0
  58. package/dist/layout/webcola.d.mts +40 -0
  59. package/dist/layout/webcola.mjs +104 -0
  60. package/dist/{queries-BfXeTXRf.d.mts → queries-B6quF529.d.mts} +1 -1
  61. package/dist/{queries-KirMDR7e.mjs → queries-BMM0XAv_.mjs} +23 -17
  62. package/dist/queries.d.mts +1 -1
  63. package/dist/queries.mjs +1 -1
  64. package/dist/schemas.d.mts +19 -1
  65. package/dist/schemas.mjs +10 -1
  66. package/dist/{types-DNYdIU21.d.mts → types-BAEQTwK_.d.mts} +46 -3
  67. package/package.json +47 -5
  68. package/schemas/edge.schema.json +27 -0
  69. package/schemas/graph.schema.json +27 -0
  70. /package/dist/{adjacency-list-GeL1Cu-L.mjs → adjacency-list-DQ32Mmhx.mjs} +0 -0
  71. /package/dist/{edge-list-BcZ0h6zz.mjs → edge-list-CA9UTvn2.mjs} +0 -0
  72. /package/dist/{mode-D8OnHFBk.mjs → mode-gu_mhKKs.mjs} +0 -0
  73. /package/dist/{validate-TtH-x3JV.mjs → validate-BsfSOv0S.mjs} +0 -0
@@ -1,5 +1,5 @@
1
- import { n as toAdjacencyList, t as fromAdjacencyList } from "./adjacency-list-GeL1Cu-L.mjs";
2
- import { n as toEdgeList, t as fromEdgeList } from "./edge-list-BcZ0h6zz.mjs";
1
+ import { n as toAdjacencyList, t as fromAdjacencyList } from "./adjacency-list-DQ32Mmhx.mjs";
2
+ import { n as toEdgeList, t as fromEdgeList } from "./edge-list-CA9UTvn2.mjs";
3
3
 
4
4
  //#region src/formats/converter/index.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { d as Graph } from "../../types-DNYdIU21.mjs";
1
+ import { f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/adjacency-list/index.d.ts
4
4
 
@@ -1,3 +1,3 @@
1
- import { n as toAdjacencyList, t as fromAdjacencyList } from "../../adjacency-list-GeL1Cu-L.mjs";
1
+ import { n as toAdjacencyList, t as fromAdjacencyList } from "../../adjacency-list-DQ32Mmhx.mjs";
2
2
 
3
3
  export { fromAdjacencyList, toAdjacencyList };
@@ -1,2 +1,2 @@
1
- import { n as createFormatConverter, r as edgeListConverter, t as adjacencyListConverter } from "../../index-D51lJnt2.mjs";
1
+ import { n as createFormatConverter, r as edgeListConverter, t as adjacencyListConverter } from "../../index-BlbSWUvH.mjs";
2
2
  export { adjacencyListConverter, createFormatConverter, edgeListConverter };
@@ -1,3 +1,3 @@
1
- import { n as createFormatConverter, r as edgeListConverter, t as adjacencyListConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { n as createFormatConverter, r as edgeListConverter, t as adjacencyListConverter } from "../../converter-DB6Rg6Vd.mjs";
2
2
 
3
3
  export { adjacencyListConverter, createFormatConverter, edgeListConverter };
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/cytoscape/index.d.ts
4
4
  interface CytoscapeNode {
@@ -33,7 +33,7 @@ interface CytoscapeJSON {
33
33
  * @example
34
34
  * ```ts
35
35
  * import { createGraph } from '@statelyai/graph';
36
- * import { toCytoscapeJSON } from '@statelyai/graph/formats/cytoscape';
36
+ * import { toCytoscapeJSON } from '@statelyai/graph/cytoscape';
37
37
  *
38
38
  * const graph = createGraph({
39
39
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -50,7 +50,7 @@ declare function toCytoscapeJSON(graph: Graph): CytoscapeJSON;
50
50
  *
51
51
  * @example
52
52
  * ```ts
53
- * import { fromCytoscapeJSON } from '@statelyai/graph/formats/cytoscape';
53
+ * import { fromCytoscapeJSON } from '@statelyai/graph/cytoscape';
54
54
  *
55
55
  * const graph = fromCytoscapeJSON({
56
56
  * elements: {
@@ -67,7 +67,7 @@ declare function fromCytoscapeJSON(cyto: CytoscapeJSON): Graph;
67
67
  * @example
68
68
  * ```ts
69
69
  * import { createGraph } from '@statelyai/graph';
70
- * import { cytoscapeConverter } from '@statelyai/graph/formats/cytoscape';
70
+ * import { cytoscapeConverter } from '@statelyai/graph/cytoscape';
71
71
  *
72
72
  * const graph = createGraph({
73
73
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -1,4 +1,4 @@
1
- import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { n as createFormatConverter } from "../../converter-DB6Rg6Vd.mjs";
2
2
 
3
3
  //#region src/formats/cytoscape/index.ts
4
4
  /**
@@ -7,7 +7,7 @@ import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
7
7
  * @example
8
8
  * ```ts
9
9
  * import { createGraph } from '@statelyai/graph';
10
- * import { toCytoscapeJSON } from '@statelyai/graph/formats/cytoscape';
10
+ * import { toCytoscapeJSON } from '@statelyai/graph/cytoscape';
11
11
  *
12
12
  * const graph = createGraph({
13
13
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -58,6 +58,8 @@ function toCytoscapeJSON(graph) {
58
58
  if (e.mode) data.mode = e.mode;
59
59
  if (e.data !== void 0) data.edgeData = e.data;
60
60
  if (e.weight !== void 0) data.weight = e.weight;
61
+ if (e.points !== void 0) data.points = e.points;
62
+ if (e.routing !== void 0) data.routing = e.routing;
61
63
  if (e.x !== void 0) data.x = e.x;
62
64
  if (e.y !== void 0) data.y = e.y;
63
65
  if (e.width !== void 0) data.width = e.width;
@@ -76,7 +78,7 @@ function toCytoscapeJSON(graph) {
76
78
  *
77
79
  * @example
78
80
  * ```ts
79
- * import { fromCytoscapeJSON } from '@statelyai/graph/formats/cytoscape';
81
+ * import { fromCytoscapeJSON } from '@statelyai/graph/cytoscape';
80
82
  *
81
83
  * const graph = fromCytoscapeJSON({
82
84
  * elements: {
@@ -125,6 +127,8 @@ function fromCytoscapeJSON(cyto) {
125
127
  ...e.data.mode && { mode: e.data.mode },
126
128
  data: e.data.edgeData,
127
129
  ...e.data.weight !== void 0 && { weight: e.data.weight },
130
+ ...e.data.points !== void 0 && { points: e.data.points },
131
+ ...e.data.routing !== void 0 && { routing: e.data.routing },
128
132
  ...e.data.x !== void 0 && { x: e.data.x },
129
133
  ...e.data.y !== void 0 && { y: e.data.y },
130
134
  ...e.data.width !== void 0 && { width: e.data.width },
@@ -142,7 +146,7 @@ function fromCytoscapeJSON(cyto) {
142
146
  * @example
143
147
  * ```ts
144
148
  * import { createGraph } from '@statelyai/graph';
145
- * import { cytoscapeConverter } from '@statelyai/graph/formats/cytoscape';
149
+ * import { cytoscapeConverter } from '@statelyai/graph/cytoscape';
146
150
  *
147
151
  * const graph = createGraph({
148
152
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/d2/shared.d.ts
4
4
  type D2Arrow = '->' | '<-' | '--' | '<->';
@@ -1,4 +1,4 @@
1
- import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { n as createFormatConverter } from "../../converter-DB6Rg6Vd.mjs";
2
2
 
3
3
  //#region src/formats/d2/shared.ts
4
4
  /** Map a d2 connector glyph to a graph edge mode. */
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/d3/index.d.ts
4
4
  interface D3Node {
@@ -27,7 +27,7 @@ interface D3Graph {
27
27
  * @example
28
28
  * ```ts
29
29
  * import { createGraph } from '@statelyai/graph';
30
- * import { toD3Graph } from '@statelyai/graph/formats/d3';
30
+ * import { toD3Graph } from '@statelyai/graph/d3';
31
31
  *
32
32
  * const graph = createGraph({
33
33
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -44,7 +44,7 @@ declare function toD3Graph(graph: Graph): D3Graph;
44
44
  *
45
45
  * @example
46
46
  * ```ts
47
- * import { fromD3Graph } from '@statelyai/graph/formats/d3';
47
+ * import { fromD3Graph } from '@statelyai/graph/d3';
48
48
  *
49
49
  * const graph = fromD3Graph({
50
50
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -59,7 +59,7 @@ declare function fromD3Graph(d3: D3Graph): Graph;
59
59
  * @example
60
60
  * ```ts
61
61
  * import { createGraph } from '@statelyai/graph';
62
- * import { d3Converter } from '@statelyai/graph/formats/d3';
62
+ * import { d3Converter } from '@statelyai/graph/d3';
63
63
  *
64
64
  * const graph = createGraph({
65
65
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -1,4 +1,4 @@
1
- import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { n as createFormatConverter } from "../../converter-DB6Rg6Vd.mjs";
2
2
 
3
3
  //#region src/formats/d3/index.ts
4
4
  /**
@@ -7,7 +7,7 @@ import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
7
7
  * @example
8
8
  * ```ts
9
9
  * import { createGraph } from '@statelyai/graph';
10
- * import { toD3Graph } from '@statelyai/graph/formats/d3';
10
+ * import { toD3Graph } from '@statelyai/graph/d3';
11
11
  *
12
12
  * const graph = createGraph({
13
13
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -52,6 +52,8 @@ function toD3Graph(graph) {
52
52
  if (e.mode) link.mode = e.mode;
53
53
  if (e.data !== void 0) link.data = e.data;
54
54
  if (e.weight !== void 0) link.weight = e.weight;
55
+ if (e.points !== void 0) link.points = e.points;
56
+ if (e.routing !== void 0) link.routing = e.routing;
55
57
  if (e.x !== void 0) link.x = e.x;
56
58
  if (e.y !== void 0) link.y = e.y;
57
59
  if (e.width !== void 0) link.width = e.width;
@@ -69,7 +71,7 @@ function toD3Graph(graph) {
69
71
  *
70
72
  * @example
71
73
  * ```ts
72
- * import { fromD3Graph } from '@statelyai/graph/formats/d3';
74
+ * import { fromD3Graph } from '@statelyai/graph/d3';
73
75
  *
74
76
  * const graph = fromD3Graph({
75
77
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -113,6 +115,8 @@ function fromD3Graph(d3) {
113
115
  ...l.mode && { mode: l.mode },
114
116
  data: l.data,
115
117
  ...l.weight !== void 0 && { weight: l.weight },
118
+ ...l.points !== void 0 && { points: l.points },
119
+ ...l.routing !== void 0 && { routing: l.routing },
116
120
  ...l.x !== void 0 && { x: l.x },
117
121
  ...l.y !== void 0 && { y: l.y },
118
122
  ...l.width !== void 0 && { width: l.width },
@@ -130,7 +134,7 @@ function fromD3Graph(d3) {
130
134
  * @example
131
135
  * ```ts
132
136
  * import { createGraph } from '@statelyai/graph';
133
- * import { d3Converter } from '@statelyai/graph/formats/d3';
137
+ * import { d3Converter } from '@statelyai/graph/d3';
134
138
  *
135
139
  * const graph = createGraph({
136
140
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/dot/index.d.ts
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { n as createFormatConverter } from "../../converter-DB6Rg6Vd.mjs";
2
2
  import parse from "dotparser";
3
3
 
4
4
  //#region src/formats/dot/index.ts
@@ -1,4 +1,4 @@
1
- import { d as Graph } from "../../types-DNYdIU21.mjs";
1
+ import { f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/edge-list/index.d.ts
4
4
 
@@ -1,3 +1,3 @@
1
- import { n as toEdgeList, t as fromEdgeList } from "../../edge-list-BcZ0h6zz.mjs";
1
+ import { n as toEdgeList, t as fromEdgeList } from "../../edge-list-CA9UTvn2.mjs";
2
2
 
3
3
  export { fromEdgeList, toEdgeList };
@@ -1,4 +1,4 @@
1
- import { L as VisualGraphFormatConverter, P as VisualGraph } from "../../types-DNYdIU21.mjs";
1
+ import { I as VisualGraph, z as VisualGraphFormatConverter } from "../../types-BAEQTwK_.mjs";
2
2
  import { ElkEdge, ElkEdgeSection, ElkExtendedEdge, ElkGraphElement, ElkLabel, ElkNode, ElkNode as ElkNode$1, ElkPoint, ElkPort, ElkPrimitiveEdge, ElkShape, LayoutOptions } from "elkjs/lib/elk-api";
3
3
 
4
4
  //#region src/formats/elk/index.d.ts
@@ -1,4 +1,4 @@
1
- import { n as getChildren } from "../../queries-KirMDR7e.mjs";
1
+ import { n as getChildren } from "../../queries-BMM0XAv_.mjs";
2
2
 
3
3
  //#region src/formats/elk/index.ts
4
4
  const STATELYAI_METADATA_KEY = "statelyai.metadata";
@@ -36,7 +36,11 @@ function convertEdge(edge) {
36
36
  sources: [edge.sourcePort != null ? `${edge.sourceId}__${edge.sourcePort}` : edge.sourceId],
37
37
  targets: [edge.targetPort != null ? `${edge.targetId}__${edge.targetPort}` : edge.targetId]
38
38
  };
39
- if (edge.label) elkEdge.labels = [{ text: edge.label }];
39
+ if (edge.label) elkEdge.labels = [{
40
+ text: edge.label,
41
+ ...edge.width > 0 && { width: edge.width },
42
+ ...edge.height > 0 && { height: edge.height }
43
+ }];
40
44
  return addMetadata(elkEdge, { edge: {
41
45
  sourceId: edge.sourceId,
42
46
  targetId: edge.targetId,
@@ -51,7 +55,9 @@ function convertEdge(edge) {
51
55
  x: edge.x,
52
56
  y: edge.y,
53
57
  width: edge.width,
54
- height: edge.height
58
+ height: edge.height,
59
+ points: edge.points,
60
+ routing: edge.routing
55
61
  } });
56
62
  }
57
63
  function convertPort(nodeId, port) {
@@ -148,7 +154,7 @@ function toELK(graph) {
148
154
  if (rootEdges.length > 0) root.edges = rootEdges.map(convertEdge);
149
155
  return root;
150
156
  }
151
- function flattenElkNodes(elkNode, parentId, nodes, edges, edgeIdx, portOwner) {
157
+ function flattenElkNodes(elkNode, parentId, nodes, edges, edgeIdx, portOwner, edgeRouting) {
152
158
  if (elkNode.children) for (const child of elkNode.children) {
153
159
  const label = child.labels?.[0]?.text ?? "";
154
160
  const metadata = readMetadata(child)?.node;
@@ -191,28 +197,51 @@ function flattenElkNodes(elkNode, parentId, nodes, edges, edgeIdx, portOwner) {
191
197
  };
192
198
  });
193
199
  nodes.push(node);
194
- flattenElkNodes(child, child.id, nodes, edges, edgeIdx, portOwner);
200
+ flattenElkNodes(child, child.id, nodes, edges, edgeIdx, portOwner, edgeRouting);
195
201
  }
196
202
  if (elkNode.edges) for (const elkEdge of elkNode.edges) for (const source of elkEdge.sources) for (const target of elkEdge.targets) {
197
203
  const metadata = readMetadata(elkEdge)?.edge;
198
204
  const sourceOwner = portOwner.get(source);
199
205
  const targetOwner = portOwner.get(target);
206
+ const elkLabel = elkEdge.labels?.[0];
207
+ const hasComputedLabel = elkLabel?.x !== void 0 && elkLabel?.y !== void 0;
208
+ const section = elkEdge.sections?.[0];
200
209
  const edge = {
201
210
  type: "edge",
202
211
  id: elkEdge.id ?? `e${edgeIdx.value++}`,
203
212
  sourceId: metadata?.sourceId ?? sourceOwner?.nodeId ?? source,
204
213
  targetId: metadata?.targetId ?? targetOwner?.nodeId ?? target,
205
- label: metadata && "label" in metadata ? metadata.label : elkEdge.labels?.[0]?.text ?? "",
214
+ label: metadata && "label" in metadata ? metadata.label : elkLabel?.text ?? "",
206
215
  data: metadata && "data" in metadata ? metadata.data : void 0,
207
- x: metadata?.x ?? 0,
208
- y: metadata?.y ?? 0,
209
- width: metadata?.width ?? 0,
210
- height: metadata?.height ?? 0,
216
+ x: hasComputedLabel ? elkLabel.x : metadata?.x ?? 0,
217
+ y: hasComputedLabel ? elkLabel.y : metadata?.y ?? 0,
218
+ width: hasComputedLabel ? elkLabel.width ?? metadata?.width ?? 0 : metadata?.width ?? 0,
219
+ height: hasComputedLabel ? elkLabel.height ?? metadata?.height ?? 0 : metadata?.height ?? 0,
211
220
  ...metadata?.mode !== void 0 && { mode: metadata.mode },
212
221
  ...metadata?.weight !== void 0 && { weight: metadata.weight },
213
222
  ...metadata?.color !== void 0 && { color: metadata.color },
214
223
  ...metadata?.style !== void 0 && { style: metadata.style }
215
224
  };
225
+ if (section?.startPoint && section.endPoint) {
226
+ edge.points = [
227
+ {
228
+ x: section.startPoint.x,
229
+ y: section.startPoint.y
230
+ },
231
+ ...(section.bendPoints ?? []).map((p) => ({
232
+ x: p.x,
233
+ y: p.y
234
+ })),
235
+ {
236
+ x: section.endPoint.x,
237
+ y: section.endPoint.y
238
+ }
239
+ ];
240
+ edge.routing = edgeRouting;
241
+ } else if (metadata?.points !== void 0) {
242
+ edge.points = metadata.points;
243
+ if (metadata.routing !== void 0) edge.routing = metadata.routing;
244
+ }
216
245
  if (metadata && "sourcePort" in metadata) edge.sourcePort = metadata.sourcePort;
217
246
  else if (sourceOwner) edge.sourcePort = sourceOwner.portName;
218
247
  if (metadata && "targetPort" in metadata) edge.targetPort = metadata.targetPort;
@@ -243,7 +272,10 @@ function flattenElkNodes(elkNode, parentId, nodes, edges, edgeIdx, portOwner) {
243
272
  function fromELK(elkRoot) {
244
273
  const nodes = [];
245
274
  const edges = [];
246
- flattenElkNodes(elkRoot, null, nodes, edges, { value: 0 }, /* @__PURE__ */ new Map());
275
+ const edgeIdx = { value: 0 };
276
+ const portOwner = /* @__PURE__ */ new Map();
277
+ const elkEdgeRouting = String(elkRoot.layoutOptions?.["elk.edgeRouting"] ?? elkRoot.layoutOptions?.["org.eclipse.elk.edgeRouting"] ?? "").toUpperCase();
278
+ flattenElkNodes(elkRoot, null, nodes, edges, edgeIdx, portOwner, elkEdgeRouting === "SPLINES" ? "splines" : elkEdgeRouting === "POLYLINE" ? "polyline" : "orthogonal");
247
279
  const seenEdges = /* @__PURE__ */ new Map();
248
280
  for (const edge of edges) if (!seenEdges.has(edge.id)) seenEdges.set(edge.id, edge);
249
281
  const elkDir = elkRoot.layoutOptions?.["elk.direction"];
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/gexf/index.d.ts
4
4
  declare function toGEXF(graph: Graph): string;
@@ -1,5 +1,5 @@
1
- import { t as getEdgeMode } from "../../mode-D8OnHFBk.mjs";
2
- import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { t as getEdgeMode } from "../../mode-gu_mhKKs.mjs";
2
+ import { n as createFormatConverter } from "../../converter-DB6Rg6Vd.mjs";
3
3
  import { XMLBuilder, XMLParser } from "fast-xml-parser";
4
4
 
5
5
  //#region src/formats/gexf/index.ts
@@ -82,6 +82,16 @@ function toGEXF(graph) {
82
82
  "@_title": "style",
83
83
  "@_type": "string"
84
84
  },
85
+ {
86
+ "@_id": "a_edgePoints",
87
+ "@_title": "points",
88
+ "@_type": "string"
89
+ },
90
+ {
91
+ "@_id": "a_edgeRouting",
92
+ "@_title": "routing",
93
+ "@_type": "string"
94
+ },
85
95
  {
86
96
  "@_id": "a_sourcePort",
87
97
  "@_title": "sourcePort",
@@ -167,6 +177,14 @@ function toGEXF(graph) {
167
177
  "@_for": "a_edgeWeight",
168
178
  "@_value": e.weight
169
179
  });
180
+ if (e.points !== void 0) edgeAttvalues.push({
181
+ "@_for": "a_edgePoints",
182
+ "@_value": JSON.stringify(e.points)
183
+ });
184
+ if (e.routing !== void 0) edgeAttvalues.push({
185
+ "@_for": "a_edgeRouting",
186
+ "@_value": e.routing
187
+ });
170
188
  if (e.x !== void 0) edgeAttvalues.push({
171
189
  "@_for": "a_edgeX",
172
190
  "@_value": e.x
@@ -318,6 +336,8 @@ function fromGEXF(xml) {
318
336
  label: e["@_label"] ?? "",
319
337
  data: attvals["data"] !== void 0 ? tryParseJSON(attvals["data"]) : void 0,
320
338
  ...attvals["weight"] !== void 0 && { weight: parseNumber(attvals["weight"], "weight attribute", "edge", id) },
339
+ ...attvals["points"] !== void 0 && { points: tryParseJSON(attvals["points"]) },
340
+ ...attvals["routing"] !== void 0 && { routing: attvals["routing"] },
321
341
  ...attvals["x"] !== void 0 && { x: parseNumber(attvals["x"], "x attribute", "edge", id) },
322
342
  ...attvals["y"] !== void 0 && { y: parseNumber(attvals["y"], "y attribute", "edge", id) },
323
343
  ...attvals["width"] !== void 0 && { width: parseNumber(attvals["width"], "width attribute", "edge", id) },
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/gml/index.d.ts
4
4
 
@@ -8,7 +8,7 @@ import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs"
8
8
  * @example
9
9
  * ```ts
10
10
  * import { createGraph } from '@statelyai/graph';
11
- * import { toGML } from '@statelyai/graph/formats/gml';
11
+ * import { toGML } from '@statelyai/graph/gml';
12
12
  *
13
13
  * const graph = createGraph({
14
14
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -30,7 +30,7 @@ declare function toGML(graph: Graph): string;
30
30
  *
31
31
  * @example
32
32
  * ```ts
33
- * import { fromGML } from '@statelyai/graph/formats/gml';
33
+ * import { fromGML } from '@statelyai/graph/gml';
34
34
  *
35
35
  * const graph = fromGML(`
36
36
  * graph [
@@ -49,7 +49,7 @@ declare function fromGML(gml: string): Graph;
49
49
  * @example
50
50
  * ```ts
51
51
  * import { createGraph } from '@statelyai/graph';
52
- * import { gmlConverter } from '@statelyai/graph/formats/gml';
52
+ * import { gmlConverter } from '@statelyai/graph/gml';
53
53
  *
54
54
  * const graph = createGraph({
55
55
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -1,4 +1,4 @@
1
- import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { n as createFormatConverter } from "../../converter-DB6Rg6Vd.mjs";
2
2
 
3
3
  //#region src/formats/gml/index.ts
4
4
  /**
@@ -7,7 +7,7 @@ import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
7
7
  * @example
8
8
  * ```ts
9
9
  * import { createGraph } from '@statelyai/graph';
10
- * import { toGML } from '@statelyai/graph/formats/gml';
10
+ * import { toGML } from '@statelyai/graph/gml';
11
11
  *
12
12
  * const graph = createGraph({
13
13
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -72,6 +72,8 @@ function toGML(graph) {
72
72
  if (edge.label) lines.push(` label ${gmlString(edge.label)}`);
73
73
  if (edge.data !== void 0) lines.push(` data ${gmlString(JSON.stringify(edge.data))}`);
74
74
  if (edge.weight !== void 0) lines.push(` weight ${edge.weight}`);
75
+ if (edge.points !== void 0) lines.push(` points ${gmlString(JSON.stringify(edge.points))}`);
76
+ if (edge.routing !== void 0) lines.push(` routing ${gmlString(edge.routing)}`);
75
77
  if (edge.sourcePort !== void 0) lines.push(` sourcePort ${gmlString(edge.sourcePort)}`);
76
78
  if (edge.targetPort !== void 0) lines.push(` targetPort ${gmlString(edge.targetPort)}`);
77
79
  if (edge.color) lines.push(` color ${gmlString(edge.color)}`);
@@ -97,7 +99,7 @@ function gmlString(s) {
97
99
  *
98
100
  * @example
99
101
  * ```ts
100
- * import { fromGML } from '@statelyai/graph/formats/gml';
102
+ * import { fromGML } from '@statelyai/graph/gml';
101
103
  *
102
104
  * const graph = fromGML(`
103
105
  * graph [
@@ -158,6 +160,8 @@ function fromGML(gml) {
158
160
  ...e["mode"] && { mode: String(e["mode"]) },
159
161
  data: e["data"] !== void 0 ? tryParseJSON(e["data"]) : void 0,
160
162
  ...e["weight"] !== void 0 && { weight: parseNumber(e["weight"], "weight", "edge", id) },
163
+ ...e["points"] !== void 0 && { points: tryParseJSON(e["points"]) },
164
+ ...e["routing"] !== void 0 && { routing: String(e["routing"]) },
161
165
  ...e["sourcePort"] !== void 0 && { sourcePort: String(e["sourcePort"]) },
162
166
  ...e["targetPort"] !== void 0 && { targetPort: String(e["targetPort"]) },
163
167
  ...e["color"] && { color: e["color"] },
@@ -316,7 +320,7 @@ function parseNumber(value, field, kind, ownerId) {
316
320
  * @example
317
321
  * ```ts
318
322
  * import { createGraph } from '@statelyai/graph';
319
- * import { gmlConverter } from '@statelyai/graph/formats/gml';
323
+ * import { gmlConverter } from '@statelyai/graph/gml';
320
324
  *
321
325
  * const graph = createGraph({
322
326
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/graphml/index.d.ts
4
4
  declare function toGraphML(graph: Graph): string;
@@ -1,5 +1,5 @@
1
- import { t as getEdgeMode } from "../../mode-D8OnHFBk.mjs";
2
- import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { t as getEdgeMode } from "../../mode-gu_mhKKs.mjs";
2
+ import { n as createFormatConverter } from "../../converter-DB6Rg6Vd.mjs";
3
3
  import { XMLBuilder, XMLParser } from "fast-xml-parser";
4
4
 
5
5
  //#region src/formats/graphml/index.ts
@@ -102,6 +102,18 @@ function toGraphML(graph) {
102
102
  "@_attr.name": "weight",
103
103
  "@_attr.type": "double"
104
104
  },
105
+ {
106
+ "@_id": "points",
107
+ "@_for": "edge",
108
+ "@_attr.name": "points",
109
+ "@_attr.type": "string"
110
+ },
111
+ {
112
+ "@_id": "routing",
113
+ "@_for": "edge",
114
+ "@_attr.name": "routing",
115
+ "@_attr.type": "string"
116
+ },
105
117
  {
106
118
  "@_id": "ports",
107
119
  "@_for": "node",
@@ -216,6 +228,14 @@ function toGraphML(graph) {
216
228
  "@_key": "weight",
217
229
  "#text": edge.weight
218
230
  });
231
+ if (edge.points !== void 0) data.push({
232
+ "@_key": "points",
233
+ "#text": JSON.stringify(edge.points)
234
+ });
235
+ if (edge.routing !== void 0) data.push({
236
+ "@_key": "routing",
237
+ "#text": edge.routing
238
+ });
219
239
  if (edge.sourcePort !== void 0) data.push({
220
240
  "@_key": "sourcePort",
221
241
  "#text": edge.sourcePort
@@ -357,6 +377,8 @@ function fromGraphML(xml) {
357
377
  data: dataMap.data !== void 0 ? tryParseJSON(dataMap.data) : void 0
358
378
  };
359
379
  if (dataMap.weight !== void 0) edge.weight = parseNumber(dataMap.weight, "weight", "edge", id);
380
+ if (dataMap.points !== void 0) edge.points = tryParseJSON(dataMap.points);
381
+ if (dataMap.routing !== void 0) edge.routing = dataMap.routing;
360
382
  if (dataMap.x !== void 0) edge.x = parseNumber(dataMap.x, "x", "edge", id);
361
383
  if (dataMap.y !== void 0) edge.y = parseNumber(dataMap.y, "y", "edge", id);
362
384
  if (dataMap.width !== void 0) edge.width = parseNumber(dataMap.width, "width", "edge", id);
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/jgf/index.d.ts
4
4
  interface JGFNode {
@@ -28,7 +28,7 @@ interface JGFGraph {
28
28
  * @example
29
29
  * ```ts
30
30
  * import { createGraph } from '@statelyai/graph';
31
- * import { toJGF } from '@statelyai/graph/formats/jgf';
31
+ * import { toJGF } from '@statelyai/graph/jgf';
32
32
  *
33
33
  * const graph = createGraph({
34
34
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -45,7 +45,7 @@ declare function toJGF(graph: Graph): JGFGraph;
45
45
  *
46
46
  * @example
47
47
  * ```ts
48
- * import { fromJGF } from '@statelyai/graph/formats/jgf';
48
+ * import { fromJGF } from '@statelyai/graph/jgf';
49
49
  *
50
50
  * const graph = fromJGF({
51
51
  * graph: {
@@ -63,7 +63,7 @@ declare function fromJGF(jgf: JGFGraph): Graph;
63
63
  * @example
64
64
  * ```ts
65
65
  * import { createGraph } from '@statelyai/graph';
66
- * import { jgfConverter } from '@statelyai/graph/formats/jgf';
66
+ * import { jgfConverter } from '@statelyai/graph/jgf';
67
67
  *
68
68
  * const graph = createGraph({
69
69
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -1,4 +1,4 @@
1
- import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { n as createFormatConverter } from "../../converter-DB6Rg6Vd.mjs";
2
2
 
3
3
  //#region src/formats/jgf/index.ts
4
4
  /**
@@ -7,7 +7,7 @@ import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
7
7
  * @example
8
8
  * ```ts
9
9
  * import { createGraph } from '@statelyai/graph';
10
- * import { toJGF } from '@statelyai/graph/formats/jgf';
10
+ * import { toJGF } from '@statelyai/graph/jgf';
11
11
  *
12
12
  * const graph = createGraph({
13
13
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -53,6 +53,8 @@ function toJGF(graph) {
53
53
  if (e.mode) meta.mode = e.mode;
54
54
  if (e.data !== void 0) meta.data = e.data;
55
55
  if (e.weight !== void 0) meta.weight = e.weight;
56
+ if (e.points !== void 0) meta.points = e.points;
57
+ if (e.routing !== void 0) meta.routing = e.routing;
56
58
  if (e.x !== void 0) meta.x = e.x;
57
59
  if (e.y !== void 0) meta.y = e.y;
58
60
  if (e.width !== void 0) meta.width = e.width;
@@ -76,7 +78,7 @@ function toJGF(graph) {
76
78
  *
77
79
  * @example
78
80
  * ```ts
79
- * import { fromJGF } from '@statelyai/graph/formats/jgf';
81
+ * import { fromJGF } from '@statelyai/graph/jgf';
80
82
  *
81
83
  * const graph = fromJGF({
82
84
  * graph: {
@@ -125,6 +127,8 @@ function fromJGF(jgf) {
125
127
  ...e.metadata?.mode && { mode: e.metadata.mode },
126
128
  data: e.metadata?.data,
127
129
  ...e.metadata?.weight !== void 0 && { weight: e.metadata.weight },
130
+ ...e.metadata?.points !== void 0 && { points: e.metadata.points },
131
+ ...e.metadata?.routing !== void 0 && { routing: e.metadata.routing },
128
132
  ...e.metadata?.x !== void 0 && { x: e.metadata.x },
129
133
  ...e.metadata?.y !== void 0 && { y: e.metadata.y },
130
134
  ...e.metadata?.width !== void 0 && { width: e.metadata.width },
@@ -142,7 +146,7 @@ function fromJGF(jgf) {
142
146
  * @example
143
147
  * ```ts
144
148
  * import { createGraph } from '@statelyai/graph';
145
- * import { jgfConverter } from '@statelyai/graph/formats/jgf';
149
+ * import { jgfConverter } from '@statelyai/graph/jgf';
146
150
  *
147
151
  * const graph = createGraph({
148
152
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/mermaid/sequence.d.ts
4
4
  interface SequenceNodeData {
@@ -1,4 +1,4 @@
1
- import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { n as createFormatConverter } from "../../converter-DB6Rg6Vd.mjs";
2
2
 
3
3
  //#region src/formats/mermaid/shared.ts
4
4
  const MERMAID_TO_DIRECTION = {