@willcgage/module-schematic 0.39.0 → 0.40.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.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 lane = state.mainsSwapped && isDouble ? 1 : 0;
574
- if (!isDouble || bothDouble || !sw || sw.onTrack !== MAIN2_TRACK_ID) {
575
- return { id: MAIN_TRACK_ID, role: "main", lane, from: "A", to: "B" };
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 ? 0 : 1;
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,12 +609,12 @@ function buildTransition(state) {
615
609
  id: swId,
616
610
  name: "End of Double Track",
617
611
  pos,
618
- // The turnout sits ON the ending main (Main 2, the upper track) and diverges
619
- // down to the continuous Main 1 — the modeller's view of the junction. Left
620
- // hand when the double end is west (Main 2 comes down going east), right
621
- // when it's east (mirror).
622
- onTrack: MAIN2_TRACK_ID,
623
- divergeTrack: MAIN_TRACK_ID,
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,
624
618
  kind: aDouble ? "left" : "right"
625
619
  };
626
620
  const cpId = nextId("cp", state.controlPoints.map((c) => c.id));