@willcgage/module-schematic 0.39.0 → 0.41.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 +18 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -567,25 +567,19 @@ function isTransitionTurnout(t) {
|
|
|
567
567
|
return t.onTrack === MAIN_TRACK_ID && t.divergeTrack === MAIN2_TRACK_ID || t.onTrack === MAIN2_TRACK_ID && t.divergeTrack === MAIN_TRACK_ID;
|
|
568
568
|
}
|
|
569
569
|
function main1Track(state) {
|
|
570
|
-
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
571
|
-
const isDouble = state.configA === "double" || state.configB === "double";
|
|
572
570
|
const sw = state.turnouts.find(isTransitionTurnout);
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
|
|
571
|
+
const legacyThroughMain2 = !!sw && sw.onTrack === MAIN2_TRACK_ID && sw.divergeTrack === MAIN_TRACK_ID;
|
|
572
|
+
const isDouble = state.configA === "double" || state.configB === "double";
|
|
573
|
+
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
574
|
+
if (!isDouble || bothDouble || !legacyThroughMain2) {
|
|
575
|
+
return { id: MAIN_TRACK_ID, role: "main", lane: 0, from: "A", to: "B" };
|
|
576
576
|
}
|
|
577
|
-
return state.configA === "double" ?
|
|
578
|
-
// Double at A: Main 1 runs from A and ends at the turnout.
|
|
579
|
-
{ id: MAIN_TRACK_ID, role: "main", lane, fromPos: 0, toPos: sw.pos }
|
|
580
|
-
) : (
|
|
581
|
-
// Double at B: Main 1 begins at the turnout and runs to B.
|
|
582
|
-
{ id: MAIN_TRACK_ID, role: "main", lane, fromPos: sw.pos, toPos: state.lengthInches }
|
|
583
|
-
);
|
|
577
|
+
return state.configA === "double" ? { id: MAIN_TRACK_ID, role: "main", lane: 0, fromPos: 0, toPos: sw.pos } : { id: MAIN_TRACK_ID, role: "main", lane: 0, fromPos: sw.pos, toPos: state.lengthInches };
|
|
584
578
|
}
|
|
585
579
|
function main2Track(state) {
|
|
586
580
|
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
587
581
|
const sws = state.turnouts.filter((t) => isTransitionTurnout(t) && t.divergeTrack === MAIN2_TRACK_ID).sort((a, b) => a.pos - b.pos);
|
|
588
|
-
const lane = state.mainsSwapped ?
|
|
582
|
+
const lane = state.mainsSwapped ? -1 : 1;
|
|
589
583
|
const authored = state.main2Path.length >= 2 ? { path: state.main2Path } : {};
|
|
590
584
|
if (bothDouble || !sws.length) {
|
|
591
585
|
return { id: MAIN2_TRACK_ID, role: "main", lane, from: "A", to: "B", ...authored };
|
|
@@ -615,13 +609,17 @@ function buildTransition(state) {
|
|
|
615
609
|
id: swId,
|
|
616
610
|
name: "End of Double Track",
|
|
617
611
|
pos,
|
|
618
|
-
// The turnout sits ON the
|
|
619
|
-
//
|
|
620
|
-
//
|
|
621
|
-
//
|
|
622
|
-
onTrack:
|
|
623
|
-
divergeTrack:
|
|
624
|
-
|
|
612
|
+
// The turnout sits ON the through mainline (Main 1) and diverges TO Main 2,
|
|
613
|
+
// the second main being added to start the double track — the modeller's
|
|
614
|
+
// view of the junction, and the direction an owner authors it (Steve
|
|
615
|
+
// Branton, #131). Main 1 runs the full module; Main 2 is the branch.
|
|
616
|
+
onTrack: MAIN_TRACK_ID,
|
|
617
|
+
divergeTrack: MAIN2_TRACK_ID,
|
|
618
|
+
// Hand so the diverging leg lands on Main 2's side. Main 2 extends toward
|
|
619
|
+
// the double end (sign −1 west / +1 east) and sits above (+1) or, when the
|
|
620
|
+
// mains are swapped, below (−1). divergeSideForHand(left)=sign(toward),
|
|
621
|
+
// (right)=−sign(toward), so pick the hand whose side matches Main 2's (#131).
|
|
622
|
+
kind: (aDouble ? -1 : 1) === (state.mainsSwapped ? -1 : 1) ? "left" : "right"
|
|
625
623
|
};
|
|
626
624
|
const cpId = nextId("cp", state.controlPoints.map((c) => c.id));
|
|
627
625
|
const sig = (facing) => ({
|