@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.d.cts CHANGED
@@ -269,6 +269,11 @@ interface ModuleSchematicDoc {
269
269
  * Present = the owner drew the real shape; absent = derive from geometry.
270
270
  * Physical view only — the operations view stays derived (#2d-track). */
271
271
  mainPath?: BenchworkPoint[] | null;
272
+ /** Authored centre-line for MAIN 2 on a double-track module (module-local
273
+ * inches, open path with arcs). Present = the owner bent Main 2 to its real
274
+ * shape; absent = derive it as a lane offset from Main 1. Physical view only
275
+ * (#131). */
276
+ main2Path?: BenchworkPoint[] | null;
272
277
  }
273
278
  /** A benchwork-outline vertex, module-local inches. The edge from this vertex
274
279
  * to the NEXT one is a straight line, unless `bulge` is set — then it's a
@@ -783,6 +788,8 @@ interface EditorState {
783
788
  /** Authored mainline centre-line (module-local inches) — empty = derive from
784
789
  * geometry. The owner-drawn real shape (#2d-track, physical view only). */
785
790
  mainPath: BenchworkPoint[];
791
+ /** Authored Main 2 centre-line (double-track only) — empty = lane offset (#131). */
792
+ main2Path: BenchworkPoint[];
786
793
  }
787
794
  /** Build the empty editor state for a module of the given length. */
788
795
  declare function emptyEditorState(lengthInches: number): EditorState;
package/dist/index.d.ts CHANGED
@@ -269,6 +269,11 @@ interface ModuleSchematicDoc {
269
269
  * Present = the owner drew the real shape; absent = derive from geometry.
270
270
  * Physical view only — the operations view stays derived (#2d-track). */
271
271
  mainPath?: BenchworkPoint[] | null;
272
+ /** Authored centre-line for MAIN 2 on a double-track module (module-local
273
+ * inches, open path with arcs). Present = the owner bent Main 2 to its real
274
+ * shape; absent = derive it as a lane offset from Main 1. Physical view only
275
+ * (#131). */
276
+ main2Path?: BenchworkPoint[] | null;
272
277
  }
273
278
  /** A benchwork-outline vertex, module-local inches. The edge from this vertex
274
279
  * to the NEXT one is a straight line, unless `bulge` is set — then it's a
@@ -783,6 +788,8 @@ interface EditorState {
783
788
  /** Authored mainline centre-line (module-local inches) — empty = derive from
784
789
  * geometry. The owner-drawn real shape (#2d-track, physical view only). */
785
790
  mainPath: BenchworkPoint[];
791
+ /** Authored Main 2 centre-line (double-track only) — empty = lane offset (#131). */
792
+ main2Path: BenchworkPoint[];
786
793
  }
787
794
  /** Build the empty editor state for a module of the given length. */
788
795
  declare function emptyEditorState(lengthInches: number): EditorState;
package/dist/index.js CHANGED
@@ -559,7 +559,8 @@ function emptyEditorState(lengthInches) {
559
559
  sections: [],
560
560
  controlPoints: [],
561
561
  industries: [],
562
- mainPath: []
562
+ mainPath: [],
563
+ main2Path: []
563
564
  };
564
565
  }
565
566
  function isTransitionTurnout(t) {
@@ -585,15 +586,17 @@ function main2Track(state) {
585
586
  const bothDouble = state.configA === "double" && state.configB === "double";
586
587
  const sws = state.turnouts.filter((t) => isTransitionTurnout(t) && t.divergeTrack === MAIN2_TRACK_ID).sort((a, b) => a.pos - b.pos);
587
588
  const lane = state.mainsSwapped ? 0 : 1;
589
+ const authored = state.main2Path.length >= 2 ? { path: state.main2Path } : {};
588
590
  if (bothDouble || !sws.length) {
589
- return { id: MAIN2_TRACK_ID, role: "main", lane, from: "A", to: "B" };
591
+ return { id: MAIN2_TRACK_ID, role: "main", lane, from: "A", to: "B", ...authored };
590
592
  }
591
593
  const track = (fromPos, toPos) => ({
592
594
  id: MAIN2_TRACK_ID,
593
595
  role: "main",
594
596
  lane,
595
597
  fromPos,
596
- toPos
598
+ toPos,
599
+ ...authored
597
600
  });
598
601
  if (state.configA === "double") return track(0, sws[0].pos);
599
602
  if (state.configB === "double") return track(sws[0].pos, state.lengthInches);
@@ -794,7 +797,8 @@ function stateToDoc(state, recordNumber) {
794
797
  // that never used them keeps exactly the doc it had before (#96 phase 2).
795
798
  ...state.sections.length ? { sections: moduleSections({ sections: state.sections }) } : {},
796
799
  // Authored mainline path (module-local inches); only when it's a real path.
797
- ...state.mainPath.length >= 2 ? { mainPath: state.mainPath } : {}
800
+ ...state.mainPath.length >= 2 ? { mainPath: state.mainPath } : {},
801
+ ...state.main2Path.length >= 2 ? { main2Path: state.main2Path } : {}
798
802
  };
799
803
  }
800
804
  function docToState(doc, fallbackLength, moduleTracks = []) {
@@ -879,6 +883,8 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
879
883
  ...Number.isFinite(p.bulge) && p.bulge ? { bulge: p.bulge } : {}
880
884
  }));
881
885
  const mainPath = trackPath(d.mainPath) ?? [];
886
+ const main2Track_ = (d.tracks ?? []).find((t) => t.id === MAIN2_TRACK_ID);
887
+ const main2Path = trackPath(d.main2Path ?? main2Track_?.path) ?? [];
882
888
  return {
883
889
  lengthInches: len,
884
890
  loop,
@@ -900,6 +906,7 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
900
906
  sectionBreaks: (d.sectionBreaks ?? []).filter((n) => Number.isFinite(n)).map((n) => sc(n)),
901
907
  sections: moduleSections(d),
902
908
  mainPath,
909
+ main2Path,
903
910
  crossings: (d.crossings ?? []).map((x) => ({
904
911
  id: x.id,
905
912
  name: x.name ?? "",