@willcgage/module-schematic 0.36.0 → 0.37.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
@@ -9,6 +9,12 @@ function endplateWidthInches(ep) {
9
9
  const w = ep?.widthInches;
10
10
  return typeof w === "number" && w > 0 ? w : FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES;
11
11
  }
12
+ function endLabels(o) {
13
+ return o === "north-south" ? { a: "S", b: "N" } : { a: "W", b: "E" };
14
+ }
15
+ function endLabelsLong(o) {
16
+ return o === "north-south" ? { a: "South", b: "North" } : { a: "West", b: "East" };
17
+ }
12
18
  function benchworkOutline(doc) {
13
19
  const pts = (doc?.outline ?? []).filter((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y)).map((p) => ({
14
20
  x: p.x,
@@ -559,6 +565,7 @@ function emptyEditorState(lengthInches) {
559
565
  outline: [],
560
566
  sectionBreaks: [],
561
567
  sections: [],
568
+ orientation: "east-west",
562
569
  controlPoints: [],
563
570
  industries: [],
564
571
  mainPath: []
@@ -795,6 +802,9 @@ function stateToDoc(state, recordNumber) {
795
802
  // Sections as objects — emitted only once the owner has some, so a module
796
803
  // that never used them keeps exactly the doc it had before (#96 phase 2).
797
804
  ...state.sections.length ? { sections: moduleSections({ sections: state.sections }) } : {},
805
+ // Emitted only when it isn't the east/west default, so existing docs are
806
+ // byte-identical.
807
+ ...state.orientation === "north-south" ? { orientation: state.orientation } : {},
798
808
  // Authored mainline path (module-local inches); only when it's a real path.
799
809
  ...state.mainPath.length >= 2 ? { mainPath: state.mainPath } : {}
800
810
  };
@@ -901,6 +911,7 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
901
911
  outline,
902
912
  sectionBreaks: (d.sectionBreaks ?? []).filter((n) => Number.isFinite(n)).map((n) => sc(n)),
903
913
  sections: moduleSections(d),
914
+ orientation: d.orientation === "north-south" ? "north-south" : "east-west",
904
915
  mainPath,
905
916
  crossings: (d.crossings ?? []).map((x) => ({
906
917
  id: x.id,
@@ -1436,6 +1447,8 @@ exports.deriveEndplatePoses = deriveEndplatePoses;
1436
1447
  exports.divergeSideForHand = divergeSideForHand;
1437
1448
  exports.docToState = docToState;
1438
1449
  exports.emptyEditorState = emptyEditorState;
1450
+ exports.endLabels = endLabels;
1451
+ exports.endLabelsLong = endLabelsLong;
1439
1452
  exports.endplateFaceSegments = endplateFaceSegments;
1440
1453
  exports.endplateTrackOffsetFor = endplateTrackOffsetFor;
1441
1454
  exports.endplateTrackOffsetInches = endplateTrackOffsetInches;