@willcgage/module-schematic 0.92.0 → 0.93.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
@@ -100,6 +100,17 @@ declare const FREEMO_TRACK_SPACING_INCHES = 1.125;
100
100
  /** Free-moN §2.0 **standard**: track crossing an endplate must be "not less than
101
101
  * 4 inches from either fascia" (and perpendicular, straight and level for 4″). */
102
102
  declare const FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES = 4;
103
+ /**
104
+ * Free-moN **standard**: minimum MAIN-LINE radius, 22″.
105
+ *
106
+ * ⚠️ The main line only. A spur, a yard lead or an industrial track may be
107
+ * tighter, and telling an owner their yard is out of spec because it is not a
108
+ * main would be worse than saying nothing.
109
+ */
110
+ declare const FREEMO_MAIN_MIN_RADIUS_INCHES = 22;
111
+ /** Free-moN **standard**: at least 6″ of straight track between REVERSE curves,
112
+ * so a train is never asked to change hands instantly. */
113
+ declare const FREEMO_REVERSE_CURVE_STRAIGHT_INCHES = 6;
103
114
  /**
104
115
  * A stretch where a pair of parallel tracks runs at something other than the
105
116
  * standard spacing, because a rigid assembly built to another spacing sits in
@@ -448,6 +459,16 @@ interface ModuleSchematicDoc {
448
459
  piece: string;
449
460
  joint: string;
450
461
  };
462
+ /** Where MAIN 2 starts, on a double-track module — the joint the endplate's
463
+ * SECOND track arrives at. Absent = single track.
464
+ *
465
+ * Two starts rather than a list because a document has exactly two mains,
466
+ * `main` and `main2`. This mirrors the thing downstream instead of inventing
467
+ * a generality nothing can read. */
468
+ start2?: {
469
+ piece: string;
470
+ joint: string;
471
+ } | null;
451
472
  } | null;
452
473
  }
453
474
  /** A benchwork-outline vertex, module-local inches. The edge from this vertex
@@ -2633,6 +2654,11 @@ interface GraphWalk {
2633
2654
  * sentence, so a caller can act on it (and say it ONCE) instead of matching
2634
2655
  * on prose. */
2635
2656
  danglingDiverges: string[];
2657
+ /** Pieces this walk never got to. ⚠️ "Unreached BY THIS WALK" is not the same
2658
+ * as "unreachable": a double-track module's second main is unreached by the
2659
+ * first walk and perfectly well connected. Ids, so a caller running more than
2660
+ * one walk can tell the difference. */
2661
+ unreached: string[];
2636
2662
  }
2637
2663
  /**
2638
2664
  * Walk the graph from an endplate and read the topology off it.
@@ -2675,6 +2701,11 @@ interface GraphDocInput {
2675
2701
  piece: string;
2676
2702
  joint: string;
2677
2703
  };
2704
+ /** Where MAIN 2 begins, on a double-track module. Absent = single track. */
2705
+ start2?: {
2706
+ piece: string;
2707
+ joint: string;
2708
+ } | null;
2678
2709
  /**
2679
2710
  * The rest of the document — module id, endplate identities, the benchwork,
2680
2711
  * industries and signals. Merged UNDERNEATH the derived keys, so the graph
@@ -3018,4 +3049,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
3018
3049
  heading: number;
3019
3050
  }>;
3020
3051
 
3021
- export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplateEdge, type EndplateEdgePose, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type GraphAnchor, type GraphConflict, type GraphConnection, type GraphDocInput, type GraphDocResult, type GraphRoute, type GraphTurnout, type GraphWalk, type ImportedPart, type IndustryLabelMode, type IndustrySpot, JOINT_SNAP_INCHES, type LanePinch, 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 OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartGeometry, type PartJoint, type PartJointRole, type PartSegment, type PieceSnap, type PlacedJoint, RAIL_GAUGE_INCHES, type ResolvedAnchor, type ReturnLoopGeometry, type ReturnLoopShape, type RouteSpan, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackGraph, type TrackPart, type TrackPiece, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexRunEnd, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, pieceRoutePaths, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, snapPiece, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
3052
+ export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplateEdge, type EndplateEdgePose, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_MAIN_MIN_RADIUS_INCHES, FREEMO_REVERSE_CURVE_STRAIGHT_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type GraphAnchor, type GraphConflict, type GraphConnection, type GraphDocInput, type GraphDocResult, type GraphRoute, type GraphTurnout, type GraphWalk, type ImportedPart, type IndustryLabelMode, type IndustrySpot, JOINT_SNAP_INCHES, type LanePinch, 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 OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartGeometry, type PartJoint, type PartJointRole, type PartSegment, type PieceSnap, type PlacedJoint, RAIL_GAUGE_INCHES, type ResolvedAnchor, type ReturnLoopGeometry, type ReturnLoopShape, type RouteSpan, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackGraph, type TrackPart, type TrackPiece, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexRunEnd, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, pieceRoutePaths, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, snapPiece, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
package/dist/index.d.ts CHANGED
@@ -100,6 +100,17 @@ declare const FREEMO_TRACK_SPACING_INCHES = 1.125;
100
100
  /** Free-moN §2.0 **standard**: track crossing an endplate must be "not less than
101
101
  * 4 inches from either fascia" (and perpendicular, straight and level for 4″). */
