@willcgage/module-schematic 0.90.0 → 0.91.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/dist/index.cjs CHANGED
@@ -2410,6 +2410,7 @@ function snapPiece(moving, others, library = BUILT_IN_TRACK_PARTS, withinInches
2410
2410
  to: best.t.key
2411
2411
  };
2412
2412
  }
2413
+ var danglingDivergeWarning = (id) => `the route diverging at ${id} is not connected to anything`;
2413
2414
  function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS) {
2414
2415
  const byKey = new Map(graph.joints.map((j) => [j.key, j]));
2415
2416
  const pieceById = new Map(pieces.map((p) => [p.id, p]));
@@ -2430,6 +2431,7 @@ function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS)
2430
2431
  const routes = [];
2431
2432
  const turnouts = [];
2432
2433
  const warnings = [];
2434
+ const danglingDiverges = [];
2433
2435
  const queued = /* @__PURE__ */ new Set();
2434
2436
  const pending = [];
2435
2437
  const walk = (startKey, startPos, id, bornAt) => {
@@ -2520,7 +2522,8 @@ function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS)
2520
2522
  const b = pending.shift();
2521
2523
  const start = link.get(b.joint);
2522
2524
  if (!start) {
2523
- warnings.push(`the route diverging at ${b.from} is not connected to anything`);
2525
+ warnings.push(danglingDivergeWarning(b.from));
2526
+ danglingDiverges.push(b.from);
2524
2527
  continue;
2525
2528
  }
2526
2529
  const already = routes.find((r2) => r2.pieces.includes(byKey.get(start).piece));
@@ -2541,7 +2544,7 @@ function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS)
2541
2544
  if (!reached.has(p.id) && !graph.unplaceable.some((u) => u.piece === p.id))
2542
2545
  warnings.push(`${p.id} is not reachable from the endplate \u2014 nothing connects it`);
2543
2546
  for (const c of graph.conflicts) warnings.push(c.reason);
2544
- return { routes, turnouts, warnings };
2547
+ return { routes, turnouts, warnings, danglingDiverges };
2545
2548
  }
2546
2549
  function resolveGraphAnchor(anchor, walk, pieces, library = BUILT_IN_TRACK_PARTS) {
2547
2550
  const piece = pieces.find((p) => p.id === anchor.piece);
@@ -2562,7 +2565,8 @@ function graphToDoc(pieces, input) {
2562
2565
  const library = input.library ?? BUILT_IN_TRACK_PARTS;
2563
2566
  const graph = buildTrackGraph(pieces, library);
2564
2567
  const walk = walkTrackGraph(graph, pieces, input.startAt, library);
2565
- const warnings = [...walk.warnings];
2568
+ const dangling = new Set(walk.danglingDiverges.map(danglingDivergeWarning));
2569
+ const warnings = walk.warnings.filter((w) => !dangling.has(w));
2566
2570
  const round = (n) => Math.round(n * 100) / 100;
2567
2571
  const base = input.base ?? {};
2568
2572
  const endplates = base.endplates && base.endplates.length ? base.endplates : [{ id: "A", label: "West" }, { id: "B", label: "East" }];