@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.cjs CHANGED
@@ -933,17 +933,24 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
933
933
  trackB: x.tracks?.[1] ?? MAIN_TRACK_ID
934
934
  })),
935
935
  extraTracks,
936
- turnouts: (d.turnouts ?? []).map((t) => ({
937
- id: t.id,
938
- name: t.name ?? "",
939
- pos: sc(t.pos),
940
- onTrack: t.onTrack,
941
- divergeTrack: t.divergeTrack,
942
- kind: t.kind ?? "right",
943
- ...t.size ? { size: t.size } : {},
944
- ...t.curved ? { curved: true } : {},
945
- ...t.flipped ? { flipped: true } : {}
946
- })),
936
+ turnouts: (d.turnouts ?? []).map((t) => {
937
+ let divergeTrack = t.divergeTrack;
938
+ if (divergeTrack === t.onTrack) {
939
+ if (t.onTrack === MAIN_TRACK_ID) divergeTrack = MAIN2_TRACK_ID;
940
+ else if (t.onTrack === MAIN2_TRACK_ID) divergeTrack = MAIN_TRACK_ID;
941
+ }
942
+ return {
943
+ id: t.id,
944
+ name: t.name ?? "",
945
+ pos: sc(t.pos),
946
+ onTrack: t.onTrack,
947
+ divergeTrack,
948
+ kind: t.kind ?? "right",
949
+ ...t.size ? { size: t.size } : {},
950
+ ...t.curved ? { curved: true } : {},
951
+ ...t.flipped ? { flipped: true } : {}
952
+ };
953
+ }),
947
954
  controlPoints: readControlPoints(d, sc),
948
955
  industries: (d.industries ?? []).map((ind) => ({
949
956
  id: ind.id,
@@ -1289,9 +1296,10 @@ function moduleFeatures(doc) {
1289
1296
  };
1290
1297
  });
1291
1298
  });
1299
+ const main2Lane = trackLane.has(MAIN2_TRACK_ID) ? trackLane.get(MAIN2_TRACK_ID) : null;
1292
1300
  const allLanes = [
1293
1301
  0,
1294
- doubleMain ? 1 : 0,
1302
+ main2Lane ?? (doubleMain ? 1 : 0),
1295
1303
  ...extraTracks.map((t) => t.lane),
1296
1304
  ...signals.map((s) => s.lane),
1297
1305
  ...crossings.flatMap((x) => [x.laneA, x.laneB]),
@@ -1319,6 +1327,7 @@ function moduleFeatures(doc) {
1319
1327
  doubleMain,
1320
1328
  loop,
1321
1329
  main2Extent,
1330
+ main2Lane,
1322
1331
  transition,
1323
1332
  loopInterchange: loop && doc.endplates.filter((e) => !e.at).length >= 2,
1324
1333
  loopReturn: loop && doc.loopReturn === "main2" ? "main2" : "same",