102
102
  declare const FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES = 4;
103
+ /**
104
+ * Free-moN **standard**: minimum MAIN-LINE radius, 22″.
105
+ *
106
+ * ⚠️ The main line only. A spur, a yard lead or an industrial track may be
107
+ * tighter, and telling an owner their yard is out of spec because it is not a
108
+ * main would be worse than saying nothing.
109
+ */
110
+ declare const FREEMO_MAIN_MIN_RADIUS_INCHES = 22;
111
+ /** Free-moN **standard**: at least 6″ of straight track between REVERSE curves,
112
+ * so a train is never asked to change hands instantly. */
113
+ declare const FREEMO_REVERSE_CURVE_STRAIGHT_INCHES = 6;
103
114
  /**
104
115
  * A stretch where a pair of parallel tracks runs at something other than the
105
116
  * standard spacing, because a rigid assembly built to another spacing sits in
@@ -448,6 +459,16 @@ interface ModuleSchematicDoc {
448
459
  piece: string;
449
460
  joint: string;
450
461
  };
462
+ /** Where MAIN 2 starts, on a double-track module — the joint the endplate's
463
+ * SECOND track arrives at. Absent = single track.
464
+ *
465
+ * Two starts rather than a list because a document has exactly two mains,
466
+ * `main` and `main2`. This mirrors the thing downstream instead of inventing
467
+ * a generality nothing can read. */
468
+ start2?: {
469
+ piece: string;
470
+ joint: string;
471
+ } | null;
451
472
  } | null;
452
473
  }
453
474
  /** A benchwork-outline vertex, module-local inches. The edge from this vertex
@@ -2633,6 +2654,11 @@ interface GraphWalk {
2633
2654
  * sentence, so a caller can act on it (and say it ONCE) instead of matching
2634
2655
  * on prose. */
2635
2656
  danglingDiverges: string[];
2657
+ /** Pieces this walk never got to. ⚠️ "Unreached BY THIS WALK" is not the same
2658
+ * as "unreachable": a double-track module's second main is unreached by the
2659
+ * first walk and perfectly well connected. Ids, so a caller running more than
2660
+ * one walk can tell the difference. */
2661
+ unreached: string[];
2636
2662
  }
