@willcgage/module-schematic 0.38.0 → 0.39.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 +11 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -561,7 +561,8 @@ function emptyEditorState(lengthInches) {
|
|
|
561
561
|
sections: [],
|
|
562
562
|
controlPoints: [],
|
|
563
563
|
industries: [],
|
|
564
|
-
mainPath: []
|
|
564
|
+
mainPath: [],
|
|
565
|
+
main2Path: []
|
|
565
566
|
};
|
|
566
567
|
}
|
|
567
568
|
function isTransitionTurnout(t) {
|
|
@@ -587,15 +588,17 @@ function main2Track(state) {
|
|
|
587
588
|
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
588
589
|
const sws = state.turnouts.filter((t) => isTransitionTurnout(t) && t.divergeTrack === MAIN2_TRACK_ID).sort((a, b) => a.pos - b.pos);
|
|
589
590
|
const lane = state.mainsSwapped ? 0 : 1;
|
|
591
|
+
const authored = state.main2Path.length >= 2 ? { path: state.main2Path } : {};
|
|
590
592
|
if (bothDouble || !sws.length) {
|
|
591
|
-
return { id: MAIN2_TRACK_ID, role: "main", lane, from: "A", to: "B" };
|
|
593
|
+
return { id: MAIN2_TRACK_ID, role: "main", lane, from: "A", to: "B", ...authored };
|
|
592
594
|
}
|
|
593
595
|
const track = (fromPos, toPos) => ({
|
|
594
596
|
id: MAIN2_TRACK_ID,
|
|
595
597
|
role: "main",
|
|
596
598
|
lane,
|
|
597
599
|
fromPos,
|
|
598
|
-
toPos
|
|
600
|
+
toPos,
|
|
601
|
+
...authored
|
|
599
602
|
});
|
|
600
603
|
if (state.configA === "double") return track(0, sws[0].pos);
|
|
601
604
|
if (state.configB === "double") return track(sws[0].pos, state.lengthInches);
|
|
@@ -796,7 +799,8 @@ function stateToDoc(state, recordNumber) {
|
|
|
796
799
|
// that never used them keeps exactly the doc it had before (#96 phase 2).
|
|
797
800
|
...state.sections.length ? { sections: moduleSections({ sections: state.sections }) } : {},
|
|
798
801
|
// Authored mainline path (module-local inches); only when it's a real path.
|
|
799
|
-
...state.mainPath.length >= 2 ? { mainPath: state.mainPath } : {}
|
|
802
|
+
...state.mainPath.length >= 2 ? { mainPath: state.mainPath } : {},
|
|
803
|
+
...state.main2Path.length >= 2 ? { main2Path: state.main2Path } : {}
|
|
800
804
|
};
|
|
801
805
|
}
|
|
802
806
|
function docToState(doc, fallbackLength, moduleTracks = []) {
|
|
@@ -881,6 +885,8 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
|
|
|
881
885
|
...Number.isFinite(p.bulge) && p.bulge ? { bulge: p.bulge } : {}
|
|
882
886
|
}));
|
|
883
887
|
const mainPath = trackPath(d.mainPath) ?? [];
|
|
888
|
+
const main2Track_ = (d.tracks ?? []).find((t) => t.id === MAIN2_TRACK_ID);
|
|
889
|
+
const main2Path = trackPath(d.main2Path ?? main2Track_?.path) ?? [];
|
|
884
890
|
return {
|
|
885
891
|
lengthInches: len,
|
|
886
892
|
loop,
|
|
@@ -902,6 +908,7 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
|
|
|
902
908
|
sectionBreaks: (d.sectionBreaks ?? []).filter((n) => Number.isFinite(n)).map((n) => sc(n)),
|
|
903
909
|
sections: moduleSections(d),
|
|
904
910
|
mainPath,
|
|
911
|
+
main2Path,
|
|
905
912
|
crossings: (d.crossings ?? []).map((x) => ({
|
|
906
913
|
id: x.id,
|
|
907
914
|
name: x.name ?? "",
|