@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.cjs CHANGED
@@ -569,25 +569,19 @@ function isTransitionTurnout(t) {
569
569
  return t.onTrack === MAIN_TRACK_ID && t.divergeTrack === MAIN2_TRACK_ID || t.onTrack === MAIN2_TRACK_ID && t.divergeTrack === MAIN_TRACK_ID;
570
570
  }
571
571
  function main1Track(state) {
572
- const bothDouble = state.configA === "double" && state.configB === "double";
573
- const isDouble = state.configA === "double" || state.configB === "double";
574
572
  const sw = state.turnouts.find(isTransitionTurnout);
575
- const lane = state.mainsSwapped && isDouble ? 1 : 0;
576
- if (!isDouble || bothDouble || !sw || sw.onTrack !== MAIN2_TRACK_ID) {
577
- return { id: MAIN_TRACK_ID, role: "main", lane, from: "A", to: "B" };
573
+ const legacyThroughMain2 = !!sw && sw.onTrack === MAIN2_TRACK_ID && sw.divergeTrack === MAIN_TRACK_ID;
574
+ const isDouble = state.configA === "double" || state.configB === "double";
575
+ const bothDouble = state.configA === "double" && state.configB === "double";
576
+ if (!isDouble || bothDouble || !legacyThroughMain2) {
577
+ return { id: MAIN_TRACK_ID, role: "main", lane: 0, from: "A", to: "B" };
578
578
  }
579
- return state.configA === "double" ? (
580
- // Double at A: Main 1 runs from A and ends at the turnout.
581
- { id: MAIN_TRACK_ID, role: "main", lane, fromPos: 0, toPos: sw.pos }
582
- ) : (
583
- // Double at B: Main 1 begins at the turnout and runs to B.
584
- { id: MAIN_TRACK_ID, role: "main", lane, fromPos: sw.pos, toPos: state.lengthInches }
585
- );
579
+ 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 };
586
580
  }
587
581
  function main2Track(state) {
588
582
  const bothDouble = state.configA === "double" && state.configB === "double";
589
583
  const sws = state.turnouts.filter((t) => isTransitionTurnout(t) && t.divergeTrack === MAIN2_TRACK_ID).sort((a, b) => a.pos - b.pos);
590
- const lane = state.mainsSwapped ? 0 : 1;
584
+ const lane = state.mainsSwapped ? -1 : 1;
591
585
  const authored = state.main2Path.length >= 2 ? { path: state.main2Path } : {};
592
586
  if (bothDouble || !sws.length) {
593
587
  return { id: MAIN2_TRACK_ID, role: "main", lane, from: "A", to: "B", ...authored };
@@ -617,12 +611,12 @@ function buildTransition(state) {
617
611
  id: swId,
618
612
  name: "End of Double Track",
619
613
  pos,
620
- // The turnout sits ON the ending main (Main 2, the upper track) and diverges
621
- // down to the continuous Main 1 — the modeller's view of the junction. Left
622
- // hand when the double end is west (Main 2 comes down going east), right
623
- // when it's east (mirror).
624
- onTrack: MAIN2_TRACK_ID,
625
- divergeTrack: MAIN_TRACK_ID,
614
+ // The turnout sits ON the through mainline (Main 1) and diverges TO Main 2,
615
+ // the second main being added to start the double track — the modeller's
616
+ // view of the junction, and the direction an owner authors it (Steve
617
+ // Branton, #131). Main 1 runs the full module; Main 2 is the branch.
618
+ onTrack: MAIN_TRACK_ID,
619
+ divergeTrack: MAIN2_TRACK_ID,
626
620
  kind: aDouble ? "left" : "right"
627
621
  };
628
622
  const cpId = nextId("cp", state.controlPoints.map((c) => c.id));