@statelyai/layout 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -161,6 +161,11 @@ pnpm release
161
161
  generated layered-option and demo-corpus freshness, tests,
162
162
  declarations/runtime builds, the demo bundle, and the packed package surface.
163
163
 
164
+ <!-- exported source compatibility derived from tsconfig.json -->
165
+
166
+ The source project checks indexed reads with `noUncheckedIndexedAccess` so
167
+ published TypeScript source supports consumers using that option.
168
+
164
169
  ## Releases
165
170
 
166
171
  <!-- release process derived from package.json#scripts and .changeset/config.json -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/layout",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Extensible, graph-native layout algorithms for @statelyai/graph",
5
5
  "license": "EPL-2.0 OR GPL-3.0-or-later",
6
6
  "repository": {
@@ -98,16 +98,16 @@ export function compileStatechartLayout(
98
98
  }
99
99
  if (scope.preferredPath) {
100
100
  for (let i = 1; i < path.length; i++) {
101
- if (!successors.get(path[i - 1])?.has(path[i]))
101
+ if (!successors.get(path[i - 1]!)?.has(path[i]!))
102
102
  throw new Error(`Disconnected preferred path in ${id}`);
103
103
  }
104
104
  } else {
105
105
  while (path.length) {
106
- const next = [...successors.get(path.at(-1))!].filter(
106
+ const next = [...successors.get(path.at(-1)!)!].filter(
107
107
  (nodeId) => !path.includes(nodeId) && !exits.includes(nodeId),
108
108
  );
109
109
  if (next.length !== 1) break;
110
- path.push(next[0]);
110
+ path.push(next[0]!);
111
111
  }
112
112
  }
113
113
  paths[id] = path;
@@ -214,8 +214,8 @@ export function scoreStatechartLayout(
214
214
  for (const point of points)
215
215
  if (!Number.isFinite(point.x) || !Number.isFinite(point.y)) score.invalid++;
216
216
  for (let i = 1; i < points.length; i++) {
217
- const a = { x: x + points[i - 1].x, y: y + points[i - 1].y };
218
- const b = { x: x + points[i].x, y: y + points[i].y };
217
+ const a = { x: x + points[i - 1]!.x, y: y + points[i - 1]!.y };
218
+ const b = { x: x + points[i]!.x, y: y + points[i]!.y };
219
219
  score.routeLength += Math.hypot(b.x - a.x, b.y - a.y);
220
220
  segments.push({ a, b, edge });
221
221
  }
@@ -225,16 +225,16 @@ export function scoreStatechartLayout(
225
225
  visit(graph, 0, 0, [graph]);
226
226
  for (let i = 0; i < boxes.length; i++)
227
227
  for (let j = i + 1; j < boxes.length; j++) {
228
- const a = boxes[i],
229
- b = boxes[j];
228
+ const a = boxes[i]!,
229
+ b = boxes[j]!;
230
230
  if ((a.node && b.ancestors.includes(a.node)) || (b.node && a.ancestors.includes(b.node)))
231
231
  continue;
232
232
  if (intersects(a.rect, b.rect)) score.overlaps++;
233
233
  }
234
234
  for (let i = 0; i < segments.length; i++)
235
235
  for (let j = i + 1; j < segments.length; j++) {
236
- const a = segments[i],
237
- b = segments[j];
236
+ const a = segments[i]!,
237
+ b = segments[j]!;
238
238
  if (a.edge === b.edge) continue;
239
239
  if (
240
240
  cross(a.a, a.b, b.a) * cross(a.a, a.b, b.b) < 0 &&
@@ -303,7 +303,7 @@ export async function layoutStatechart<T extends ElkNode>(
303
303
  }
304
304
  for (const group of groups.values())
305
305
  for (let i = 1; i < Math.min(group.length, 3); i++) {
306
- const edge = group[i];
306
+ const edge = group[i]!;
307
307
  if (
308
308
  option(edge, "edgeLabels.placement") === undefined &&
309
309
  edge.labels!.every((label) => option(label, "edgeLabels.placement") === undefined)