@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.d.cts CHANGED
@@ -263,6 +263,11 @@ interface ModuleSchematicDoc {
263
263
  * Absent = the module keeps using its own `outline` exactly as before; this
264
264
  * is purely additive and nothing migrates on read. */
265
265
  sections?: SchematicSection[];
266
+ /** Which compass axis the module actually runs along. The dispatcher panel
267
+ * always draws LEFT→RIGHT — that's what makes a layout of modules read as one
268
+ * strip — but a module built north/south should still be labelled N and S.
269
+ * Absent = east/west. */
270
+ orientation?: ModuleOrientation;
266
271
  /** @deprecated pre-grouping flat signals; read for back-compat. */
267
272
  signals?: SchematicSignal[];
268
273
  /** Authored mainline centre-line (module-local inches, open path with arcs).
@@ -279,6 +284,20 @@ interface BenchworkPoint {
279
284
  y: number;
280
285
  bulge?: number;
281
286
  }
287
+ /** The compass axis a module runs along. Endplate A is the first label,
288
+ * endplate B the second, so A→B reads left→right in the dispatcher panel
289
+ * whichever axis it is. */
290
+ type ModuleOrientation = "east-west" | "north-south";
291
+ /** The compass letters for a module's two ends, A first. */
292
+ declare function endLabels(o: ModuleOrientation | null | undefined): {
293
+ a: string;
294
+ b: string;
295
+ };
296
+ /** …spelled out, for a caption like "derived, South → North". */
297
+ declare function endLabelsLong(o: ModuleOrientation | null | undefined): {
298
+ a: string;
299
+ b: string;
300
+ };
282
301
  /** One bench-work section of a module (#96 phase 2). */
283
302
  interface SectionFootprint {
284
303
  id: string;
@@ -771,6 +790,8 @@ interface EditorState {
771
790
  /** The module's sections as named objects, each optionally carrying its own
772
791
  * outline (#96 phase 2). Empty = fall back to `outline` + `sectionBreaks`. */
773
792
  sections: SchematicSection[];
793
+ /** Compass axis the module runs along; the panel still draws left→right. */
794
+ orientation: ModuleOrientation;
774
795
  controlPoints: EditorControlPoint[];
775
796
  /** Rail-served industries — car-spot spans on a track (#industries). */
776
797
  industries: EditorIndustry[];
@@ -1062,4 +1083,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
1062
1083
  heading: number;
1063
1084
  }>;
1064
1085
 
1065
- export { type BenchworkPoint, type BranchConnector, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type GeometryType, type IndustryLabelMode, type IndustrySpot, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OutlineFace, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SectionRelativePos, type SignalFacing, type SignalSide, type TrackConfig, type TrackRole, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, fromSectionRelative, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, remapPos, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackPath };
1086
+ export { type BenchworkPoint, type BranchConnector, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type GeometryType, type IndustryLabelMode, type IndustrySpot, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleOrientation, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OutlineFace, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SectionRelativePos, type SignalFacing, type SignalSide, type TrackConfig, type TrackRole, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endLabels, endLabelsLong, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, fromSectionRelative, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, remapPos, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackPath };
package/dist/index.d.ts CHANGED
@@ -263,6 +263,11 @@ interface ModuleSchematicDoc {
263
263
  * Absent = the module keeps using its own `outline` exactly as before; this
264
264
  * is purely additive and nothing migrates on read. */
265
265
  sections?: SchematicSection[];
266
+ /** Which compass axis the module actually runs along. The dispatcher panel
267
+ * always draws LEFT→RIGHT — that's what makes a layout of modules read as one
268
+ * strip — but a module built north/south should still be labelled N and S.
269
+ * Absent = east/west. */
270
+ orientation?: ModuleOrientation;
266
271
  /** @deprecated pre-grouping flat signals; read for back-compat. */
267
272
  signals?: SchematicSignal[];
268
273
  /** Authored mainline centre-line (module-local inches, open path with arcs).
@@ -279,6 +284,20 @@ interface BenchworkPoint {
279
284
  y: number;
280
285
  bulge?: number;
281
286
  }
287
+ /** The compass axis a module runs along. Endplate A is the first label,
288
+ * endplate B the second, so A→B reads left→right in the dispatcher panel
289
+ * whichever axis it is. */
290
+ type ModuleOrientation = "east-west" | "north-south";
291
+ /** The compass letters for a module's two ends, A first. */
292
+ declare function endLabels(o: ModuleOrientation | null | undefined): {
293
+ a: string;
294
+ b: string;
295
+ };
296
+ /** …spelled out, for a caption like "derived, South → North". */
297
+ declare function endLabelsLong(o: ModuleOrientation | null | undefined): {
298
+ a: string;
299
+ b: string;
300
+ };
282
301
  /** One bench-work section of a module (#96 phase 2). */
283
302
  interface SectionFootprint {
284
303
  id: string;
@@ -771,6 +790,8 @@ interface EditorState {
771
790
  /** The module's sections as named objects, each optionally carrying its own
772
791
  * outline (#96 phase 2). Empty = fall back to `outline` + `sectionBreaks`. */
773
792
  sections: SchematicSection[];
793
+ /** Compass axis the module runs along; the panel still draws left→right. */
794
+ orientation: ModuleOrientation;
774
795
  controlPoints: EditorControlPoint[];
775
796
  /** Rail-served industries — car-spot spans on a track (#industries). */
776
797
  industries: EditorIndustry[];
@@ -1062,4 +1083,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
1062
1083
  heading: number;
1063
1084
  }>;
1064
1085
 
1065
- export { type BenchworkPoint, type BranchConnector, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type GeometryType, type IndustryLabelMode, type IndustrySpot, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OutlineFace, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SectionRelativePos, type SignalFacing, type SignalSide, type TrackConfig, type TrackRole, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, fromSectionRelative, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, remapPos, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackPath };
1086
+ export { type BenchworkPoint, type BranchConnector, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type GeometryType, type IndustryLabelMode, type IndustrySpot, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleOrientation, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OutlineFace, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SectionRelativePos, type SignalFacing, type SignalSide, type TrackConfig, type TrackRole, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endLabels, endLabelsLong, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, fromSectionRelative, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, remapPos, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackPath };
package/dist/index.js CHANGED
@@ -7,6 +7,12 @@ function endplateWidthInches(ep) {
7
7
  const w = ep?.widthInches;
8
8
  return typeof w === "number" && w > 0 ? w : FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES;
9
9
  }
10
+ function endLabels(o) {
11
+ return o === "north-south" ? { a: "S", b: "N" } : { a: "W", b: "E" };
12
+ }
13
+ function endLabelsLong(o) {
14
+ return o === "north-south" ? { a: "South", b: "North" } : { a: "West", b: "East" };
15
+ }
10
16
  function benchworkOutline(doc) {
11
17
  const pts = (doc?.outline ?? []).filter((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y)).map((p) => ({
12
18
  x: p.x,
@@ -557,6 +563,7 @@ function emptyEditorState(lengthInches) {
557
563
  outline: [],
558
564
  sectionBreaks: [],
559
565
  sections: [],
566
+ orientation: "east-west",
560
567
  controlPoints: [],
561
568
  industries: [],
562
569
  mainPath: []
@@ -793,6 +800,9 @@ function stateToDoc(state, recordNumber) {
793
800
  // Sections as objects — emitted only once the owner has some, so a module
794
801
  // that never used them keeps exactly the doc it had before (#96 phase 2).
795
802
  ...state.sections.length ? { sections: moduleSections({ sections: state.sections }) } : {},
803
+ // Emitted only when it isn't the east/west default, so existing docs are
804
+ // byte-identical.
805
+ ...state.orientation === "north-south" ? { orientation: state.orientation } : {},
796
806
  // Authored mainline path (module-local inches); only when it's a real path.
797
807
  ...state.mainPath.length >= 2 ? { mainPath: state.mainPath } : {}
798
808
  };
@@ -899,6 +909,7 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
899
909
  outline,
900
910
  sectionBreaks: (d.sectionBreaks ?? []).filter((n) => Number.isFinite(n)).map((n) => sc(n)),
901
911
  sections: moduleSections(d),
912
+ orientation: d.orientation === "north-south" ? "north-south" : "east-west",
902
913
  mainPath,
903
914
  crossings: (d.crossings ?? []).map((x) => ({
904
915
  id: x.id,
@@ -1413,6 +1424,6 @@ function poseOverridesFromDoc(doc) {
1413
1424
  return out;
1414
1425
  }
1415
1426
 
1416
- export { FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, MAIN2_TRACK_ID, MAIN_TRACK_ID, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, fromSectionRelative, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, remapPos, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackPath };
1427
+ export { FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, MAIN2_TRACK_ID, MAIN_TRACK_ID, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endLabels, endLabelsLong, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, fromSectionRelative, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, remapPos, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackPath };
1417
1428
  //# sourceMappingURL=index.js.map
1418
1429
  //# sourceMappingURL=index.js.map