2637
2663
  /**
2638
2664
  * Walk the graph from an endplate and read the topology off it.
@@ -2675,6 +2701,11 @@ interface GraphDocInput {
2675
2701
  piece: string;
2676
2702
  joint: string;
2677
2703
  };
2704
+ /** Where MAIN 2 begins, on a double-track module. Absent = single track. */
2705
+ start2?: {
2706
+ piece: string;
2707
+ joint: string;
2708
+ } | null;
2678
2709
  /**
2679
2710
  * The rest of the document — module id, endplate identities, the benchwork,
2680
2711
  * industries and signals. Merged UNDERNEATH the derived keys, so the graph
@@ -3018,4 +3049,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
3018
3049
  heading: number;
3019
3050
  }>;
3020
3051
 
3021
- export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplateEdge, type EndplateEdgePose, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type GraphAnchor, type GraphConflict, type GraphConnection, type GraphDocInput, type GraphDocResult, type GraphRoute, type GraphTurnout, type GraphWalk, type ImportedPart, type IndustryLabelMode, type IndustrySpot, JOINT_SNAP_INCHES, type LanePinch, 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 OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartGeometry, type PartJoint, type PartJointRole, type PartSegment, type PieceSnap, type PlacedJoint, RAIL_GAUGE_INCHES, type ResolvedAnchor, type ReturnLoopGeometry, type ReturnLoopShape, type RouteSpan, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackGraph, type TrackPart, type TrackPiece, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexRunEnd, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, pieceRoutePaths, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, snapPiece, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
3052
+ export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplateEdge, type EndplateEdgePose, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_MAIN_MIN_RADIUS_INCHES, FREEMO_REVERSE_CURVE_STRAIGHT_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type GraphAnchor, type GraphConflict, type GraphConnection, type GraphDocInput, type GraphDocResult, type GraphRoute, type GraphTurnout, type GraphWalk, type ImportedPart, type IndustryLabelMode, type IndustrySpot, JOINT_SNAP_INCHES, type LanePinch, 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 OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartGeometry, type PartJoint, type PartJointRole, type PartSegment, type PieceSnap, type PlacedJoint, RAIL_GAUGE_INCHES, type ResolvedAnchor, type ReturnLoopGeometry, type ReturnLoopShape, type RouteSpan, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackGraph, type TrackPart, type TrackPiece, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexRunEnd, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, pieceRoutePaths, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, snapPiece, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
package/dist/index.js CHANGED
@@ -3,6 +3,8 @@ var FREEMO_ENDPLATE_WIDTH_MIN_INCHES = 12;
3
3
  var FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES = 24;
4
4
  var FREEMO_TRACK_SPACING_INCHES = 1.125;
5
5
  var FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES = 4;
6
+ var FREEMO_MAIN_MIN_RADIUS_INCHES = 22;
7
+ var FREEMO_REVERSE_CURVE_STRAIGHT_INCHES = 6;
6
8
  var PINCH_EASE_INCHES = 3;
7
9
  function laneOffsetAt(lane, pos, pinches, spacingInches = FREEMO_TRACK_SPACING_INCHES) {
8
10
  const base = (lane ?? 0) * spacingInches;
@@ -2439,6 +2441,7 @@ function snapPiece(moving, others, library = BUILT_IN_TRACK_PARTS, withinInches
2439
2441
  };
2440
2442
  }
2441
2443
  var danglingDivergeWarning = (id) => `the route diverging at ${id} is not connected to anything`;
2444
+ var unreachedWarning = (id) => `${id} is not reachable from the endplate \u2014 nothing connects it`;
2442
2445
  function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS) {
2443
2446
  const byKey = new Map(graph.joints.map((j) => [j.key, j]));
2444
2447
  const pieceById = new Map(pieces.map((p) => [p.id, p]));
@@ -2576,11 +2579,14 @@ function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS)
2576
2579
  if (sw && !sw.divergeRoute) sw.divergeRoute = r.id;
2577
2580
  }
2578
2581
  const reached = new Set(routes.flatMap((r) => r.pieces));
2582
+ const unreached = [];
2579
2583
  for (const p of pieces)
2580
- if (!reached.has(p.id) && !graph.unplaceable.some((u) => u.piece === p.id))
2581
- warnings.push(`${p.id} is not reachable from the endplate \u2014 nothing connects it`);
2584
+ if (!reached.has(p.id) && !graph.unplaceable.some((u) => u.piece === p.id)) {
2585
+ warnings.push(unreachedWarning(p.id));
2586
+ unreached.push(p.id);
2587
+ }
2582
2588
  for (const c of graph.conflicts) warnings.push(c.reason);
2583
- return { routes, turnouts, warnings, danglingDiverges };
2589
+ return { routes, turnouts, warnings, danglingDiverges, unreached };
2584
2590
  }
2585
2591
  function resolveGraphAnchor(anchor, walk, pieces, library = BUILT_IN_TRACK_PARTS) {
2586
2592
  const piece = pieces.find((p) => p.id === anchor.piece);
@@ -2609,14 +2615,29 @@ function graphToDoc(pieces, input) {
2609
2615
  const epA = endplates[0];
2610
2616
  const epB = endplates[1];
2611
2617
  const main = walk.routes.find((r) => r.id === "main");
2612
- const lengthInches = round(main.toPos);
2613
- const branches = walk.routes.filter((r) => r.id !== "main" && r.pieces.length);
2618
+ const walk2 = input.start2 ? walkTrackGraph(graph, pieces, input.start2, library) : null;
2619
+ const main2 = walk2?.routes.find((r) => r.id === "main") ?? null;
2620
+ const claimed = new Set(walk.routes.flatMap((r) => r.pieces));
2621
+ if (main2 && main2.pieces.some((p) => claimed.has(p))) {
2622
+ warnings.push(
2623
+ "Main 2 starts on track that Main 1 already runs along \u2014 they are one run, not two"
2624
+ );
2625
+ }
2626
+ const twoMains = !!main2 && !main2.pieces.some((p) => claimed.has(p));
2627
+ const main2Lane = twoMains ? (graph.joints.find((j) => j.key === `${input.start2.piece}.${input.start2.joint}`)?.y ?? 1) >= 0 ? 1 : -1 : 0;
2628
+ const lengthInches = round(Math.max(main.toPos, twoMains ? main2.toPos : 0));
2629
+ const branches = [
2630
+ ...walk.routes.filter((r) => r.id !== "main" && r.pieces.length),
2631
+ ...twoMains ? walk2.routes.filter((r) => r.id !== "main" && r.pieces.length).map((r) => ({ ...r, id: `main2:${r.id}`, bornAt: r.bornAt })) : []
2632
+ ];
2614
2633
  const trackIdOf = /* @__PURE__ */ new Map([["main", MAIN_TRACK_ID]]);
