@willcgage/module-schematic 0.24.0 → 0.25.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 +20 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -224,6 +224,21 @@ function emptyEditorState(lengthInches) {
|
|
|
224
224
|
function isTransitionTurnout(t) {
|
|
225
225
|
return t.onTrack === MAIN_TRACK_ID && t.divergeTrack === MAIN2_TRACK_ID || t.onTrack === MAIN2_TRACK_ID && t.divergeTrack === MAIN_TRACK_ID;
|
|
226
226
|
}
|
|
227
|
+
function main1Track(state) {
|
|
228
|
+
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
229
|
+
const isDouble = state.configA === "double" || state.configB === "double";
|
|
230
|
+
const sw = state.turnouts.find(isTransitionTurnout);
|
|
231
|
+
if (!isDouble || bothDouble || !sw || sw.onTrack !== MAIN2_TRACK_ID) {
|
|
232
|
+
return { id: MAIN_TRACK_ID, role: "main", lane: 0, from: "A", to: "B" };
|
|
233
|
+
}
|
|
234
|
+
return state.configA === "double" ? (
|
|
235
|
+
// Double at A: Main 1 runs from A and ends at the turnout.
|
|
236
|
+
{ id: MAIN_TRACK_ID, role: "main", lane: 0, fromPos: 0, toPos: sw.pos }
|
|
237
|
+
) : (
|
|
238
|
+
// Double at B: Main 1 begins at the turnout and runs to B.
|
|
239
|
+
{ id: MAIN_TRACK_ID, role: "main", lane: 0, fromPos: sw.pos, toPos: state.lengthInches }
|
|
240
|
+
);
|
|
241
|
+
}
|
|
227
242
|
function main2Track(state) {
|
|
228
243
|
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
229
244
|
const sw = state.turnouts.find(isTransitionTurnout);
|
|
@@ -336,7 +351,11 @@ function stateToDoc(state, recordNumber) {
|
|
|
336
351
|
state.loop ? (
|
|
337
352
|
// The main runs the lead from A and turns back at the balloon.
|
|
338
353
|
{ id: MAIN_TRACK_ID, role: "main", lane: 0, fromPos: 0, toPos: state.lengthInches }
|
|
339
|
-
) :
|
|
354
|
+
) : (
|
|
355
|
+
// Normally A→B; partial when MAIN 2 is the through main and Main 1 is
|
|
356
|
+
// the one that ends at the transition turnout (#FMN-0043).
|
|
357
|
+
main1Track(state)
|
|
358
|
+
),
|
|
340
359
|
// Double track: Main 2 is a real entity so turnouts/signals can attach.
|
|
341
360
|
// On a loop it exists only for a Main 2 directional return (the U joins
|
|
342
361
|
// the two lanes at the balloon); a same-main loop's parallel lead legs
|