@statelyai/layout 0.1.3 → 0.3.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 (85) hide show
  1. package/NOTICE.md +43 -0
  2. package/README.md +153 -6
  3. package/dist/elkjs/index.cjs +9 -0
  4. package/dist/elkjs/index.d.cts +155 -0
  5. package/dist/elkjs/index.d.mts +51 -39
  6. package/dist/elkjs/index.mjs +3 -1484
  7. package/dist/elkjs/main.cjs +17 -0
  8. package/dist/elkjs/main.d.cts +10 -0
  9. package/dist/elkjs/main.d.mts +11 -0
  10. package/dist/elkjs/main.mjs +17 -0
  11. package/dist/elkjs/worker-api.cjs +3 -0
  12. package/dist/elkjs/worker-api.d.cts +3 -0
  13. package/dist/elkjs/worker-api.d.mts +3 -0
  14. package/dist/elkjs/worker-api.mjs +3 -0
  15. package/dist/elkjs/worker.cjs +86 -0
  16. package/dist/elkjs/worker.d.cts +17 -0
  17. package/dist/elkjs/worker.d.mts +17 -0
  18. package/dist/elkjs/worker.mjs +86 -0
  19. package/dist/elkjs-DaHMISnQ.mjs +1677 -0
  20. package/dist/elkjs-dMghiiWW.cjs +1706 -0
  21. package/dist/index-BEA_pzeT.d.cts +72 -0
  22. package/dist/{index-8xYkohbz.d.mts → index-D9dhxrRl.d.cts} +111 -5
  23. package/dist/index-DNTLRsDl.d.mts +72 -0
  24. package/dist/index-DNixtE3h.d.mts +1318 -0
  25. package/dist/index.cjs +215 -0
  26. package/dist/index.d.cts +78 -0
  27. package/dist/index.d.mts +4 -3
  28. package/dist/index.mjs +25 -25
  29. package/dist/layered/index.cjs +38 -0
  30. package/dist/layered/index.d.cts +3 -0
  31. package/dist/layered/index.d.mts +3 -2
  32. package/dist/layered/index.mjs +1 -1
  33. package/dist/layered-B2buJqMf.cjs +12009 -0
  34. package/dist/{layered-CoeH9LRO.mjs → layered-DGFTeQSl.mjs} +2323 -149
  35. package/dist/{spore-BtTSZbb6.mjs → layout-engine-Cs5tatA6.mjs} +159 -5
  36. package/dist/layout-engine-Dn1PiFwP.cjs +712 -0
  37. package/dist/public-types-9NCPoqbp.d.mts +109 -0
  38. package/dist/public-types-BcRZoJE3.d.cts +109 -0
  39. package/dist/routing/index.cjs +28 -0
  40. package/dist/routing/index.d.cts +3 -0
  41. package/dist/routing/index.d.mts +3 -0
  42. package/dist/routing/index.mjs +3 -0
  43. package/dist/routing-A2hrK9MP.mjs +2396 -0
  44. package/dist/routing-ujEP7Qh6.cjs +2606 -0
  45. package/dist/types-CT2akdK0.d.mts +133 -0
  46. package/dist/types-uxPlGRof.d.cts +133 -0
  47. package/dist/worker-client-BNjwT1AJ.mjs +92 -0
  48. package/dist/worker-client-BwGGRD5y.d.mts +19 -0
  49. package/dist/worker-client-D4oEvhAl.cjs +98 -0
  50. package/dist/worker-client-D4zNyPEI.d.cts +19 -0
  51. package/package.json +45 -10
  52. package/src/authoring/coordinates.ts +114 -0
  53. package/src/authoring/partial.ts +584 -0
  54. package/src/authoring/routing.ts +211 -0
  55. package/src/box.ts +22 -0
  56. package/src/constraints.ts +222 -0
  57. package/src/elkjs/index.ts +104 -39
  58. package/src/elkjs/main.ts +19 -0
  59. package/src/elkjs/public-types.ts +125 -0
  60. package/src/elkjs/routes.ts +147 -0
  61. package/src/elkjs/worker-api.ts +29 -0
  62. package/src/elkjs/worker-client.ts +138 -0
  63. package/src/elkjs/worker.ts +117 -0
  64. package/src/index.ts +19 -0
  65. package/src/internal/elkjs-compatibility.ts +17 -0
  66. package/src/internal/layout-engine.ts +126 -0
  67. package/src/layered/compound.ts +417 -0
  68. package/src/layered/index.ts +58 -105
  69. package/src/layered/types.ts +21 -0
  70. package/src/layout.ts +35 -28
  71. package/src/packing.ts +22 -0
  72. package/src/random.ts +75 -3
  73. package/src/routing/adapters.ts +111 -0
  74. package/src/routing/algorithms.ts +676 -0
  75. package/src/routing/coordination.ts +86 -0
  76. package/src/routing/engine.ts +473 -0
  77. package/src/routing/index.ts +68 -0
  78. package/src/routing/layout-cache.ts +65 -0
  79. package/src/routing/model.ts +218 -0
  80. package/src/routing/path.ts +324 -0
  81. package/src/routing/persistent.ts +117 -0
  82. package/src/routing/search.ts +276 -0
  83. package/src/routing/spatial.ts +78 -0
  84. package/src/routing/types.ts +146 -0
  85. package/src/types.ts +17 -2