2634
+ if (twoMains) trackIdOf.set("main2:main", MAIN2_TRACK_ID);
2615
2635
  for (const r of branches) trackIdOf.set(r.id, r.pieces[0]);
2616
2636
  const laneOf = (r) => {
2617
2637
  const side = Math.sign(r.lateral) || 1;
2618
2638
  const sameSide = branches.filter((x) => (Math.sign(x.lateral) || 1) === side).sort((a, b) => Math.abs(a.lateral) - Math.abs(b.lateral));
2619
- return side * (sameSide.indexOf(r) + 1);
2639
+ const taken = side === main2Lane ? 1 : 0;
2640
+ return side * (sameSide.indexOf(r) + 1 + taken);
2620
2641
  };
2621
2642
  const tracks = [
2622
2643
  {
@@ -2625,7 +2646,20 @@ function graphToDoc(pieces, input) {
2625
2646
  lane: 0,
2626
2647
  from: epA?.id ?? "A",
2627
2648
  ...epB ? { to: epB.id } : {}
2628
- }
2649
+ },
2650
+ ...twoMains ? [
2651
+ {
2652
+ id: MAIN2_TRACK_ID,
2653
+ role: "main",
2654
+ lane: main2Lane,
2655
+ from: epA?.id ?? "A",
2656
+ ...epB ? { to: epB.id } : {},
2657
+ // ⚠️ Its own extent, because a second main need not run the whole
2658
+ // module: on a transition module it starts or stops partway.
2659
+ fromPos: round(Math.min(main2.fromPos, main2.toPos)),
2660
+ toPos: round(Math.max(main2.fromPos, main2.toPos))
2661
+ }
2662
+ ] : []
2629
2663
  ];
