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