package/NOTICE.md CHANGED
@@ -16,3 +16,46 @@ https://github.com/eclipse/elk-models. Those examples are available under the
16
16
  Eclipse Public License 2.0. Their ELKT graph source and upstream paths are
17
17
  preserved in the generated example catalog; the upstream repository retains
18
18
  the original per-file notices.
19
+
20
+ ## Kiwi constraint solver
21
+
22
+ Runtime bundles include `@lume/kiwi` 0.4.4 (https://github.com/lume/kiwi).
23
+
24
+ ```text
25
+ =========================
26
+ The Kiwi licensing terms
27
+ =========================
28
+ Kiwi is licensed under the terms of the Modified BSD License (also known as
29
+ New or Revised BSD), as follows:
30
+
31
+ Copyright (c) 2013, Nucleic Development Team
32
+ Copyright (c) 2021, Joseph Orbegoso Pea
33
+ Copyright (c) 2021, LUME
34
+
35
+ All rights reserved.
36
+
37
+ Redistribution and use in source and binary forms, with or without
38
+ modification, are permitted provided that the following conditions are met:
39
+
40
+ Redistributions of source code must retain the above copyright notice, this
41
+ list of conditions and the following disclaimer.
42
+
43
+ Redistributions in binary form must reproduce the above copyright notice, this
44
+ list of conditions and the following disclaimer in the documentation and/or
45
+ other materials provided with the distribution.
46
+
47
+ Neither the name of the Nucleic Development Team nor the names of its
48
+ contributors may be used to endorse or promote products derived from this
49
+ software without specific prior written permission.
50
+
51
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
52
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
53
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
54
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
55
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
57
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
58
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
59
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61
+ ```
package/README.md CHANGED
@@ -4,8 +4,9 @@ Native TypeScript graph layout algorithms built directly on
4
4
  [`@statelyai/graph`](https://github.com/statelyai/graph).
5
5
 
6
6
  This is not a new graph interchange format. Public APIs consume `Graph` and
7
- return `VisualGraph`; positions remain node fields and routes remain
8
- `GraphEdge.points`.
7
+ return `VisualGraph`; positions remain node fields. Standalone routing adds
8
+ immutable structured routes and incremental patches alongside the existing
9
+ `GraphEdge.points` layout output.
9
10
 
10
11
  ## Status
11
12
 
@@ -16,8 +17,9 @@ layered inventory with one simplified typed name per ELK option. Flat and
16
17
  compound graphs, cross-hierarchy edges, ports, labels, self-loops, wrapping,
17
18
  four directions, constraints, and replaceable phases are differential-tested
18
19
  against elkjs, including a curated complex state-machine corpus in both primary
19
- layout orientations. Partial, incremental, and route-only layout remain
20
- explicit unimplemented capabilities.
20
+ layout orientations. Native layered layout also supports partial selection,
21
+ route-only execution, and geometric constraints. Incremental layout remains
22
+ explicitly unsupported.
21
23
 
22
24
  ## Install
23
25
 
@@ -54,6 +56,116 @@ result.diagnostics;
54
56
  result.metrics;
55
57
  ```
56
58
 
59
+ ## Native compound geometry
60
+
61
+ <!-- compound geometry options and output from src/layered/types.ts and src/layered/compound.ts -->
62
+
63
+ ```ts
64
+ const result = getLayeredLayout(graph, {
65
+ direction: "down",
66
+ padding: { top: 24, right: 40, bottom: 24, left: 40 },
67
+ compound: (node) => ({
68
+ header: { width: 200, height: 60, side: "top" },
69
+ direction: "right",
70
+ }),
71
+ edgeAttachment: (edge) => ({
72
+ source: "content", // Use "outer" for an outward/reentering transition.
73
+ }),
74
+ });
75
+ result.compoundGeometry.get("parent"); // { bounds, header, content }
76
+ result.compoundRoutes; // World-space sections, label gaps, routing diagnostics.
77
+ ```
78
+
79
+ Each scope reserves children and measured labels before its ancestors are laid
80
+ out. Header measurements cannot replace finalized compound dimensions. Node
81
+ positions and compound bounds are parent-relative; edge label positions and
82
+ routes are world-relative, marked by `edgeCoordinateSpace: "world"`. Header and content rectangles are local to the
83
+ compound. For ancestor-to-descendant edges, content attachments leave inward;
84
+ outer attachments leave outward. Explicit ports retain their node-local geometry.
85
+ The native compound router emits orthogonal route sections for the original endpoints.
86
+ Use `compoundRoutes` or `getLayoutRoutes(result)` to retain label gaps and
87
+ fallback diagnostics; legacy `edge.points` flattens the sections. `getLayout`
88
+ also reports routing diagnostics in its result. Compound routing currently uses
89
+ orthogonal sections independently of the flat layout routing setting.
90
+
91
+ These options belong to the native contract; they do not change the pinned
92
+ ELK compatibility contract. The existing simplified advanced options still
93
+ map to ELK option IDs, but identical geometry is not guaranteed between contracts.
94
+
95
+ ## Standalone incremental routing
96
+
97
+ <!-- routing API and strategy catalog from src/routing/index.ts -->
98
+
99
+ ```ts
100
+ import { getDiff } from "@statelyai/graph";
101
+ import { orthogonalRouting, toSvgPath } from "@statelyai/layout/routing";
102
+
103
+ const previous = orthogonalRouting.route(graph);
104
+ const { snapshot, patches } = orthogonalRouting.update(
105
+ nextGraph,
106
+ previous,
107
+ getDiff(graph, nextGraph),
108
+ );
109
+ const route = snapshot.routes.get("ab");
110
+ const paths = route?.sections.map((section) => toSvgPath(section.path));
111
+ ```
112
+
113
+ Incremental results match fresh routing for the same graph and settings. Previous
114
+ paths are cached outputs, never constraints on new routes.
115
+
116
+ Every strategy supports incremental updates with immutable snapshots and shared
117
+ indexes. Nodes, ports, and labels stay fixed. Every edge receives a route;
118
+ fallbacks expose status and diagnostics. Deterministic soft crossing/overlap costs
119
+ coordinate unrelated groups; residual conflicts stay visible and reported. Native TypeScript strategies cover
120
+ straight, Bézier, orthogonal, polyline, octilinear, curved, organic, parallel,
121
+ self-loop, fan, bus, and bundled routes. Render curves directly or flatten them
122
+ for a lines-only renderer. ELK/native layout adapters preserve existing output.
123
+
124
+ For efficient dragging, supply the edit's diff directly: `getDiff` scans the
125
+ whole graph. See [routing contracts, algorithms, and examples](docs/routing.md).
126
+
127
+ ## Layout while authoring
128
+
129
+ <!-- partial scopes and geometry constraints from src/types.ts and src/constraints.ts -->
130
+
131
+ Select nodes and edges independently. Edge selection never moves endpoints:
132
+
133
+ ```ts
134
+ import { c, getLayout } from "@statelyai/layout";
135
+
136
+ const result = await getLayout({
137
+ graph,
138
+ scope: {
139
+ mode: "partial",
140
+ edgeIds: ["ab", "bc"],
141
+ edgeGeometry: "labels",
142
+ routing: "selected",
143
+ },
144
+ constraints: [
145
+ c.align({
146
+ id: "label-centers",
147
+ entities: [
148
+ { edgeId: "ab", part: "label" },
149
+ { edgeId: "bc", part: "label" },
150
+ ],
151
+ axis: "x",
152
+ anchor: "center",
153
+ }),
154
+ ],
155
+ });
156
+ ```
157
+
158
+ `nodeIds` permits position changes; `edgeIds` permits routes, label positions,
159
+ or both. `routing: "affected"` (default) also repairs edges affected by moved
160
+ nodes, within `edgeGeometry` permissions. Unselected nodes, dimensions, ports,
161
+ and topology remain fixed. Results include field-specific graph patches and
162
+ repair/conflict diagnostics. Constraints support alignment, distribution, pins,
163
+ linear equalities/inequalities, and route waypoints.
164
+
165
+ See [authoring layout](docs/authoring-layout.md) for baseline requirements,
166
+ selection semantics, routing limits, and examples. Existing ELK compatibility
167
+ behavior is unchanged.
168
+
57
169
  ## elkjs compatibility
58
170
 
59
171
  <!-- elkjs-compatible entry point and layered mapping exports from package.json#exports and src/layered/index.ts -->
@@ -67,9 +179,29 @@ const elk = new ELK();
67
179
  const legacyResult = await elk.layout(elkJsonGraph);
68
180
  ```
69
181
 
182
+ Migration-compatible package aliases are also available for
183
+ `lib/main.js`, `lib/elk-api.js`, `lib/elk.bundled.js`, `lib/elk-worker.js`,
184
+ and `lib/elk-worker.min.js`. The worker entries implement elkjs's message
185
+ protocol in-process, including custom `workerFactory` construction and
186
+ termination. Both ESM imports and the original CommonJS `require()` style are
187
+ supported. Worker calls merge constructor defaults with per-layout overrides;
188
+ terminal worker errors reject pending and later requests.
189
+
70
190
  The adapter accepts ELK JSON and option aliases, translates to
71
191
  `@statelyai/graph`, runs native algorithms, and translates the result back.
72
- Native algorithms never consume ELK JSON directly.
192
+ Native algorithms never consume ELK JSON directly. `getLayout` and the
193
+ compatibility adapter dispatch through one typed internal engine; direct native
194
+ functions expose those same algorithm implementations. ELK-specific defaults
195
+ and quirks remain local to the pinned compatibility adapter.
196
+
197
+ Compatibility policies currently preserve exact elkjs 0.11.1 Random geometry
198
+ and Box SIMPLE geometry, including provider bounds and whether edge sections
199
+ are routed or left authored. Rectangle Packing has an exact default baseline;
200
+ its full Java packing strategy remains in progress.
201
+
202
+ The compatibility entry's named graph, edge, option, and result types are
203
+ mutually assignable with the declarations shipped by `elkjs@0.11.1`. Its
204
+ default class also accepts the library's broader internal graph inputs.
73
205
 
74
206
  <!-- fixed-port placement and inline center-label guarantees from src/layered/index.ts and src/layered/strategies.ts -->
75
207
 
@@ -153,13 +285,28 @@ pnpm install
153
285
  pnpm verify
154
286
  pnpm bench
155
287
  pnpm demo
288
+ pnpm storybook
156
289
  pnpm changeset
157
290
  pnpm release
158
291
  ```
159
292
 
160
293
  `pnpm verify` checks Oxfmt, Oxlint, source and repository TypeScript projects,
161
294
  generated layered-option and demo-corpus freshness, tests,
162
- declarations/runtime builds, the demo bundle, and the packed package surface.
295
+ declarations/runtime builds, demo and Storybook bundles, and the packed package surface.
296
+
297
+ <!-- authoring stories derived from stories/*.stories.tsx and package.json#scripts -->
298
+
299
+ `pnpm storybook` opens the authoring workbench at `http://127.0.0.1:6018`.
300
+ The **Layout / Partial selection** story starts with a fully laid-out graph.
301
+ Click nodes (or select the review branch), choose a direction, and press
302
+ **Auto-layout selection**. Unselected nodes remain fixed; dashed outlines show
303
+ previous positions. Reset restores the original full layout.
304
+
305
+ Eight additional stories cover edge-only routing, independently editable constraint groups,
306
+ selected-node placement, affected-route repair, constraint conflicts, overlap
307
+ diagnostics, nested coordinates, and unsupported incremental layout. Controls
308
+ rerun the real API; each story shows matched before/after geometry, patches, and
309
+ current limitations. `pnpm storybook:build` writes a static build to `dist-storybook`.
163
310
 
164
311
  <!-- exported source compatibility derived from tsconfig.json -->
165
312
 
@@ -0,0 +1,9 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ require('../layered-B2buJqMf.cjs');
3
+ const require_elkjs = require('../elkjs-dMghiiWW.cjs');
4
+
5
+ exports.compileStatechartLayout = require_elkjs.compileStatechartLayout;
6
+ exports.default = require_elkjs.ELK;
7
+ exports.getElkRoutes = require_elkjs.getElkRoutes;
8
+ exports.layoutStatechart = require_elkjs.layoutStatechart;
9
+ exports.scoreStatechartLayout = require_elkjs.scoreStatechartLayout;
@@ -0,0 +1,155 @@
1
+ import { _ as ElkShape, a as ElkEdgeSection, c as ElkLabel, d as ElkLayoutCategoryDescription, f as ElkLayoutOptionDescription, g as ElkPrimitiveEdge, h as ElkPort, i as ElkEdge, l as ElkLayoutAlgorithmDescription, m as ElkPoint, n as ELKConstructorArguments, o as ElkExtendedEdge, p as ElkNode, r as ElkCommonDescription, s as ElkGraphElement, t as ELK, u as ElkLayoutArguments, v as LaidOutElkNode, y as LayoutOptions } from "../public-types-BcRZoJE3.cjs";
2
+ import { r as Route } from "../types-uxPlGRof.cjs";
3
+
4
+ //#region src/elkjs/types.d.ts
5
+ type ElkId = string | number;
6
+ interface ElkGraphElement$1 {
7
+ id?: ElkId;
8
+ layoutOptions?: Record<string, unknown>;
9
+ properties?: Record<string, unknown>;
10
+ }
11
+ interface ElkPoint$1 {
12
+ x: number;
13
+ y: number;
14
+ }
15
+ interface ElkShape$1 extends ElkGraphElement$1 {
16
+ x?: number;
17
+ y?: number;
18
+ width?: number;
19
+ height?: number;
20
+ }
21
+ interface ElkLabel$1 extends ElkShape$1 {
22
+ text?: string;
23
+ }
24
+ interface ElkPort$1 extends ElkShape$1 {
25
+ labels?: ElkLabel$1[];
26
+ }
27
+ interface ElkEdgeSection$1 extends ElkGraphElement$1 {
28
+ startPoint: ElkPoint$1;
29
+ endPoint: ElkPoint$1;
30
+ bendPoints?: ElkPoint$1[];
31
+ incomingShape?: ElkId;
32
+ outgoingShape?: ElkId;
33
+ }
34
+ interface ElkEdge$1 extends ElkGraphElement$1 {
35
+ sources?: ElkId[];
36
+ targets?: ElkId[];
37
+ source?: ElkId;
38
+ target?: ElkId;
39
+ sourcePort?: ElkId;
40
+ targetPort?: ElkId;
41
+ labels?: ElkLabel$1[];
42
+ sections?: ElkEdgeSection$1[];
43
+ junctionPoints?: ElkPoint$1[];
44
+ }
45
+ interface ElkNode$1 extends ElkShape$1 {
46
+ labels?: ElkLabel$1[];
47
+ ports?: ElkPort$1[];
48
+ children?: ElkNode$1[];
49
+ edges?: ElkEdge$1[];
50
+ logging?: ElkLogging;
51
+ }
52
+ interface ElkLogging {
53
+ name?: string;
54
+ executionTime?: number;
55
+ logs?: string[];
56
+ children?: ElkLogging[];
57
+ }
58
+ interface ElkLayoutArguments$1 {
59
+ layoutOptions?: Record<string, unknown>;
60
+ logging?: boolean;
61
+ measureExecutionTime?: boolean;
62
+ }
63
+ interface ElkConstructorArguments {
64
+ defaultLayoutOptions?: Record<string, unknown>;
65
+ algorithms?: string[];
66
+ workerUrl?: string;
67
+ workerFactory?: (url?: string) => unknown;
68
+ }
69
+ interface ElkCommonDescription$1 {
70
+ id?: string;
71
+ name?: string;
72
+ description?: string;
73
+ }
74
+ interface ElkLayoutAlgorithmDescription$1 extends ElkCommonDescription$1 {
75
+ category?: string;
76
+ knownOptions?: string[];
77
+ supportedFeatures?: string[];
78
+ }
79
+ interface ElkLayoutOptionDescription$1 extends ElkCommonDescription$1 {
80
+ group?: string;
81
+ type?: string;
82
+ targets?: string[];
83
+ }
84
+ interface ElkLayoutCategoryDescription$1 extends ElkCommonDescription$1 {
85
+ knownLayouters?: string[];
86
+ }
87
+ type LaidOutElkNode$1<T extends ElkNode$1> = Omit<T, "children" | "edges"> & Omit<ElkNode$1, "children" | "edges"> & {
88
+ children?: Array<NonNullable<T["children"]>[number] & ElkNode$1>;
89
+ edges?: Array<NonNullable<T["edges"]>[number] & ElkEdge$1>;
90
+ };
91
+ //#endregion
92
+ //#region src/elkjs/statechart.d.ts
93
+ interface StatechartScope {
94
+ /** Direct child of this container; never inferred from state names. */
95
+ initialNodeId?: ElkId;
96
+ /** Connected direct-child path. Explicit paths resolve branching ambiguity. */
97
+ preferredPath?: readonly ElkId[];
98
+ direction?: "UP" | "DOWN" | "LEFT" | "RIGHT";
99
+ }
100
+ interface StatechartLayoutOptions {
101
+ scopes: Readonly<Record<string, StatechartScope>>;
102
+ /** Total engine calls, including baseline; integer from 1 to 3. Default 3. */
103
+ maxAttempts?: number;
104
+ }
105
+ interface StatechartLayoutScore {
106
+ invalid: number;
107
+ overlaps: number;
108
+ pathOrder: number;
109
+ crossings: number;
110
+ bends: number;
111
+ routeLength: number;
112
+ }
113
+ interface StatechartLayoutPlan {
114
+ graph: ElkNode$1;
115
+ paths: Record<string, ElkId[]>;
116
+ commonExits: Record<string, ElkId[]>;
117
+ }
118
+ /** Compile semantic hints into settings implemented by this package's ELK adapter. */
119
+ declare function compileStatechartLayout(input: ElkNode$1, scopes: StatechartLayoutOptions["scopes"]): StatechartLayoutPlan;
120
+ /** Diagnostic objective, not a proof of geometric validity. Coordinates are container-relative. */
121
+ declare function scoreStatechartLayout(graph: ElkNode$1, paths?: StatechartLayoutPlan["paths"]): StatechartLayoutScore;
122
+ /** Each attempt starts from original input. No post-layout geometry edits. */
123
+ declare function layoutStatechart<T extends ElkNode$1>(input: T, options: StatechartLayoutOptions): Promise<{
124
+ attempts: {
125
+ kind: "baseline" | "policy" | "spacing";
126
+ score: StatechartLayoutScore;
127
+ }[];
128
+ paths: Record<string, ElkId[]>;
129
+ commonExits: Record<string, ElkId[]>;
130
+ graph: LaidOutElkNode$1<T>;
131
+ score: StatechartLayoutScore;
132
+ attempt: number;
133
+ }>;
134
+ //#endregion
135
+ //#region src/elkjs/routes.d.ts
136
+ interface ElkRouteOptions {
137
+ /** ELK stores spline controls in bendPoints; the caller must identify that encoding. */
138
+ routing?: "ORTHOGONAL" | "POLYLINE" | "SPLINES";
139
+ }
140
+ /** Normalize any ELK layout's section geometry, preserving ports and hyperedge junctions. */
141
+ declare function getElkRoutes(graph: ElkNode, options?: ElkRouteOptions): ReadonlyMap<string, Route>;
142
+ //#endregion
143
+ //#region src/elkjs/index.d.ts
144
+ declare class ELK$1 {
145
+ #private;
146
+ constructor(options?: ElkConstructorArguments);
147
+ knownLayoutAlgorithms(): Promise<ElkLayoutAlgorithmDescription$1[]>;
148
+ knownLayoutOptions(): Promise<ElkLayoutOptionDescription$1[]>;
149
+ knownLayoutCategories(): Promise<ElkLayoutCategoryDescription$1[]>;
150
+ terminateWorker(): void;
151
+ layout<T extends ElkNode>(graph: T, arguments_?: ElkLayoutArguments): Promise<ElkNode & LaidOutElkNode<T>>;
152
+ layout<T extends ElkNode$1>(graph: T, arguments_?: ElkLayoutArguments$1): Promise<LaidOutElkNode$1<T>>;
153
+ }
154
+ //#endregion
155
+ export { type ELK, type ELKConstructorArguments, type ElkCommonDescription, type ElkEdge, type ElkEdgeSection, type ElkExtendedEdge, type ElkGraphElement, type ElkId, type ElkLabel, type ElkLayoutAlgorithmDescription, type ElkLayoutArguments, type ElkLayoutCategoryDescription, type ElkLayoutOptionDescription, type ElkLogging, type ElkNode, type ElkPoint, type ElkPort, type ElkPrimitiveEdge, type ElkRouteOptions, type ElkShape, type LaidOutElkNode, type LayoutOptions, type StatechartLayoutOptions, type StatechartLayoutPlan, type StatechartLayoutScore, type StatechartScope, compileStatechartLayout, ELK$1 as default, getElkRoutes, layoutStatechart, scoreStatechartLayout };
@@ -1,49 +1,52 @@
1
+ import { _ as ElkShape, a as ElkEdgeSection, c as ElkLabel, d as ElkLayoutCategoryDescription, f as ElkLayoutOptionDescription, g as ElkPrimitiveEdge, h as ElkPort, i as ElkEdge, l as ElkLayoutAlgorithmDescription, m as ElkPoint, n as ELKConstructorArguments, o as ElkExtendedEdge, p as ElkNode, r as ElkCommonDescription, s as ElkGraphElement, t as ELK, u as ElkLayoutArguments, v as LaidOutElkNode, y as LayoutOptions } from "../public-types-9NCPoqbp.mjs";
2
+ import { r as Route } from "../types-CT2akdK0.mjs";
3
+
1
4
  //#region src/elkjs/types.d.ts
2
5
  type ElkId = string | number;
3
- interface ElkGraphElement {
6
+ interface ElkGraphElement$1 {
4
7
  id?: ElkId;
5
8
  layoutOptions?: Record<string, unknown>;
6
9
  properties?: Record<string, unknown>;
7
10
  }
8
- interface ElkPoint {
11
+ interface ElkPoint$1 {
9
12
  x: number;
10
13
  y: number;
11
14
  }
12
- interface ElkShape extends ElkGraphElement {
15
+ interface ElkShape$1 extends ElkGraphElement$1 {
13
16
  x?: number;
14
17
  y?: number;
15
18
  width?: number;
16
19
  height?: number;
17
20
  }
18
- interface ElkLabel extends ElkShape {
21
+ interface ElkLabel$1 extends ElkShape$1 {
19
22
  text?: string;
20
23
  }
21
- interface ElkPort extends ElkShape {
22
- labels?: ElkLabel[];
24
+ interface ElkPort$1 extends ElkShape$1 {
25
+ labels?: ElkLabel$1[];
23
26
  }
24
- interface ElkEdgeSection extends ElkGraphElement {
25
- startPoint: ElkPoint;
26
- endPoint: ElkPoint;
27
- bendPoints?: ElkPoint[];
27
+ interface ElkEdgeSection$1 extends ElkGraphElement$1 {
28
+ startPoint: ElkPoint$1;
29
+ endPoint: ElkPoint$1;
30
+ bendPoints?: ElkPoint$1[];
28
31
  incomingShape?: ElkId;
29
32
  outgoingShape?: ElkId;
30
33
  }
31
- interface ElkEdge extends ElkGraphElement {
34
+ interface ElkEdge$1 extends ElkGraphElement$1 {
32
35
  sources?: ElkId[];
33
36
  targets?: ElkId[];
34
37
  source?: ElkId;
35
38
  target?: ElkId;
36
39
  sourcePort?: ElkId;
37
40
  targetPort?: ElkId;
38
- labels?: ElkLabel[];
39
- sections?: ElkEdgeSection[];
40
- junctionPoints?: ElkPoint[];
41
- }
42
- interface ElkNode extends ElkShape {
43
- labels?: ElkLabel[];
44
- ports?: ElkPort[];
45
- children?: ElkNode[];
46
- edges?: ElkEdge[];
41
+ labels?: ElkLabel$1[];
42
+ sections?: ElkEdgeSection$1[];
43
+ junctionPoints?: ElkPoint$1[];
44
+ }
45
+ interface ElkNode$1 extends ElkShape$1 {
46
+ labels?: ElkLabel$1[];
47
+ ports?: ElkPort$1[];
48
+ children?: ElkNode$1[];
49
+ edges?: ElkEdge$1[];
47
50
  logging?: ElkLogging;
48
51
  }
49
52
  interface ElkLogging {
@@ -52,7 +55,7 @@ interface ElkLogging {
52
55
  logs?: string[];
53
56
  children?: ElkLogging[];
54
57
  }
55
- interface ElkLayoutArguments {
58
+ interface ElkLayoutArguments$1 {
56
59
  layoutOptions?: Record<string, unknown>;
57
60
  logging?: boolean;
58
61
  measureExecutionTime?: boolean;
@@ -63,27 +66,27 @@ interface ElkConstructorArguments {
63
66
  workerUrl?: string;
64
67
  workerFactory?: (url?: string) => unknown;
65
68
  }
66
- interface ElkCommonDescription {
69
+ interface ElkCommonDescription$1 {
67
70
  id?: string;
68
71
  name?: string;
69
72
  description?: string;
70
73
  }
71
- interface ElkLayoutAlgorithmDescription extends ElkCommonDescription {
74
+ interface ElkLayoutAlgorithmDescription$1 extends ElkCommonDescription$1 {
72
75
  category?: string;
73
76
  knownOptions?: string[];
74
77
  supportedFeatures?: string[];
75
78
  }
76
- interface ElkLayoutOptionDescription extends ElkCommonDescription {
79
+ interface ElkLayoutOptionDescription$1 extends ElkCommonDescription$1 {
77
80
  group?: string;
78
81
  type?: string;
79
82
  targets?: string[];
80
83
  }
81
- interface ElkLayoutCategoryDescription extends ElkCommonDescription {
84
+ interface ElkLayoutCategoryDescription$1 extends ElkCommonDescription$1 {
82
85
  knownLayouters?: string[];
83
86
  }
84
- type LaidOutElkNode<T extends ElkNode> = Omit<T, "children" | "edges"> & Omit<ElkNode, "children" | "edges"> & {
85
- children?: Array<NonNullable<T["children"]>[number] & ElkNode>;
86
- edges?: Array<NonNullable<T["edges"]>[number] & ElkEdge>;
87
+ type LaidOutElkNode$1<T extends ElkNode$1> = Omit<T, "children" | "edges"> & Omit<ElkNode$1, "children" | "edges"> & {
88
+ children?: Array<NonNullable<T["children"]>[number] & ElkNode$1>;
89
+ edges?: Array<NonNullable<T["edges"]>[number] & ElkEdge$1>;
87
90
  };
88
91
  //#endregion
89
92
  //#region src/elkjs/statechart.d.ts
@@ -108,36 +111,45 @@ interface StatechartLayoutScore {
108
111
  routeLength: number;
109
112
  }
110
113
  interface StatechartLayoutPlan {
111
- graph: ElkNode;
114
+ graph: ElkNode$1;
112
115
  paths: Record<string, ElkId[]>;
113
116
  commonExits: Record<string, ElkId[]>;
114
117
  }
115
118
  /** Compile semantic hints into settings implemented by this package's ELK adapter. */
116
- declare function compileStatechartLayout(input: ElkNode, scopes: StatechartLayoutOptions["scopes"]): StatechartLayoutPlan;
119
+ declare function compileStatechartLayout(input: ElkNode$1, scopes: StatechartLayoutOptions["scopes"]): StatechartLayoutPlan;
117
120
  /** Diagnostic objective, not a proof of geometric validity. Coordinates are container-relative. */
118
- declare function scoreStatechartLayout(graph: ElkNode, paths?: StatechartLayoutPlan["paths"]): StatechartLayoutScore;
121
+ declare function scoreStatechartLayout(graph: ElkNode$1, paths?: StatechartLayoutPlan["paths"]): StatechartLayoutScore;
119
122
  /** Each attempt starts from original input. No post-layout geometry edits. */
120
- declare function layoutStatechart<T extends ElkNode>(input: T, options: StatechartLayoutOptions): Promise<{
123
+ declare function layoutStatechart<T extends ElkNode$1>(input: T, options: StatechartLayoutOptions): Promise<{
121
124
  attempts: {
122
125
  kind: "baseline" | "policy" | "spacing";
123
126
  score: StatechartLayoutScore;
124
127
  }[];
125
128
  paths: Record<string, ElkId[]>;
126
129
  commonExits: Record<string, ElkId[]>;
127
- graph: LaidOutElkNode<T>;
130
+ graph: LaidOutElkNode$1<T>;
128
131
  score: StatechartLayoutScore;
129
132
  attempt: number;
130
133
  }>;
131
134
  //#endregion
135
+ //#region src/elkjs/routes.d.ts
136
+ interface ElkRouteOptions {
137
+ /** ELK stores spline controls in bendPoints; the caller must identify that encoding. */
138
+ routing?: "ORTHOGONAL" | "POLYLINE" | "SPLINES";
139
+ }
140
+ /** Normalize any ELK layout's section geometry, preserving ports and hyperedge junctions. */
141
+ declare function getElkRoutes(graph: ElkNode, options?: ElkRouteOptions): ReadonlyMap<string, Route>;
142
+ //#endregion
132
143
  //#region src/elkjs/index.d.ts
133
- declare class ELK {
144
+ declare class ELK$1 {
134
145
  #private;
135
146
  constructor(options?: ElkConstructorArguments);
136
- knownLayoutAlgorithms(): Promise<ElkLayoutAlgorithmDescription[]>;
137
- knownLayoutOptions(): Promise<ElkLayoutOptionDescription[]>;
138
- knownLayoutCategories(): Promise<ElkLayoutCategoryDescription[]>;
147
+ knownLayoutAlgorithms(): Promise<ElkLayoutAlgorithmDescription$1[]>;
148
+ knownLayoutOptions(): Promise<ElkLayoutOptionDescription$1[]>;
149
+ knownLayoutCategories(): Promise<ElkLayoutCategoryDescription$1[]>;
139
150
  terminateWorker(): void;
140
- layout<T extends ElkNode>(graph: T, arguments_?: ElkLayoutArguments): Promise<LaidOutElkNode<T>>;
151
+ layout<T extends ElkNode>(graph: T, arguments_?: ElkLayoutArguments): Promise<ElkNode & LaidOutElkNode<T>>;
152
+ layout<T extends ElkNode$1>(graph: T, arguments_?: ElkLayoutArguments$1): Promise<LaidOutElkNode$1<T>>;
141
153
  }
142
154
  //#endregion
143
- export { type ElkCommonDescription, type ElkConstructorArguments, type ElkEdge, type ElkEdgeSection, type ElkGraphElement, type ElkId, type ElkLabel, type ElkLayoutAlgorithmDescription, type ElkLayoutArguments, type ElkLayoutCategoryDescription, type ElkLayoutOptionDescription, type ElkLogging, type ElkNode, type ElkPoint, type ElkPort, type ElkShape, type LaidOutElkNode, type StatechartLayoutOptions, type StatechartLayoutPlan, type StatechartLayoutScore, type StatechartScope, compileStatechartLayout, ELK as default, layoutStatechart, scoreStatechartLayout };
155
+ export { type ELK, type ELKConstructorArguments, type ElkCommonDescription, type ElkEdge, type ElkEdgeSection, type ElkExtendedEdge, type ElkGraphElement, type ElkId, type ElkLabel, type ElkLayoutAlgorithmDescription, type ElkLayoutArguments, type ElkLayoutCategoryDescription, type ElkLayoutOptionDescription, type ElkLogging, type ElkNode, type ElkPoint, type ElkPort, type ElkPrimitiveEdge, type ElkRouteOptions, type ElkShape, type LaidOutElkNode, type LayoutOptions, type StatechartLayoutOptions, type StatechartLayoutPlan, type StatechartLayoutScore, type StatechartScope, compileStatechartLayout, ELK$1 as default, getElkRoutes, layoutStatechart, scoreStatechartLayout };