@willcgage/module-schematic 0.25.0 → 0.26.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 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -210,6 +210,7 @@ function emptyEditorState(lengthInches) {
|
|
|
210
210
|
loopReturn: "same",
|
|
211
211
|
configA: "single",
|
|
212
212
|
configB: "single",
|
|
213
|
+
mainsSwapped: false,
|
|
213
214
|
extraTracks: [],
|
|
214
215
|
turnouts: [],
|
|
215
216
|
crossings: [],
|
|
@@ -230,29 +231,31 @@ function main1Track(state) {
|
|
|
230
231
|
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
231
232
|
const isDouble = state.configA === "double" || state.configB === "double";
|
|
232
233
|
const sw = state.turnouts.find(isTransitionTurnout);
|
|
234
|
+
const lane = state.mainsSwapped && isDouble ? 1 : 0;
|
|
233
235
|
if (!isDouble || bothDouble || !sw || sw.onTrack !== MAIN2_TRACK_ID) {
|
|
234
|
-
return { id: MAIN_TRACK_ID, role: "main", lane
|
|
236
|
+
return { id: MAIN_TRACK_ID, role: "main", lane, from: "A", to: "B" };
|
|
235
237
|
}
|
|
236
238
|
return state.configA === "double" ? (
|
|
237
239
|
// Double at A: Main 1 runs from A and ends at the turnout.
|
|
238
|
-
{ id: MAIN_TRACK_ID, role: "main", lane
|
|
240
|
+
{ id: MAIN_TRACK_ID, role: "main", lane, fromPos: 0, toPos: sw.pos }
|
|
239
241
|
) : (
|
|
240
242
|
// Double at B: Main 1 begins at the turnout and runs to B.
|
|
241
|
-
{ id: MAIN_TRACK_ID, role: "main", lane
|
|
243
|
+
{ id: MAIN_TRACK_ID, role: "main", lane, fromPos: sw.pos, toPos: state.lengthInches }
|
|
242
244
|
);
|
|
243
245
|
}
|
|
244
246
|
function main2Track(state) {
|
|
245
247
|
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
246
248
|
const sw = state.turnouts.find(isTransitionTurnout);
|
|
249
|
+
const lane = state.mainsSwapped ? 0 : 1;
|
|
247
250
|
if (bothDouble || !sw || sw.divergeTrack !== MAIN2_TRACK_ID) {
|
|
248
|
-
return { id: MAIN2_TRACK_ID, role: "main", lane
|
|
251
|
+
return { id: MAIN2_TRACK_ID, role: "main", lane, from: "A", to: "B" };
|
|
249
252
|
}
|
|
250
253
|
return state.configA === "double" ? (
|
|
251
254
|
// Double at A: Main 2 runs from A and ends at the turnout.
|
|
252
|
-
{ id: MAIN2_TRACK_ID, role: "main", lane
|
|
255
|
+
{ id: MAIN2_TRACK_ID, role: "main", lane, fromPos: 0, toPos: sw.pos }
|
|
253
256
|
) : (
|
|
254
257
|
// Double at B: Main 2 begins at the turnout and runs to B.
|
|
255
|
-
{ id: MAIN2_TRACK_ID, role: "main", lane
|
|
258
|
+
{ id: MAIN2_TRACK_ID, role: "main", lane, fromPos: sw.pos, toPos: state.lengthInches }
|
|
256
259
|
);
|
|
257
260
|
}
|
|
258
261
|
function buildTransition(state) {
|
|
@@ -309,6 +312,7 @@ function stateToDoc(state, recordNumber) {
|
|
|
309
312
|
lengthInches: state.lengthInches,
|
|
310
313
|
...state.loop ? { loop: true } : {},
|
|
311
314
|
...state.loop && state.loopReturn === "main2" ? { loopReturn: "main2" } : {},
|
|
315
|
+
...state.mainsSwapped ? { mainsSwapped: true } : {},
|
|
312
316
|
endplates: withWidths(
|
|
313
317
|
withPoses(
|
|
314
318
|
[
|
|
@@ -520,6 +524,7 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
|
|
|
520
524
|
lengthInches: len,
|
|
521
525
|
loop,
|
|
522
526
|
loopReturn: loop && d.loopReturn === "main2" ? "main2" : "same",
|
|
527
|
+
mainsSwapped: d.mainsSwapped === true,
|
|
523
528
|
configA: configOf("A"),
|
|
524
529
|
// On a loop, a missing B means pure turnback; present = interchange loop.
|
|
525
530
|
configB: loop && !hasB ? "none" : configOf("B"),
|