@willcgage/module-schematic 0.49.2 → 0.49.4

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
@@ -1000,6 +1000,10 @@ interface ModuleFeatures {
1000
1000
  fromFrac: number;
1001
1001
  toFrac: number;
1002
1002
  } | null;
1003
+ /** Main 2's drawn lane — +1 above Main 1 by default, −1 below when the mains
1004
+ * are swapped (#131/#172). Null when there is no Main 2. Renderers must draw
1005
+ * Main 2 (and its diverges) at THIS lane, never a hard-coded +1. */
1006
+ main2Lane: number | null;
1003
1007
  /** Single↔double transition, fully described (#FMN-0043). The `through` main
1004
1008
  * runs the whole module; the `branch` main exists only on the double side and
1005
1009
  * merges at `atFrac`. EITHER main can be through/branch — the surviving single
package/dist/index.d.ts CHANGED
@@ -1000,6 +1000,10 @@ interface ModuleFeatures {
1000
1000
  fromFrac: number;
1001
1001
  toFrac: number;
1002
1002
  } | null;
1003
+ /** Main 2's drawn lane — +1 above Main 1 by default, −1 below when the mains
1004
+ * are swapped (#131/#172). Null when there is no Main 2. Renderers must draw
1005
+ * Main 2 (and its diverges) at THIS lane, never a hard-coded +1. */
1006
+ main2Lane: number | null;
1003
1007
  /** Single↔double transition, fully described (#FMN-0043). The `through` main
1004
1008
  * runs the whole module; the `branch` main exists only on the double side and
1005
1009
  * merges at `atFrac`. EITHER main can be through/branch — the surviving single
package/dist/index.js CHANGED
@@ -931,17 +931,24 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
931
931
  trackB: x.tracks?.[1] ?? MAIN_TRACK_ID
932
932
  })),
933
933
  extraTracks,
934
- turnouts: (d.turnouts ?? []).map((t) => ({
935
- id: t.id,
936
- name: t.name ?? "",
937
- pos: sc(t.pos),
938
- onTrack: t.onTrack,
939
- divergeTrack: t.divergeTrack,
940
- kind: t.kind ?? "right",
941
- ...t.size ? { size: t.size } : {},
942
- ...t.curved ? { curved: true } : {},
943
- ...t.flipped ? { flipped: true } : {}
944
- })),
934
+ turnouts: (d.turnouts ?? []).map((t) => {
935
+ let divergeTrack = t.divergeTrack;
936
+ if (divergeTrack === t.onTrack) {
937
+ if (t.onTrack === MAIN_TRACK_ID) divergeTrack = MAIN2_TRACK_ID;
938
+ else if (t.onTrack === MAIN2_TRACK_ID) divergeTrack = MAIN_TRACK_ID;
939
+ }
940
+ return {
941
+ id: t.id,
942
+ name: t.name ?? "",
943
+ pos: sc(t.pos),
944
+ onTrack: t.onTrack,
945
+ divergeTrack,
946
+ kind: t.kind ?? "right",
947
+ ...t.size ? { size: t.size } : {},
948
+ ...t.curved ? { curved: true } : {},
949
+ ...t.flipped ? { flipped: true } : {}
950
+ };
951
+ }),
945
952
  controlPoints: readControlPoints(d, sc),
946
953
  industries: (d.industries ?? []).map((ind) => ({
947
954
  id: ind.id,
@@ -1287,9 +1294,10 @@ function moduleFeatures(doc) {
1287
1294
  };
1288
1295
  });
1289
1296
  });
1297
+ const main2Lane = trackLane.has(MAIN2_TRACK_ID) ? trackLane.get(MAIN2_TRACK_ID) : null;
1290
1298
  const allLanes = [
1291
1299
  0,
1292
- doubleMain ? 1 : 0,
1300
+ main2Lane ?? (doubleMain ? 1 : 0),
1293
1301
  ...extraTracks.map((t) => t.lane),
1294
1302
  ...signals.map((s) => s.lane),
1295
1303
  ...crossings.flatMap((x) => [x.laneA, x.laneB]),
@@ -1317,6 +1325,7 @@ function moduleFeatures(doc) {
1317
1325
  doubleMain,
1318
1326
  loop,
1319
1327
  main2Extent,
1328
+ main2Lane,
1320
1329
  transition,
1321
1330
  loopInterchange: loop && doc.endplates.filter((e) => !e.at).length >= 2,
1322
1331
  loopReturn: loop && doc.loopReturn === "main2" ? "main2" : "same",