@opsydyn/foldkit-zloz-elk 0.0.0-stage → 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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ ## [0.3.0](https://github.com/opsydyn/fold-kit-experiments/compare/foldkit-zloz-elk-v0.2.0...foldkit-zloz-elk-v0.3.0) (2026-11-10)
4
+
5
+ ### Miscellaneous Chores
6
+
7
+ - **foldkit-zloz-elk:** Synchronize foldkit-zloz versions
8
+
9
+ ## [0.2.0](https://github.com/opsydyn/fold-kit-experiments/compare/foldkit-zloz-elk-v0.1.1...foldkit-zloz-elk-v0.2.0) (2026-11-09)
10
+
11
+ ### Miscellaneous Chores
12
+
13
+ - **foldkit-zloz-elk:** Synchronize foldkit-zloz versions
14
+
15
+ ## [0.1.1](https://github.com/opsydyn/fold-kit-experiments/compare/foldkit-zloz-elk-v0.1.0...foldkit-zloz-elk-v0.1.1) (2026-11-09)
16
+
17
+ ### Miscellaneous Chores
18
+
19
+ - **foldkit-zloz-elk:** Synchronize foldkit-zloz versions
20
+
21
+ ## 0.1.0 (unreleased)
22
+
23
+ - Route fixed boundary projections and rejoin canonical custom anchors.
24
+
25
+ - Add a separately installable ELK Layered adapter with fixed port positions,
26
+ variable node sizes, orthogonal routes and caller-owned worker support.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alan P Currie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,69 @@
1
- # Temporary Holding Version
1
+ # Foldkit Zloz ELK
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Optional automatic layout for `@opsydyn/foldkit-zloz`. The adapter maps flat and nested graphs with fixed ports to ELK Layered. It returns node
4
+ positions, fitted group bounds, and orthogonal edge routes. It owns no UI, persistence, graph state or workflow execution.
5
+
6
+ Version 0.1.0 is a local release candidate; npm publication has not been performed.
7
+
8
+ ## Install and use
9
+
10
+ After publication:
11
+
12
+ ```sh
13
+ npm install @opsydyn/foldkit-zloz @opsydyn/foldkit-zloz-elk
14
+ ```
15
+
16
+ ```ts
17
+ import { createEditor, layoutRequest, applyLayout } from '@opsydyn/foldkit-zloz';
18
+ import { createElkLayout } from '@opsydyn/foldkit-zloz-elk';
19
+
20
+ const editor = createEditor({ nodes: [], edges: [] });
21
+ const active = layoutRequest(editor, 'arrange-1');
22
+ const layout = createElkLayout({ direction: 'RIGHT', spacing: 64 });
23
+ const result = await layout(active); // Run this work in a FoldKit Command.
24
+ const arranged = applyLayout(editor, active, result);
25
+ ```
26
+
27
+ In an asynchronous application, the completion handler must use the **current**
28
+ editor and active request from the Model. Never capture those old values and write
29
+ them back on completion. Clear active requests on document replacement.
30
+
31
+ The default direction is RIGHT; DOWN is also supported. Node sizes and authored
32
+ port anchors remain authoritative. Legacy side/offset ports keep their
33
+ positions. Custom anchors are projected onto their declared side for ELK, then
34
+ route leads join back to the exact authored points. User IDs are mapped to independent internal IDs.
35
+ Input snapshots are not mutated. Engine failures reject the Promise; missing node
36
+ positions or invalid routes reject with `ZlozError` rather than inventing geometry.
37
+
38
+ ## Worker ownership
39
+
40
+ The default bundled ELK runs **in process** and creates a fresh instance for each
41
+ call. Its Promise does not move computation off the UI thread. For larger graphs,
42
+ construct a worker-backed ELK instance using your bundler's worker configuration
43
+ and pass it as `createElkLayout({ elk })`. The caller owns and terminates that worker.
44
+ The adapter never terminates caller-owned resources. Command interruption alone
45
+ does not cancel ELK computation; request/revision checks prevent late publication.
46
+ See [ELK's worker documentation](https://github.com/kieler/elkjs#web-worker).
47
+
48
+ ELK is an external dependency, not bundled into this package. The core package
49
+ installs and works without it. Node 22+, ESM only. Initial compatibility is Zloz
50
+ 0.1.0 and the pinned elkjs 0.12.1. Both Zloz packages release at the same version.
51
+ The adapter has no FoldKit or Effect peer.
52
+
53
+ The default adapter is qualified in Node and Chromium. Bun can compute layouts,
54
+ but elkjs 0.12.1's bundled fallback installs a global `self.onmessage` handler in
55
+ Bun 1.4.4, keeping a standalone process alive after completion. Use Node for CLI
56
+ layout jobs. The dependency-free core is separately tested in both Node and Bun.
57
+
58
+ ## Scope and verification
59
+
60
+ Compound layout preserves group membership and routes directed edges across
61
+ boundaries. Zloz edges connect one source to one target. Compare representative
62
+ diagrams before upgrading ELK, since layout may vary by version.
63
+
64
+ Run `bun run --filter @opsydyn/foldkit-zloz-elk test`, `typecheck` and `pack:check`.
65
+ The core's packed consumer test installs both tarballs through npm and exercises
66
+ real layout plus the optional FoldKit renderer.
67
+
68
+ See [publication standards](https://github.com/opsydyn/fold-kit-experiments/blob/main/docs/releases/foldkit-zloz.md) and
69
+ [dependency notices](THIRD-PARTY-NOTICES.md).
@@ -0,0 +1,13 @@
1
+ # Third-party notices
2
+
3
+ This package depends on the unmodified `elkjs` 0.12.1 npm package, distributed
4
+ separately by npm. Its declared licence is `EPL-2.0 OR GPL-3.0-or-later`; the EPL-2.0
5
+ option applies to this integration. Preserve upstream notices when redistributing
6
+ or bundling that dependency. The adapter's own source is MIT licensed.
7
+
8
+ ELK upstream: <https://github.com/kieler/elkjs>
9
+
10
+ ELK source and licensing: <https://github.com/kieler/elkjs/blob/master/LICENSE.md>
11
+
12
+ ELK is generated from the Eclipse Layout Kernel; its complete dependency notices
13
+ remain in the upstream package. This adapter does not modify or vendor ELK code.
@@ -0,0 +1,14 @@
1
+ import { LayoutEngine } from "@opsydyn/foldkit-zloz";
2
+ import { ELK } from "elkjs/lib/elk-api.js";
3
+
4
+ //#region src/index.d.ts
5
+ type ElkLayoutOptions = Readonly<{
6
+ direction?: 'RIGHT' | 'DOWN';
7
+ spacing?: number; /** Supply a worker-backed instance when needed; the caller owns its lifetime. */
8
+ elk?: Pick<ELK, 'layout'>;
9
+ }>;
10
+ /** Default invocations use in-process ELK. Caller-supplied worker instances remain caller-owned. */
11
+ declare function createElkLayout(options?: ElkLayoutOptions): LayoutEngine;
12
+ //#endregion
13
+ export { ElkLayoutOptions, createElkLayout };
14
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,169 @@
1
+ import { ZlozError, portBoundaryPosition, portPosition, validateGraph } from "@opsydyn/foldkit-zloz";
2
+ import ELK from "elkjs/lib/elk.bundled.js";
3
+ //#region src/index.ts
4
+ /**
5
+ * Optional ELK layout adapter; the host owns request publication and worker lifetime.
6
+ * @module ELK
7
+ */
8
+ function routePoints(sections, edgeId) {
9
+ const byId = new Map(sections.map((section) => [section.id, section]));
10
+ const visited = /* @__PURE__ */ new Set();
11
+ const points = [];
12
+ let current = sections.find((section) => !section.incomingSections?.length);
13
+ while (current && !visited.has(current.id)) {
14
+ visited.add(current.id);
15
+ const previous = points.at(-1);
16
+ if (previous && (Math.abs(previous.x - current.startPoint.x) > 1e-6 || Math.abs(previous.y - current.startPoint.y) > 1e-6)) break;
17
+ if (!previous) points.push(current.startPoint);
18
+ for (const bend of current.bendPoints ?? []) points.push(bend);
19
+ points.push(current.endPoint);
20
+ const outgoing = current.outgoingSections ?? [];
21
+ if (outgoing.length === 0 && visited.size === sections.length) return points.map(({ x, y }) => ({
22
+ x,
23
+ y
24
+ }));
25
+ const next = outgoing[0];
26
+ if (outgoing.length !== 1 || next === void 0) break;
27
+ current = byId.get(next);
28
+ }
29
+ throw new ZlozError("invalid-layout", `ELK omitted a continuous route for ${edgeId}`);
30
+ }
31
+ /** Default invocations use in-process ELK. Caller-supplied worker instances remain caller-owned. */
32
+ function createElkLayout(options = {}) {
33
+ const spacing = options.spacing ?? 64;
34
+ if (!Number.isFinite(spacing) || spacing <= 0) throw new ZlozError("invalid-layout", "Layout spacing must be positive and finite");
35
+ return async (request) => {
36
+ validateGraph(request.graph);
37
+ const nodeIds = new Map(request.graph.nodes.map((node, index) => [node.id, `n:${index}`]));
38
+ const portIds = /* @__PURE__ */ new Map();
39
+ const hasGroups = request.graph.nodes.some((node) => node.kind === "group");
40
+ const children = [];
41
+ const elkNodes = new Map(request.graph.nodes.map((node, index) => {
42
+ if (node.kind === "group") return [node.id, {
43
+ id: `n:${index}`,
44
+ width: node.size.width,
45
+ height: node.size.height,
46
+ children: [],
47
+ layoutOptions: { "elk.padding": "[top=52,left=24,bottom=24,right=24]" }
48
+ }];
49
+ const ports = new Map(node.ports.map((port, at) => [port.id, `p:${index}:${at}`]));
50
+ portIds.set(node.id, ports);
51
+ return [node.id, {
52
+ id: `n:${index}`,
53
+ width: node.size.width,
54
+ height: node.size.height,
55
+ layoutOptions: { "elk.portConstraints": "FIXED_POS" },
56
+ ports: node.ports.map((port) => {
57
+ const point = portBoundaryPosition(node, port.id);
58
+ const side = {
59
+ left: "WEST",
60
+ right: "EAST",
61
+ top: "NORTH",
62
+ bottom: "SOUTH"
63
+ }[port.side];
64
+ return {
65
+ id: ports.get(port.id) ?? "",
66
+ width: 0,
67
+ height: 0,
68
+ x: point.x - node.position.x,
69
+ y: point.y - node.position.y,
70
+ layoutOptions: { "elk.port.side": side }
71
+ };
72
+ })
73
+ }];
74
+ }));
75
+ for (const node of request.graph.nodes) {
76
+ const elkNode = elkNodes.get(node.id);
77
+ if (!elkNode) throw new ZlozError("invalid-layout", `Missing input elkNode for ${node.id}`);
78
+ const siblings = node.parentId === void 0 ? children : elkNodes.get(node.parentId)?.children;
79
+ if (!siblings) throw new ZlozError("invalid-layout", `Missing parent elkNode for ${node.id}`);
80
+ siblings.push(elkNode);
81
+ }
82
+ const graph = {
83
+ id: "graph",
84
+ layoutOptions: {
85
+ "elk.algorithm": "layered",
86
+ "elk.hierarchyHandling": hasGroups ? "INCLUDE_CHILDREN" : "SEPARATE_CHILDREN",
87
+ "elk.json.shapeCoords": "ROOT",
88
+ "elk.json.edgeCoords": "ROOT",
89
+ "elk.direction": options.direction ?? "RIGHT",
90
+ "elk.edgeRouting": "ORTHOGONAL",
91
+ "elk.spacing.nodeNode": String(spacing),
92
+ "elk.layered.spacing.nodeNodeBetweenLayers": String(spacing)
93
+ },
94
+ children,
95
+ edges: request.graph.edges.map((edge, index) => ({
96
+ id: `e:${index}`,
97
+ sources: [portIds.get(edge.source.node)?.get(edge.source.port) ?? ""],
98
+ targets: [portIds.get(edge.target.node)?.get(edge.target.port) ?? ""]
99
+ }))
100
+ };
101
+ const result = await (options.elk ?? new ELK()).layout(graph);
102
+ const laidOutNodes = /* @__PURE__ */ new Map();
103
+ const laidOutEdges = /* @__PURE__ */ new Map();
104
+ const pending = [result];
105
+ while (pending.length > 0) {
106
+ const node = pending.pop();
107
+ if (!node) break;
108
+ laidOutNodes.set(node.id, node);
109
+ for (const edge of node.edges ?? []) laidOutEdges.set(edge.id, edge.sections ?? []);
110
+ for (const child of node.children ?? []) pending.push(child);
111
+ }
112
+ const positions = request.graph.nodes.map((node) => {
113
+ const laidOut = laidOutNodes.get(nodeIds.get(node.id) ?? "");
114
+ if (!laidOut || !Number.isFinite(laidOut.x) || !Number.isFinite(laidOut.y) || laidOut.x === void 0 || laidOut.y === void 0) throw new ZlozError("invalid-layout", `ELK omitted position for ${node.id}`);
115
+ const position = {
116
+ id: node.id,
117
+ x: laidOut.x,
118
+ y: laidOut.y
119
+ };
120
+ if (node.kind !== "group") return position;
121
+ const { width, height } = laidOut;
122
+ if (width === void 0 || height === void 0 || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) throw new ZlozError("invalid-layout", `ELK returned invalid bounds for ${node.id}`);
123
+ return {
124
+ ...position,
125
+ size: {
126
+ width,
127
+ height
128
+ }
129
+ };
130
+ });
131
+ const routes = request.graph.edges.map((edge, index) => {
132
+ const points = routePoints(laidOutEdges.get(`e:${index}`) ?? [], edge.id);
133
+ if (!points.every((point) => Number.isFinite(point.x) && Number.isFinite(point.y))) throw new ZlozError("invalid-layout", `ELK returned an invalid route for ${edge.id}`);
134
+ const sourceNode = request.graph.nodes.find((node) => node.id === edge.source.node);
135
+ const targetNode = request.graph.nodes.find((node) => node.id === edge.target.node);
136
+ const sourcePosition = positions.find((position) => position.id === edge.source.node);
137
+ const targetPosition = positions.find((position) => position.id === edge.target.node);
138
+ if (!sourceNode || !targetNode || !sourcePosition || !targetPosition) throw new ZlozError("invalid-layout", "Missing routed endpoint");
139
+ const anchored = [
140
+ portPosition({
141
+ ...sourceNode,
142
+ position: sourcePosition
143
+ }, edge.source.port),
144
+ ...points,
145
+ portPosition({
146
+ ...targetNode,
147
+ position: targetPosition
148
+ }, edge.target.port)
149
+ ];
150
+ return {
151
+ id: edge.id,
152
+ points: anchored.filter((point, index) => {
153
+ const previous = anchored[index - 1];
154
+ return !previous || previous.x !== point.x || previous.y !== point.y;
155
+ })
156
+ };
157
+ });
158
+ return {
159
+ requestId: request.requestId,
160
+ revision: request.revision,
161
+ positions,
162
+ routes
163
+ };
164
+ };
165
+ }
166
+ //#endregion
167
+ export { createElkLayout };
168
+
169
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Optional ELK layout adapter; the host owns request publication and worker lifetime.\n * @module ELK\n */\nimport {\n ZlozError,\n portPosition,\n portBoundaryPosition,\n validateGraph,\n type EdgeRoute,\n type LayoutEngine,\n} from '@opsydyn/foldkit-zloz';\nimport type { ELK as ElkInstance, ElkNode, ElkEdgeSection } from 'elkjs/lib/elk-api';\nimport ELK from 'elkjs/lib/elk.bundled.js';\n\nexport type ElkLayoutOptions = Readonly<{\n direction?: 'RIGHT' | 'DOWN';\n spacing?: number;\n /** Supply a worker-backed instance when needed; the caller owns its lifetime. */\n elk?: Pick<ElkInstance, 'layout'>;\n}>;\n\nfunction routePoints(sections: readonly ElkEdgeSection[], edgeId: string): EdgeRoute['points'] {\n const byId = new Map(sections.map((section) => [section.id, section]));\n const visited = new Set<string>();\n const points: Array<{ x: number; y: number }> = [];\n let current = sections.find((section) => !section.incomingSections?.length);\n while (current && !visited.has(current.id)) {\n visited.add(current.id);\n const previous = points.at(-1);\n if (\n previous &&\n (Math.abs(previous.x - current.startPoint.x) > 1e-6 ||\n Math.abs(previous.y - current.startPoint.y) > 1e-6)\n )\n break;\n if (!previous) points.push(current.startPoint);\n for (const bend of current.bendPoints ?? []) points.push(bend);\n points.push(current.endPoint);\n const outgoing = current.outgoingSections ?? [];\n if (outgoing.length === 0 && visited.size === sections.length)\n return points.map(({ x, y }) => ({ x, y }));\n const next = outgoing[0];\n if (outgoing.length !== 1 || next === undefined) break;\n current = byId.get(next);\n }\n throw new ZlozError('invalid-layout', `ELK omitted a continuous route for ${edgeId}`);\n}\n\n/** Default invocations use in-process ELK. Caller-supplied worker instances remain caller-owned. */\nexport function createElkLayout(options: ElkLayoutOptions = {}): LayoutEngine {\n const spacing = options.spacing ?? 64;\n if (!Number.isFinite(spacing) || spacing <= 0)\n throw new ZlozError('invalid-layout', 'Layout spacing must be positive and finite');\n return async (request) => {\n validateGraph(request.graph);\n const nodeIds = new Map(request.graph.nodes.map((node, index) => [node.id, `n:${index}`]));\n const portIds = new Map<string, Map<string, string>>();\n const hasGroups = request.graph.nodes.some((node) => node.kind === 'group');\n const children: ElkNode[] = [];\n const elkNodes = new Map(\n request.graph.nodes.map((node, index): [string, ElkNode] => {\n if (node.kind === 'group')\n return [\n node.id,\n {\n id: `n:${index}`,\n width: node.size.width,\n height: node.size.height,\n children: [],\n layoutOptions: { 'elk.padding': '[top=52,left=24,bottom=24,right=24]' },\n },\n ];\n const ports = new Map(node.ports.map((port, at) => [port.id, `p:${index}:${at}`]));\n portIds.set(node.id, ports);\n return [\n node.id,\n {\n id: `n:${index}`,\n width: node.size.width,\n height: node.size.height,\n layoutOptions: { 'elk.portConstraints': 'FIXED_POS' },\n ports: node.ports.map((port) => {\n const point = portBoundaryPosition(node, port.id);\n const side = { left: 'WEST', right: 'EAST', top: 'NORTH', bottom: 'SOUTH' }[\n port.side\n ];\n return {\n id: ports.get(port.id) ?? '',\n width: 0,\n height: 0,\n x: point.x - node.position.x,\n y: point.y - node.position.y,\n layoutOptions: { 'elk.port.side': side },\n };\n }),\n },\n ];\n }),\n );\n for (const node of request.graph.nodes) {\n const elkNode = elkNodes.get(node.id);\n if (!elkNode) throw new ZlozError('invalid-layout', `Missing input elkNode for ${node.id}`);\n const siblings =\n node.parentId === undefined ? children : elkNodes.get(node.parentId)?.children;\n if (!siblings) throw new ZlozError('invalid-layout', `Missing parent elkNode for ${node.id}`);\n siblings.push(elkNode);\n }\n const graph: ElkNode = {\n id: 'graph',\n layoutOptions: {\n 'elk.algorithm': 'layered',\n 'elk.hierarchyHandling': hasGroups ? 'INCLUDE_CHILDREN' : 'SEPARATE_CHILDREN',\n 'elk.json.shapeCoords': 'ROOT',\n 'elk.json.edgeCoords': 'ROOT',\n 'elk.direction': options.direction ?? 'RIGHT',\n 'elk.edgeRouting': 'ORTHOGONAL',\n 'elk.spacing.nodeNode': String(spacing),\n 'elk.layered.spacing.nodeNodeBetweenLayers': String(spacing),\n },\n children,\n edges: request.graph.edges.map((edge, index) => ({\n id: `e:${index}`,\n sources: [portIds.get(edge.source.node)?.get(edge.source.port) ?? ''],\n targets: [portIds.get(edge.target.node)?.get(edge.target.port) ?? ''],\n })),\n };\n const elk = options.elk ?? new ELK();\n const result = await elk.layout(graph);\n const laidOutNodes = new Map<string, ElkNode>();\n const laidOutEdges = new Map<string, ElkEdgeSection[]>();\n const pending = [result];\n while (pending.length > 0) {\n const node = pending.pop();\n if (!node) break;\n laidOutNodes.set(node.id, node);\n for (const edge of node.edges ?? []) laidOutEdges.set(edge.id, edge.sections ?? []);\n for (const child of node.children ?? []) pending.push(child);\n }\n const positions = request.graph.nodes.map((node) => {\n const laidOut = laidOutNodes.get(nodeIds.get(node.id) ?? '');\n if (\n !laidOut ||\n !Number.isFinite(laidOut.x) ||\n !Number.isFinite(laidOut.y) ||\n laidOut.x === undefined ||\n laidOut.y === undefined\n )\n throw new ZlozError('invalid-layout', `ELK omitted position for ${node.id}`);\n const position = { id: node.id, x: laidOut.x, y: laidOut.y };\n if (node.kind !== 'group') return position;\n const { width, height } = laidOut;\n if (\n width === undefined ||\n height === undefined ||\n !Number.isFinite(width) ||\n !Number.isFinite(height) ||\n width <= 0 ||\n height <= 0\n )\n throw new ZlozError('invalid-layout', `ELK returned invalid bounds for ${node.id}`);\n return { ...position, size: { width, height } };\n });\n const routes: EdgeRoute[] = request.graph.edges.map((edge, index) => {\n const sections = laidOutEdges.get(`e:${index}`) ?? [];\n const points = routePoints(sections, edge.id);\n if (!points.every((point) => Number.isFinite(point.x) && Number.isFinite(point.y)))\n throw new ZlozError('invalid-layout', `ELK returned an invalid route for ${edge.id}`);\n const sourceNode = request.graph.nodes.find((node) => node.id === edge.source.node);\n const targetNode = request.graph.nodes.find((node) => node.id === edge.target.node);\n const sourcePosition = positions.find((position) => position.id === edge.source.node);\n const targetPosition = positions.find((position) => position.id === edge.target.node);\n if (!sourceNode || !targetNode || !sourcePosition || !targetPosition)\n throw new ZlozError('invalid-layout', 'Missing routed endpoint');\n const anchored = [\n portPosition({ ...sourceNode, position: sourcePosition }, edge.source.port),\n ...points,\n portPosition({ ...targetNode, position: targetPosition }, edge.target.port),\n ];\n return {\n id: edge.id,\n points: anchored.filter((point, index) => {\n const previous = anchored[index - 1];\n return !previous || previous.x !== point.x || previous.y !== point.y;\n }),\n };\n });\n return { requestId: request.requestId, revision: request.revision, positions, routes };\n };\n}\n"],"mappings":";;;;;;;AAsBA,SAAS,YAAY,UAAqC,QAAqC;CAC7F,MAAM,OAAO,IAAI,IAAI,SAAS,KAAK,YAAY,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC;CACtE,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,SAA0C,EAAE;CAClD,IAAI,UAAU,SAAS,MAAM,YAAY,CAAC,QAAQ,kBAAkB,OAAO;AAC3E,QAAO,WAAW,CAAC,QAAQ,IAAI,QAAQ,GAAG,EAAE;AAC1C,UAAQ,IAAI,QAAQ,GAAG;EACvB,MAAM,WAAW,OAAO,GAAG,GAAG;AAC9B,MACE,aACC,KAAK,IAAI,SAAS,IAAI,QAAQ,WAAW,EAAE,GAAG,QAC7C,KAAK,IAAI,SAAS,IAAI,QAAQ,WAAW,EAAE,GAAG,MAEhD;AACF,MAAI,CAAC,SAAU,QAAO,KAAK,QAAQ,WAAW;AAC9C,OAAK,MAAM,QAAQ,QAAQ,cAAc,EAAE,CAAE,QAAO,KAAK,KAAK;AAC9D,SAAO,KAAK,QAAQ,SAAS;EAC7B,MAAM,WAAW,QAAQ,oBAAoB,EAAE;AAC/C,MAAI,SAAS,WAAW,KAAK,QAAQ,SAAS,SAAS,OACrD,QAAO,OAAO,KAAK,EAAE,GAAG,SAAS;GAAE;GAAG;GAAG,EAAE;EAC7C,MAAM,OAAO,SAAS;AACtB,MAAI,SAAS,WAAW,KAAK,SAAS,KAAA,EAAW;AACjD,YAAU,KAAK,IAAI,KAAK;;AAE1B,OAAM,IAAI,UAAU,kBAAkB,sCAAsC,SAAS;;;AAIvF,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AAK,OAAO,KAAK;GACnF,MAAM,aAAa,QAAQ,MAAM,MAAM,MAAM,SAAS,KAAK,OAAO,KAAK,OAAO,KAAK;GACnF,MAAM,iBAAiB,UAAU,MAAM,aAAa,SAAS,OAAO,KAAK,OAAO,KAAK;GACrF,MAAM,iBAAiB,UAAU,MAAM,aAAa,SAAS,OAAO,KAAK,OAAO,KAAK;AACrF,OAAI,CAAC,cAAc,CAAC,cAAc,CAAC,kBAAkB,CAAC,eACpD,OAAM,IAAI,UAAU,kBAAkB,0BAA0B;GAClE,MAAM,WAAW;IACf,aAAa;KAAE,GAAG;KAAY,UAAU;KAAgB,EAAE,KAAK,OAAO,KAAK;IAC3E,GAAG;IACH,aAAa;KAAE,GAAG;KAAY,UAAU;KAAgB,EAAE,KAAK,OAAO,KAAK;IAC5E;AACD,UAAO;IACL,IAAI,KAAK;IACT,QAAQ,SAAS,QAAQ,OAAO,UAAU;KACxC,MAAM,WAAW,SAAS,QAAQ;AAClC,YAAO,CAAC,YAAY,SAAS,MAAM,MAAM,KAAK,SAAS,MAAM,MAAM;MACnE;IACH;IACD;AACF,SAAO;GAAE,WAAW,QAAQ;GAAW,UAAU,QAAQ;GAAU;GAAW;GAAQ"}
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@opsydyn/foldkit-zloz-elk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "Optional ELK layout adapter for Foldkit Zloz.",
5
+ "keywords": [
6
+ "diagram",
7
+ "flow",
8
+ "foldkit",
9
+ "graph",
10
+ "typescript"
11
+ ],
12
+ "homepage": "https://github.com/opsydyn/fold-kit-experiments/tree/main/packages/foldkit-zloz-elk#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/opsydyn/fold-kit-experiments/issues"
15
+ },
16
+ "license": "MIT",
17
+ "author": "Alan P Currie",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/opsydyn/fold-kit-experiments.git",
21
+ "directory": "packages/foldkit-zloz-elk"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "CHANGELOG.md",
27
+ "LICENSE",
28
+ "THIRD-PARTY-NOTICES.md",
29
+ "!dist/pack"
30
+ ],
31
+ "type": "module",
32
+ "sideEffects": false,
33
+ "main": "./dist/index.mjs",
34
+ "types": "./dist/index.d.mts",
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/index.d.mts",
38
+ "import": "./dist/index.mjs"
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "build": "bun run --filter @opsydyn/foldkit-zloz build && tsdown",
47
+ "typecheck": "bun run --filter @opsydyn/foldkit-zloz build && tsc --noEmit",
48
+ "test": "bun test ./test",
49
+ "pack:check": "bun run build && publint && bun ../../tools/pack-zloz.ts foldkit-zloz-elk"
50
+ },
51
+ "dependencies": {
52
+ "elkjs": "0.12.1"
53
+ },
54
+ "devDependencies": {
55
+ "@arethetypeswrong/cli": "0.18.5",
56
+ "@opsydyn/foldkit-zloz": "0.3.0",
57
+ "@types/node": "^22.0.0",
58
+ "bun-types": "^1.3.14",
59
+ "publint": "0.3.25",
60
+ "tsdown": "^0.21.8",
61
+ "typescript": "^6.0.3"
62
+ },
63
+ "peerDependencies": {
64
+ "@opsydyn/foldkit-zloz": "0.3.0"
65
+ },
66
+ "engines": {
67
+ "node": ">=22.0.0"
68
+ }
69
+ }