@willcgage/module-schematic 0.33.0 → 0.34.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 +19 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -555,18 +555,22 @@ function main1Track(state) {
|
|
|
555
555
|
}
|
|
556
556
|
function main2Track(state) {
|
|
557
557
|
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
558
|
-
const
|
|
558
|
+
const sws = state.turnouts.filter((t) => isTransitionTurnout(t) && t.divergeTrack === MAIN2_TRACK_ID).sort((a, b) => a.pos - b.pos);
|
|
559
559
|
const lane = state.mainsSwapped ? 0 : 1;
|
|
560
|
-
if (bothDouble || !
|
|
560
|
+
if (bothDouble || !sws.length) {
|
|
561
561
|
return { id: MAIN2_TRACK_ID, role: "main", lane, from: "A", to: "B" };
|
|
562
562
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
);
|
|
563
|
+
const track = (fromPos, toPos) => ({
|
|
564
|
+
id: MAIN2_TRACK_ID,
|
|
565
|
+
role: "main",
|
|
566
|
+
lane,
|
|
567
|
+
fromPos,
|
|
568
|
+
toPos
|
|
569
|
+
});
|
|
570
|
+
if (state.configA === "double") return track(0, sws[0].pos);
|
|
571
|
+
if (state.configB === "double") return track(sws[0].pos, state.lengthInches);
|
|
572
|
+
if (sws.length >= 2) return track(sws[0].pos, sws[sws.length - 1].pos);
|
|
573
|
+
return track(sws[0].pos, state.lengthInches);
|
|
570
574
|
}
|
|
571
575
|
function buildTransition(state) {
|
|
572
576
|
const aDouble = state.configA === "double";
|
|
@@ -684,7 +688,12 @@ function stateToDoc(state, recordNumber) {
|
|
|
684
688
|
// double) Main 2 only runs from the mainline turnout to the double end —
|
|
685
689
|
// the turnout that diverges to main2 is the single source of truth for
|
|
686
690
|
// where the transition sits (fd#175 / FMN-0038).
|
|
687
|
-
|
|
691
|
+
// …and on a module that's SINGLE at both ends but goes double in the
|
|
692
|
+
// middle to form a siding: the turnouts are what make Main 2 exist, so a
|
|
693
|
+
// pair of them is reason enough to emit it (#118). Without this the
|
|
694
|
+
// second main simply wasn't in the doc, and neither the board nor the
|
|
695
|
+
// dispatcher panel could draw it.
|
|
696
|
+
...!state.loop && (state.configA === "double" || state.configB === "double" || state.turnouts.some((t) => isTransitionTurnout(t) && t.divergeTrack === MAIN2_TRACK_ID)) ? [main2Track(state)] : [],
|
|
688
697
|
...state.loop && state.loopReturn === "main2" ? [{ id: MAIN2_TRACK_ID, role: "main", lane: 1, fromPos: 0, toPos: state.lengthInches }] : [],
|
|
689
698
|
...state.extraTracks.map((t) => ({
|
|
690
699
|
id: t.id,
|