@willcgage/module-schematic 0.23.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 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
- ) : { id: MAIN_TRACK_ID, role: "main", lane: 0, from: "A", to: "B" },
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
@@ -368,7 +387,8 @@ function stateToDoc(state, recordNumber) {
368
387
  divergeTrack: t.divergeTrack,
369
388
  kind: t.kind,
370
389
  name: t.name || void 0,
371
- ...t.size ? { size: t.size } : {}
390
+ ...t.size ? { size: t.size } : {},
391
+ ...t.curved ? { curved: true } : {}
372
392
  })),
373
393
  ...state.crossings.length > 0 ? {
374
394
  crossings: state.crossings.map((x) => ({
@@ -529,7 +549,8 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
529
549
  onTrack: t.onTrack,
530
550
  divergeTrack: t.divergeTrack,
531
551
  kind: t.kind ?? "right",
532
- ...t.size ? { size: t.size } : {}
552
+ ...t.size ? { size: t.size } : {},
553
+ ...t.curved ? { curved: true } : {}
533
554
  })),
534
555
  controlPoints: readControlPoints(d, sc),
535
556
  industries: (d.industries ?? []).map((ind) => ({