2630
2664
  for (const r of branches) {
2631
2665
  const id = trackIdOf.get(r.id);
@@ -2643,9 +2677,29 @@ function graphToDoc(pieces, input) {
2643
2677
  ...meta.moduleTrackId != null ? { moduleTrackId: meta.moduleTrackId } : {}
2644
2678
  });
2645
2679
  }
2680
+ if (walk2) {
2681
+ const seen = /* @__PURE__ */ new Set([
2682
+ ...walk.routes.flatMap((r) => r.pieces),
2683
+ ...walk2.routes.flatMap((r) => r.pieces)
2684
+ ]);
2685
+ const covered = new Set([...walk.unreached, ...walk2.unreached].filter((id) => seen.has(id)));
2686
+ const drop = new Set([...covered].map(unreachedWarning));
2687
+ const d2 = new Set(walk2.danglingDiverges.map(danglingDivergeWarning));
2688
+ for (let i = warnings.length - 1; i >= 0; i--) if (drop.has(warnings[i])) warnings.splice(i, 1);
2689
+ for (const w of walk2.warnings)
2690
+ if (!d2.has(w) && !drop.has(w) && !warnings.includes(w)) warnings.push(w);
2691
+ }
2646
2692
  const pieceById = new Map(pieces.map((p) => [p.id, p]));
2647
2693
  const turnouts = [];
2648
- for (const t of walk.turnouts) {
2694
+ const allTurnouts = [
2695
+ ...walk.turnouts,
2696
+ ...twoMains ? walk2.turnouts.map((t) => ({
2697
+ ...t,
2698
+ onRoute: t.onRoute === "main" ? "main2:main" : `main2:${t.onRoute}`,
2699
+ divergeRoute: t.divergeRoute ? `main2:${t.divergeRoute}` : null
2700
+ })) : []
2701
+ ];
2702
+ for (const t of allTurnouts) {
2649
2703
  const diverge = t.divergeRoute ? trackIdOf.get(t.divergeRoute) : void 0;
2650
2704
  if (!diverge) {
2651
2705
  warnings.push(
@@ -2727,7 +2781,13 @@ function deriveGraphDoc(doc, library = BUILT_IN_TRACK_PARTS) {
2727
2781
  ...t.moduleTrackId != null ? { moduleTrackId: t.moduleTrackId } : {}
2728
2782
  };
2729
2783
  }
2730
- const out = graphToDoc(g.pieces, { startAt: g.startAt, base: doc, meta, library });
2784
+ const out = graphToDoc(g.pieces, {
2785
+ startAt: g.startAt,
2786
+ start2: g.start2 ?? null,
2787
+ base: doc,
2788
+ meta,
2789
+ library
2790
+ });
2731
2791
  return { doc: out.doc, warnings: out.warnings };
2732
2792
  }
2733
2793
  function frogCasting(cl, opts = {}) {
@@ -3363,6 +3423,6 @@ function poseOverridesFromDoc(doc) {
3363
3423
  return out;
3364
3424
  }
3365
3425
 
3366
- export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, JOINT_SNAP_INCHES, MAIN2_TRACK_ID, MAIN_TRACK_ID, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, PINCH_EASE_INCHES, RAIL_GAUGE_INCHES, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexRunEnd, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, pieceRoutePaths, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, snapPiece, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
3426
+ export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_MAIN_MIN_RADIUS_INCHES, FREEMO_REVERSE_CURVE_STRAIGHT_INCHES, FREEMO_TRACK_SPACING_INCHES, JOINT_SNAP_INCHES, MAIN2_TRACK_ID, MAIN_TRACK_ID, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, PINCH_EASE_INCHES, RAIL_GAUGE_INCHES, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexRunEnd, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, pieceRoutePaths, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, snapPiece, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
3367
3427
  //# sourceMappingURL=index.js.map
3368
3428
  //# sourceMappingURL=index.js.map