@willcgage/module-schematic 0.49.2 → 0.49.3

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
@@ -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,