@statelyai/layout 0.0.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/LICENSE.md +264 -0
- package/NOTICE.md +10 -0
- package/README.md +140 -0
- package/dist/elkjs/index.d.mts +97 -0
- package/dist/elkjs/index.mjs +412 -0
- package/dist/index-v0P1Ake8.d.mts +149 -0
- package/dist/index.d.mts +77 -0
- package/dist/index.mjs +139 -0
- package/dist/layered/index.d.mts +2 -0
- package/dist/layered/index.mjs +3 -0
- package/dist/layered-ByNCZQgJ.mjs +439 -0
- package/dist/spore-cihb_Aht.mjs +487 -0
- package/package.json +61 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Eclipse Public License - v 2.0
|
|
2
|
+
|
|
3
|
+
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
|
|
4
|
+
PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF
|
|
5
|
+
THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
|
|
6
|
+
|
|
7
|
+
## 1. DEFINITIONS
|
|
8
|
+
|
|
9
|
+
“Contribution” means:
|
|
10
|
+
|
|
11
|
+
- a\) in the case of the initial Contributor, the initial content
|
|
12
|
+
Distributed under this Agreement, and
|
|
13
|
+
- b\) in the case of each subsequent Contributor:
|
|
14
|
+
- i\) changes to the Program, and
|
|
15
|
+
- ii\) additions to the Program;
|
|
16
|
+
|
|
17
|
+
where such changes and/or additions to the Program originate from
|
|
18
|
+
and are Distributed by that particular Contributor. A Contribution
|
|
19
|
+
“originates” from a Contributor if it was added to the Program by
|
|
20
|
+
such Contributor itself or anyone acting on such Contributor's
|
|
21
|
+
behalf. Contributions do not include changes or additions to the
|
|
22
|
+
Program that are not Modified Works.
|
|
23
|
+
|
|
24
|
+
“Contributor” means any person or entity that Distributes the Program.
|
|
25
|
+
|
|
26
|
+
“Licensed Patents” mean patent claims licensable by a Contributor which
|
|
27
|
+
are necessarily infringed by the use or sale of its Contribution alone
|
|
28
|
+
or when combined with the Program.
|
|
29
|
+
|
|
30
|
+
“Program” means the Contributions Distributed in accordance with this
|
|
31
|
+
Agreement.
|
|
32
|
+
|
|
33
|
+
“Recipient” means anyone who receives the Program under this Agreement
|
|
34
|
+
or any Secondary License (as applicable), including Contributors.
|
|
35
|
+
|
|
36
|
+
“Derivative Works” shall mean any work, whether in Source Code or other
|
|
37
|
+
form, that is based on (or derived from) the Program and for which the
|
|
38
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
39
|
+
represent, as a whole, an original work of authorship.
|
|
40
|
+
|
|
41
|
+
“Modified Works” shall mean any work in Source Code or other form that
|
|
42
|
+
results from an addition to, deletion from, or modification of the
|
|
43
|
+
contents of the Program, including, for purposes of clarity any new file
|
|
44
|
+
in Source Code form that contains any contents of the Program. Modified
|
|
45
|
+
Works shall not include works that contain only declarations,
|
|
46
|
+
interfaces, types, classes, structures, or files of the Program solely
|
|
47
|
+
in each case in order to link to, bind by name, or subclass the Program
|
|
48
|
+
or Modified Works thereof.
|
|
49
|
+
|
|
50
|
+
“Distribute” means the acts of a) distributing or b) making available in
|
|
51
|
+
any manner that enables the transfer of a copy.
|
|
52
|
+
|
|
53
|
+
“Source Code” means the form of a Program preferred for making
|
|
54
|
+
modifications, including but not limited to software source code,
|
|
55
|
+
documentation source, and configuration files.
|
|
56
|
+
|
|
57
|
+
“Secondary License” means either the GNU General Public License, Version
|
|
58
|
+
2.0, or any later versions of that license, including any exceptions or
|
|
59
|
+
additional permissions as identified by the initial Contributor.
|
|
60
|
+
|
|
61
|
+
## 2. GRANT OF RIGHTS
|
|
62
|
+
|
|
63
|
+
- a\) Subject to the terms of this Agreement, each Contributor hereby
|
|
64
|
+
grants Recipient a non-exclusive, worldwide, royalty-free copyright
|
|
65
|
+
license to reproduce, prepare Derivative Works of, publicly display,
|
|
66
|
+
publicly perform, Distribute and sublicense the Contribution of such
|
|
67
|
+
Contributor, if any, and such Derivative Works.
|
|
68
|
+
- b\) Subject to the terms of this Agreement, each Contributor hereby
|
|
69
|
+
grants Recipient a non-exclusive, worldwide, royalty-free patent license
|
|
70
|
+
under Licensed Patents to make, use, sell, offer to sell, import and
|
|
71
|
+
otherwise transfer the Contribution of such Contributor, if any, in
|
|
72
|
+
Source Code or other form. This patent license shall apply to the
|
|
73
|
+
combination of the Contribution and the Program if, at the time the
|
|
74
|
+
Contribution is added by the Contributor, such addition of the
|
|
75
|
+
Contribution causes such combination to be covered by the
|
|
76
|
+
Licensed Patents. The patent license shall not apply to any other
|
|
77
|
+
combinations which include the Contribution. No hardware per se is
|
|
78
|
+
licensed hereunder.
|
|
79
|
+
- c\) Recipient understands that although each Contributor grants the
|
|
80
|
+
licenses to its Contributions set forth herein, no assurances are
|
|
81
|
+
provided by any Contributor that the Program does not infringe the
|
|
82
|
+
patent or other intellectual property rights of any other entity. Each
|
|
83
|
+
Contributor disclaims any liability to Recipient for claims brought by
|
|
84
|
+
any other entity based on infringement of intellectual property rights
|
|
85
|
+
or otherwise. As a condition to exercising the rights and licenses
|
|
86
|
+
granted hereunder, each Recipient hereby assumes sole responsibility to
|
|
87
|
+
secure any other intellectual property rights needed, if any. For
|
|
88
|
+
example, if a third party patent license is required to allow Recipient
|
|
89
|
+
to Distribute the Program, it is Recipient's responsibility to acquire
|
|
90
|
+
that license before distributing the Program.
|
|
91
|
+
- d\) Each Contributor represents that to its knowledge it has sufficient
|
|
92
|
+
copyright rights in its Contribution, if any, to grant the copyright
|
|
93
|
+
license set forth in this Agreement.
|
|
94
|
+
- e\) Notwithstanding the terms of any Secondary License, no Contributor
|
|
95
|
+
makes additional grants to any Recipient (other than those set forth in
|
|
96
|
+
this Agreement) as a result of such Recipient's receipt of the Program
|
|
97
|
+
under the terms of a Secondary License (if permitted under the terms of
|
|
98
|
+
Section 3).
|
|
99
|
+
|
|
100
|
+
## 3. REQUIREMENTS
|
|
101
|
+
|
|
102
|
+
3.1 If a Contributor Distributes the Program in any form, then:
|
|
103
|
+
|
|
104
|
+
- a\) the Program must also be made available as Source Code, in accordance
|
|
105
|
+
with section 3.2, and the Contributor must accompany the Program with a
|
|
106
|
+
statement that the Source Code for the Program is available under this
|
|
107
|
+
Agreement, and informs Recipients how to obtain it in a reasonable
|
|
108
|
+
manner on or through a medium customarily used for software exchange;
|
|
109
|
+
and
|
|
110
|
+
- b\) the Contributor may Distribute the Program under a license different
|
|
111
|
+
than this Agreement, provided that such license:
|
|
112
|
+
- i\) effectively disclaims on behalf of all other Contributors all
|
|
113
|
+
warranties and conditions, express and implied, including warranties or
|
|
114
|
+
conditions of title and non-infringement, and implied warranties or
|
|
115
|
+
conditions of merchantability and fitness for a particular purpose;
|
|
116
|
+
- ii\) effectively excludes on behalf of all other Contributors all
|
|
117
|
+
liability for damages, including direct, indirect, special, incidental
|
|
118
|
+
and consequential damages, such as lost profits;
|
|
119
|
+
- iii\) does not attempt to limit or alter the recipients' rights in the
|
|
120
|
+
Source Code under section 3.2; and
|
|
121
|
+
- iv\) requires any subsequent distribution of the Program by any party to
|
|
122
|
+
be under a license that satisfies the requirements of this section 3.
|
|
123
|
+
|
|
124
|
+
3.2 When the Program is Distributed as Source Code:
|
|
125
|
+
|
|
126
|
+
- a\) it must be made available under this Agreement, or if the Program (i)
|
|
127
|
+
is combined with other material in a separate file or files made
|
|
128
|
+
available under a Secondary License, and (ii) the initial Contributor
|
|
129
|
+
attached to the Source Code the notice described in Exhibit A of this
|
|
130
|
+
Agreement, then the Program may be made available under the terms of
|
|
131
|
+
such Secondary Licenses, and
|
|
132
|
+
- b\) a copy of this Agreement must be included with each copy of
|
|
133
|
+
the Program.
|
|
134
|
+
|
|
135
|
+
3.3 Contributors may not remove or alter any copyright, patent,
|
|
136
|
+
trademark, attribution notices, disclaimers of warranty, or limitations
|
|
137
|
+
of liability (‘notices’) contained within the Program from any copy of
|
|
138
|
+
the Program which they Distribute, provided that Contributors may add
|
|
139
|
+
their own appropriate notices.
|
|
140
|
+
|
|
141
|
+
## 4. COMMERCIAL DISTRIBUTION
|
|
142
|
+
|
|
143
|
+
Commercial distributors of software may accept certain responsibilities
|
|
144
|
+
with respect to end users, business partners and the like. While this
|
|
145
|
+
license is intended to facilitate the commercial use of the Program, the
|
|
146
|
+
Contributor who includes the Program in a commercial product offering
|
|
147
|
+
should do so in a manner which does not create potential liability for
|
|
148
|
+
other Contributors. Therefore, if a Contributor includes the Program in
|
|
149
|
+
a commercial product offering, such Contributor (“Commercial
|
|
150
|
+
Contributor”) hereby agrees to defend and indemnify every other
|
|
151
|
+
Contributor (“Indemnified Contributor”) against any losses, damages and
|
|
152
|
+
costs (collectively “Losses”) arising from claims, lawsuits and other
|
|
153
|
+
legal actions brought by a third party against the Indemnified
|
|
154
|
+
Contributor to the extent caused by the acts or omissions of such
|
|
155
|
+
Commercial Contributor in connection with its distribution of the
|
|
156
|
+
Program in a commercial product offering. The obligations in this
|
|
157
|
+
section do not apply to any claims or Losses relating to any actual or
|
|
158
|
+
alleged intellectual property infringement. In order to qualify, an
|
|
159
|
+
Indemnified Contributor must: a) promptly notify the Commercial
|
|
160
|
+
Contributor in writing of such claim, and b) allow the Commercial
|
|
161
|
+
Contributor to control, and cooperate with the Commercial Contributor
|
|
162
|
+
in, the defense and any related settlement negotiations. The Indemnified
|
|
163
|
+
Contributor may participate in any such claim at its own expense.
|
|
164
|
+
|
|
165
|
+
For example, a Contributor might include the Program in a commercial
|
|
166
|
+
product offering, Product X. That Contributor is then a Commercial
|
|
167
|
+
Contributor. If that Commercial Contributor then makes performance
|
|
168
|
+
claims, or offers warranties related to Product X, those performance
|
|
169
|
+
claims and warranties are such Commercial Contributor's responsibility
|
|
170
|
+
alone. Under this section, the Commercial Contributor would have to
|
|
171
|
+
defend claims against the other Contributors related to those
|
|
172
|
+
performance claims and warranties, and if a court requires any other
|
|
173
|
+
Contributor to pay any damages as a result, the Commercial Contributor
|
|
174
|
+
must pay those damages.
|
|
175
|
+
|
|
176
|
+
## 5. NO WARRANTY {#warranty}
|
|
177
|
+
|
|
178
|
+
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
|
|
179
|
+
PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS”
|
|
180
|
+
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
|
|
181
|
+
IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
|
|
182
|
+
TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
|
|
183
|
+
PURPOSE. Each Recipient is solely responsible for determining the
|
|
184
|
+
appropriateness of using and distributing the Program and assumes all
|
|
185
|
+
risks associated with its exercise of rights under this Agreement,
|
|
186
|
+
including but not limited to the risks and costs of program errors,
|
|
187
|
+
compliance with applicable laws, damage to or loss of data, programs or
|
|
188
|
+
equipment, and unavailability or interruption of operations.
|
|
189
|
+
|
|
190
|
+
## 6. DISCLAIMER OF LIABILITY {#disclaimer}
|
|
191
|
+
|
|
192
|
+
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
|
|
193
|
+
PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
|
|
194
|
+
SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
195
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
|
|
196
|
+
PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
197
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
198
|
+
ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
|
|
199
|
+
EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
|
|
200
|
+
POSSIBILITY OF SUCH DAMAGES.
|
|
201
|
+
|
|
202
|
+
## 7. GENERAL
|
|
203
|
+
|
|
204
|
+
If any provision of this Agreement is invalid or unenforceable under
|
|
205
|
+
applicable law, it shall not affect the validity or enforceability of
|
|
206
|
+
the remainder of the terms of this Agreement, and without further action
|
|
207
|
+
by the parties hereto, such provision shall be reformed to the minimum
|
|
208
|
+
extent necessary to make such provision valid and enforceable.
|
|
209
|
+
|
|
210
|
+
If Recipient institutes patent litigation against any entity (including
|
|
211
|
+
a cross-claim or counterclaim in a lawsuit) alleging that the Program
|
|
212
|
+
itself (excluding combinations of the Program with other software or
|
|
213
|
+
hardware) infringes such Recipient's patent(s), then such Recipient's
|
|
214
|
+
rights granted under Section 2(b) shall terminate as of the date such
|
|
215
|
+
litigation is filed.
|
|
216
|
+
|
|
217
|
+
All Recipient's rights under this Agreement shall terminate if it fails
|
|
218
|
+
to comply with any of the material terms or conditions of this Agreement
|
|
219
|
+
and does not cure such failure in a reasonable period of time after
|
|
220
|
+
becoming aware of such noncompliance. If all Recipient's rights under
|
|
221
|
+
this Agreement terminate, Recipient agrees to cease use and distribution
|
|
222
|
+
of the Program as soon as reasonably practicable. However, Recipient's
|
|
223
|
+
obligations under this Agreement and any licenses granted by Recipient
|
|
224
|
+
relating to the Program shall continue and survive.
|
|
225
|
+
|
|
226
|
+
Everyone is permitted to copy and distribute copies of this Agreement,
|
|
227
|
+
but in order to avoid inconsistency the Agreement is copyrighted and may
|
|
228
|
+
only be modified in the following manner. The Agreement Steward reserves
|
|
229
|
+
the right to publish new versions (including revisions) of this
|
|
230
|
+
Agreement from time to time. No one other than the Agreement Steward has
|
|
231
|
+
the right to modify this Agreement. The Eclipse Foundation is the
|
|
232
|
+
initial Agreement Steward. The Eclipse Foundation may assign the
|
|
233
|
+
responsibility to serve as the Agreement Steward to a suitable separate
|
|
234
|
+
entity. Each new version of the Agreement will be given a distinguishing
|
|
235
|
+
version number. The Program (including Contributions) may always be
|
|
236
|
+
Distributed subject to the version of the Agreement under which it was
|
|
237
|
+
received. In addition, after a new version of the Agreement is
|
|
238
|
+
published, Contributor may elect to Distribute the Program (including
|
|
239
|
+
its Contributions) under the new version.
|
|
240
|
+
|
|
241
|
+
Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
|
|
242
|
+
receives no rights or licenses to the intellectual property of any
|
|
243
|
+
Contributor under this Agreement, whether expressly, by implication,
|
|
244
|
+
estoppel or otherwise. All rights in the Program not expressly granted
|
|
245
|
+
under this Agreement are reserved. Nothing in this Agreement is intended
|
|
246
|
+
to be enforceable by any entity that is not a Contributor or Recipient.
|
|
247
|
+
No third-party beneficiary rights are created under this Agreement.
|
|
248
|
+
|
|
249
|
+
## Exhibit A – Form of Secondary Licenses Notice {#exhibit-a}
|
|
250
|
+
|
|
251
|
+
“This Source Code may also be made available under the following
|
|
252
|
+
Secondary Licenses when the conditions for such availability set forth
|
|
253
|
+
in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
|
|
254
|
+
version(s), and exceptions or additional permissions here}.”
|
|
255
|
+
|
|
256
|
+
> Simply including a copy of this Agreement, including this Exhibit A is
|
|
257
|
+
> not sufficient to license the Source Code under Secondary Licenses.
|
|
258
|
+
>
|
|
259
|
+
> If it is not possible or desirable to put the notice in a particular
|
|
260
|
+
> file, then You may include the notice in a location (such as a LICENSE
|
|
261
|
+
> file in a relevant directory) where a recipient would be likely to
|
|
262
|
+
> look for such a notice.
|
|
263
|
+
>
|
|
264
|
+
> You may add additional accurate notices of copyright ownership.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Notices for Stately Layout
|
|
2
|
+
|
|
3
|
+
This project is a native TypeScript implementation of graph layout algorithms
|
|
4
|
+
and uses `@statelyai/graph` as its public graph model.
|
|
5
|
+
|
|
6
|
+
The project intends to implement algorithms available in the Eclipse Layout
|
|
7
|
+
Kernel. Eclipse Layout Kernel is maintained by the ELK contributors and is a
|
|
8
|
+
trademark of the Eclipse Foundation. See https://github.com/eclipse-elk/elk.
|
|
9
|
+
|
|
10
|
+
No Eclipse Layout Kernel source has been copied into the initial implementation.
|
package/README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# @statelyai/layout
|
|
2
|
+
|
|
3
|
+
Native TypeScript graph layout algorithms built directly on
|
|
4
|
+
[`@statelyai/graph`](https://github.com/statelyai/graph).
|
|
5
|
+
|
|
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`.
|
|
9
|
+
|
|
10
|
+
## Status
|
|
11
|
+
|
|
12
|
+
The native layered implementation currently supports flat graphs, cycles,
|
|
13
|
+
ports, self-loops, four directions, typed constraints, padding, orthogonal
|
|
14
|
+
routes, and replaceable phases. Native fixed, rectangle-packing, and initial
|
|
15
|
+
SPOrE implementations are also available. ELK Box SIMPLE placement and seeded
|
|
16
|
+
Random node placement are translated from Java. Partial, incremental,
|
|
17
|
+
route-only, and native compound layout remain explicit unimplemented
|
|
18
|
+
capabilities.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
<!-- install command derived from package.json#name -->
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add @statelyai/layout @statelyai/graph
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
<!-- primary layout functions exported from src/index.ts -->
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { createGraph } from "@statelyai/graph";
|
|
34
|
+
import { getLayeredLayout, getLayout } from "@statelyai/layout";
|
|
35
|
+
|
|
36
|
+
const graph = createGraph({
|
|
37
|
+
nodes: [{ id: "a" }, { id: "b" }],
|
|
38
|
+
edges: [{ id: "ab", sourceId: "a", targetId: "b" }],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const visualGraph = getLayeredLayout(graph, { direction: "right" });
|
|
42
|
+
|
|
43
|
+
const result = await getLayout({
|
|
44
|
+
graph,
|
|
45
|
+
algorithm: "layered",
|
|
46
|
+
options: { direction: "right" },
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
result.graph;
|
|
50
|
+
result.patches;
|
|
51
|
+
result.diagnostics;
|
|
52
|
+
result.metrics;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## elkjs compatibility
|
|
56
|
+
|
|
57
|
+
<!-- elkjs-compatible entry point exported from package.json#exports -->
|
|
58
|
+
|
|
59
|
+
Legacy consumers can migrate through an isolated compatibility entry point:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import ELK from "@statelyai/layout/elkjs";
|
|
63
|
+
|
|
64
|
+
const elk = new ELK();
|
|
65
|
+
const legacyResult = await elk.layout(elkJsonGraph);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The adapter accepts ELK JSON and option aliases, translates to
|
|
69
|
+
`@statelyai/graph`, runs native algorithms, and translates the result back.
|
|
70
|
+
Native algorithms never consume ELK JSON directly.
|
|
71
|
+
|
|
72
|
+
## Parity lab
|
|
73
|
+
|
|
74
|
+
<!-- representative graph count and engines from demo/scenarios.ts -->
|
|
75
|
+
|
|
76
|
+
The browser lab compares 15 already-laid-out graphs in two renderers: a
|
|
77
|
+
coordinate-faithful SVG geometry inspector and the `@statelyai/sdk` project
|
|
78
|
+
embed. It covers all 11 algorithm families exposed by the elkjs 0.11.1
|
|
79
|
+
demonstrator surface plus cycle, long-edge, named-port, and compound layered
|
|
80
|
+
cases. Native and oracle-backed graphs are labeled separately; elkjs is never
|
|
81
|
+
bundled into the browser.
|
|
82
|
+
|
|
83
|
+
The SVG layer displays exact node dimensions and coordinates, edge label
|
|
84
|
+
rectangles, route points, routing modes, and node-relative ports. The SDK layer
|
|
85
|
+
then shows how the same serialized `@statelyai/graph` value appears in the Viz
|
|
86
|
+
project view.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pnpm demo:generate
|
|
90
|
+
pnpm demo
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The embed target defaults to `http://localhost:3000`. Override it with
|
|
94
|
+
`?editor=http://localhost:4864` when the Viz editor runs elsewhere.
|
|
95
|
+
|
|
96
|
+

|
|
97
|
+
|
|
98
|
+
## Extensibility
|
|
99
|
+
|
|
100
|
+
<!-- layered strategy fields from src/layered/types.ts -->
|
|
101
|
+
|
|
102
|
+
Layered phases are replaceable independently:
|
|
103
|
+
|
|
104
|
+
- `breakCycles`
|
|
105
|
+
- `assignLayers`
|
|
106
|
+
- `minimizeCrossings`
|
|
107
|
+
- `placeNodes`
|
|
108
|
+
- `routeEdges`
|
|
109
|
+
|
|
110
|
+
Strategies exchange typed artifacts keyed by graph entity IDs. They never
|
|
111
|
+
convert the public graph into an ELK-shaped API.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
const result = getLayeredLayout(graph, {
|
|
115
|
+
strategies: {
|
|
116
|
+
routeEdges(input, orientation, placement) {
|
|
117
|
+
return myRouter(input, orientation, placement);
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
See [Architecture](./docs/architecture.md), [Roadmap](./docs/roadmap.md), and
|
|
124
|
+
[Upstream and provenance](./docs/upstream.md). [Parity](./docs/parity.md) tracks
|
|
125
|
+
API coverage separately from native algorithm fidelity.
|
|
126
|
+
|
|
127
|
+
## Development
|
|
128
|
+
|
|
129
|
+
<!-- scripts derived from package.json#scripts -->
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
pnpm install
|
|
133
|
+
pnpm verify
|
|
134
|
+
pnpm bench
|
|
135
|
+
pnpm demo
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`pnpm verify` checks Oxfmt, Oxlint, source and repository TypeScript projects,
|
|
139
|
+
generated corpus freshness, tests, declarations/runtime builds, the demo
|
|
140
|
+
bundle, and the packed package surface.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//#region src/elkjs/types.d.ts
|
|
2
|
+
type ElkId = string | number;
|
|
3
|
+
interface ElkGraphElement {
|
|
4
|
+
id?: ElkId;
|
|
5
|
+
layoutOptions?: Record<string, unknown>;
|
|
6
|
+
properties?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
interface ElkPoint {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}
|
|
12
|
+
interface ElkShape extends ElkGraphElement {
|
|
13
|
+
x?: number;
|
|
14
|
+
y?: number;
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
}
|
|
18
|
+
interface ElkLabel extends ElkShape {
|
|
19
|
+
text?: string;
|
|
20
|
+
}
|
|
21
|
+
interface ElkPort extends ElkShape {
|
|
22
|
+
labels?: ElkLabel[];
|
|
23
|
+
}
|
|
24
|
+
interface ElkEdgeSection extends ElkGraphElement {
|
|
25
|
+
startPoint: ElkPoint;
|
|
26
|
+
endPoint: ElkPoint;
|
|
27
|
+
bendPoints?: ElkPoint[];
|
|
28
|
+
}
|
|
29
|
+
interface ElkEdge extends ElkGraphElement {
|
|
30
|
+
sources?: ElkId[];
|
|
31
|
+
targets?: ElkId[];
|
|
32
|
+
source?: ElkId;
|
|
33
|
+
target?: ElkId;
|
|
34
|
+
sourcePort?: ElkId;
|
|
35
|
+
targetPort?: ElkId;
|
|
36
|
+
labels?: ElkLabel[];
|
|
37
|
+
sections?: ElkEdgeSection[];
|
|
38
|
+
}
|
|
39
|
+
interface ElkNode extends ElkShape {
|
|
40
|
+
labels?: ElkLabel[];
|
|
41
|
+
ports?: ElkPort[];
|
|
42
|
+
children?: ElkNode[];
|
|
43
|
+
edges?: ElkEdge[];
|
|
44
|
+
logging?: ElkLogging;
|
|
45
|
+
}
|
|
46
|
+
interface ElkLogging {
|
|
47
|
+
name?: string;
|
|
48
|
+
executionTime?: number;
|
|
49
|
+
logs?: string[];
|
|
50
|
+
children?: ElkLogging[];
|
|
51
|
+
}
|
|
52
|
+
interface ElkLayoutArguments {
|
|
53
|
+
layoutOptions?: Record<string, unknown>;
|
|
54
|
+
logging?: boolean;
|
|
55
|
+
measureExecutionTime?: boolean;
|
|
56
|
+
}
|
|
57
|
+
interface ElkConstructorArguments {
|
|
58
|
+
defaultLayoutOptions?: Record<string, unknown>;
|
|
59
|
+
algorithms?: string[];
|
|
60
|
+
workerUrl?: string;
|
|
61
|
+
workerFactory?: (url?: string) => unknown;
|
|
62
|
+
}
|
|
63
|
+
interface ElkCommonDescription {
|
|
64
|
+
id?: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
}
|
|
68
|
+
interface ElkLayoutAlgorithmDescription extends ElkCommonDescription {
|
|
69
|
+
category?: string;
|
|
70
|
+
knownOptions?: string[];
|
|
71
|
+
supportedFeatures?: string[];
|
|
72
|
+
}
|
|
73
|
+
interface ElkLayoutOptionDescription extends ElkCommonDescription {
|
|
74
|
+
group?: string;
|
|
75
|
+
type?: string;
|
|
76
|
+
targets?: string[];
|
|
77
|
+
}
|
|
78
|
+
interface ElkLayoutCategoryDescription extends ElkCommonDescription {
|
|
79
|
+
knownLayouters?: string[];
|
|
80
|
+
}
|
|
81
|
+
type LaidOutElkNode<T extends ElkNode> = Omit<T, "children" | "edges"> & Omit<ElkNode, "children" | "edges"> & {
|
|
82
|
+
children?: Array<NonNullable<T["children"]>[number] & ElkNode>;
|
|
83
|
+
edges?: Array<NonNullable<T["edges"]>[number] & ElkEdge>;
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/elkjs/index.d.ts
|
|
87
|
+
declare class ELK {
|
|
88
|
+
#private;
|
|
89
|
+
constructor(options?: ElkConstructorArguments);
|
|
90
|
+
knownLayoutAlgorithms(): Promise<ElkLayoutAlgorithmDescription[]>;
|
|
91
|
+
knownLayoutOptions(): Promise<ElkLayoutOptionDescription[]>;
|
|
92
|
+
knownLayoutCategories(): Promise<ElkLayoutCategoryDescription[]>;
|
|
93
|
+
terminateWorker(): void;
|
|
94
|
+
layout<T extends ElkNode>(graph: T, arguments_?: ElkLayoutArguments): Promise<LaidOutElkNode<T>>;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
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, ELK as default };
|