@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.d.cts CHANGED
@@ -2597,6 +2597,10 @@ interface GraphWalk {
2597
2597
  turnouts: GraphTurnout[];
2598
2598
  /** Every reason this walk is not the whole layout. */
2599
2599
  warnings: string[];
2600
+ /** Turnouts whose diverging route reaches nothing — the ids, not just the
2601
+ * sentence, so a caller can act on it (and say it ONCE) instead of matching
2602
+ * on prose. */
2603
+ danglingDiverges: string[];
2600
2604
  }
2601
2605
  /**
2602
2606
  * Walk the graph from an endplate and read the topology off it.
package/dist/index.d.ts CHANGED
@@ -2597,6 +2597,10 @@ interface GraphWalk {
2597
2597
  turnouts: GraphTurnout[];
2598
2598
  /** Every reason this walk is not the whole layout. */
2599
2599
  warnings: string[];
2600
+ /** Turnouts whose diverging route reaches nothing — the ids, not just the
2601
+ * sentence, so a caller can act on it (and say it ONCE) instead of matching
2602
+ * on prose. */
2603
+ danglingDiverges: string[];
2600
2604
  }
2601
2605
  /**
2602
2606
  * Walk the graph from an endplate and read the topology off it.
package/dist/index.js CHANGED
@@ -2408,6 +2408,7 @@ function snapPiece(moving, others, library = BUILT_IN_TRACK_PARTS, withinInches
2408
2408
  to: best.t.key
2409
2409
  };
2410
2410
  }
2411
+ var danglingDivergeWarning = (id) => `the route diverging at ${id} is not connected to anything`;
2411
2412
  function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS) {
2412
2413
  const byKey = new Map(graph.joints.map((j) => [j.key, j]));
2413
2414
  const pieceById = new Map(pieces.map((p) => [p.id, p]));
@@ -2428,6 +2429,7 @@ function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS)
2428
2429
  const routes = [];
2429
2430
  const turnouts = [];
2430
2431
  const warnings = [];
2432
+ const danglingDiverges = [];
2431
2433
  const queued = /* @__PURE__ */ new Set();
2432
2434
  const pending = [];
2433
2435
  const walk = (startKey, startPos, id, bornAt) => {
@@ -2518,7 +2520,8 @@ function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS)
2518
2520
  const b = pending.shift();
2519
2521
  const start = link.get(b.joint);
2520
2522
  if (!start) {
2521
- warnings.push(`the route diverging at ${b.from} is not connected to anything`);
2523
+ warnings.push(danglingDivergeWarning(b.from));
2524
+ danglingDiverges.push(b.from);
2522
2525
  continue;
2523
2526
  }
2524
2527
  const already = routes.find((r2) => r2.pieces.includes(byKey.get(start).piece));
@@ -2539,7 +2542,7 @@ function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS)
2539
2542
  if (!reached.has(p.id) && !graph.unplaceable.some((u) => u.piece === p.id))
2540
2543
  warnings.push(`${p.id} is not reachable from the endplate \u2014 nothing connects it`);
2541
2544
  for (const c of graph.conflicts) warnings.push(c.reason);
2542
- return { routes, turnouts, warnings };
2545
+ return { routes, turnouts, warnings, danglingDiverges };
2543
2546
  }
2544
2547
  function resolveGraphAnchor(anchor, walk, pieces, library = BUILT_IN_TRACK_PARTS) {
2545
2548
  const piece = pieces.find((p) => p.id === anchor.piece);
@@ -2560,7 +2563,8 @@ function graphToDoc(pieces, input) {
2560
2563
  const library = input.library ?? BUILT_IN_TRACK_PARTS;
2561
2564
  const graph = buildTrackGraph(pieces, library);
2562
2565
  const walk = walkTrackGraph(graph, pieces, input.startAt, library);
2563
- const warnings = [...walk.warnings];
2566
+ const dangling = new Set(walk.danglingDiverges.map(danglingDivergeWarning));
2567
+ const warnings = walk.warnings.filter((w) => !dangling.has(w));
2564
2568
  const round = (n) => Math.round(n * 100) / 100;
2565
2569
  const base = input.base ?? {};
2566
2570
  const endplates = base.endplates && base.endplates.length ? base.endplates : [{ id: "A", label: "West" }, { id: "B", label: "East" }];