@willcgage/module-schematic 0.61.0 → 0.63.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
@@ -43,6 +43,19 @@ interface SchematicEndplate {
43
43
  y: number;
44
44
  heading: number;
45
45
  };
46
+ /** Whether that pose was AUTHORED — placed or typed by the owner — rather
47
+ * than a derived one that found its way into the doc (#182).
48
+ *
49
+ * Authorship used to be inferred from `pose` merely existing, so a derived
50
+ * pose written back silently PINNED the plate: it stopped following the
51
+ * module and went stale the moment the length changed (FMN-0068 ended up with
52
+ * endplate B at x=48 on a 47.9″ board). A pose is only an override when the
53
+ * owner meant it.
54
+ *
55
+ * Absent on A/B = derived residue, ignored. Absent on a placed branch
56
+ * endplate (one with `at`) = still authored — placing it IS the gesture, and
57
+ * docs predate this flag. */
58
+ poseAuthored?: boolean;
46
59
  /** Free-moN endplate FACE width across the track, inches — the physical size
47
60
  * of the standard interface at this end. Free-moN spec: 12″ minimum, 24″
48
61
  * recommended. Absent = the recommended default (modules may differ end to
@@ -1249,6 +1262,42 @@ declare const ATLAS_CODE55_N: TrackPart[];
1249
1262
  declare const BUILT_IN_TRACK_PARTS: TrackPart[];
1250
1263
  /** Look a part up by its slug. */
1251
1264
  declare function trackPart(id: string, library?: TrackPart[]): TrackPart | null;
1265
+ /** Half an N-scale tie, inches — a 8′6″ tie is 102″ prototype, /160 ≈ 0.638″.
1266
+ * The half-width a tie strip extends either side of the rail it carries, which
1267
+ * is what gives a drawn turnout body its width. */
1268
+ declare const TIE_HALF_LENGTH_INCHES = 0.319;
1269
+ /** Where a turnout part physically starts and stops, relative to its POINTS.
1270
+ * All inches; `aheadOfPoints` is the end of the tie strip, which is essentially
1271
+ * where the diverging rail stops and the owner's flex track begins. */
1272
+ interface PartExtent {
1273
+ /** Points → the near end of the tie strip. Positive = the strip starts this
1274
+ * far BEHIND the points (it always does — that end is plain approach track). */
1275
+ behindPoints: number;
1276
+ /** Points → the far end of the tie strip. */
1277
+ aheadOfPoints: number;
1278
+ /** Frog → the far end. How much turnout there still is past the frog. */
1279
+ pastFrog: number;
1280
+ }
1281
+ /**
1282
+ * A part's real extent, or **null when it hasn't been measured**.
1283
+ *
1284
+ * ⚠️ This deliberately does NOT fall back to a frog-number rule, unlike
1285
+ * {@link leadInchesForSize}. Overall length is not a function of N — the #5 and
1286
+ * the #7 are BOTH 6.00″, same tie strip, different frog. Angle is geometry;
1287
+ * length is packaging, and packaging can only be looked up. A renderer that
1288
+ * gets null should draw no part boundary rather than invent one: the absence is
1289
+ * a truthful signal that the library has a gap, and inventing a length here is
1290
+ * how hand-built geometry once reached owners as if it were part data.
1291
+ *
1292
+ * Requires `pointsOffset` and `overallLength`; `pastFrog` additionally needs
1293
+ * `frogOffset`. Every dimension must be `measured` — a derived one would launder
1294
+ * a guess into a drawing that says "this is where your turnout ends".
1295
+ */
1296
+ declare function partExtent(part: TrackPart | null | undefined): PartExtent | null;
1297
+ /** The extent of the part a turnout of this frog number IS, or null when no
1298
+ * measured part matches EXACTLY. A #6 is not a #5 or a #7 — the nearest part's
1299
+ * length says nothing about it (see {@link partExtent}). */
1300
+ declare function partExtentForSize(size: number, library?: TrackPart[]): PartExtent | null;
1252
1301
  /** The closest built-in turnout for a frog number — what a bare `size` maps to
1253
1302
  * when a turnout names no part. Exact match wins; otherwise the nearest frog. */
1254
1303
  declare function turnoutPartForSize(size: number, library?: TrackPart[]): TrackPart | null;
@@ -1624,4 +1673,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
1624
1673
  heading: number;
1625
1674
  }>;
1626
1675
 
1627
- export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CODE55_RAIL_HEIGHT_INCHES, 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 EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FrogCasting, type GeometryType, type ImportedPart, 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 PartAngle, type PartDimension, type PartEnd, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, 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, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partOutlineAtFrog, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
1676
+ export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CODE55_RAIL_HEIGHT_INCHES, 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 EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FrogCasting, type GeometryType, type ImportedPart, 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 PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, 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, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partOutlineAtFrog, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
package/dist/index.d.ts CHANGED
@@ -43,6 +43,19 @@ interface SchematicEndplate {
43
43
  y: number;
44
44
  heading: number;
45
45
  };
46
+ /** Whether that pose was AUTHORED — placed or typed by the owner — rather
47
+ * than a derived one that found its way into the doc (#182).
48
+ *
49
+ * Authorship used to be inferred from `pose` merely existing, so a derived
50
+ * pose written back silently PINNED the plate: it stopped following the
51
+ * module and went stale the moment the length changed (FMN-0068 ended up with
52
+ * endplate B at x=48 on a 47.9″ board). A pose is only an override when the
53
+ * owner meant it.
54
+ *
55
+ * Absent on A/B = derived residue, ignored. Absent on a placed branch
56
+ * endplate (one with `at`) = still authored — placing it IS the gesture, and
57
+ * docs predate this flag. */
58
+ poseAuthored?: boolean;
46
59
  /** Free-moN endplate FACE width across the track, inches — the physical size
47
60
  * of the standard interface at this end. Free-moN spec: 12″ minimum, 24″
48
61
  * recommended. Absent = the recommended default (modules may differ end to
@@ -1249,6 +1262,42 @@ declare const ATLAS_CODE55_N: TrackPart[];
1249
1262
  declare const BUILT_IN_TRACK_PARTS: TrackPart[];
1250
1263
  /** Look a part up by its slug. */
1251
1264
  declare function trackPart(id: string, library?: TrackPart[]): TrackPart | null;
1265
+ /** Half an N-scale tie, inches — a 8′6″ tie is 102″ prototype, /160 ≈ 0.638″.
1266
+ * The half-width a tie strip extends either side of the rail it carries, which
1267
+ * is what gives a drawn turnout body its width. */
1268
+ declare const TIE_HALF_LENGTH_INCHES = 0.319;
1269
+ /** Where a turnout part physically starts and stops, relative to its POINTS.
1270
+ * All inches; `aheadOfPoints` is the end of the tie strip, which is essentially
1271
+ * where the diverging rail stops and the owner's flex track begins. */
1272
+ interface PartExtent {
1273
+ /** Points → the near end of the tie strip. Positive = the strip starts this
1274
+ * far BEHIND the points (it always does — that end is plain approach track). */
1275
+ behindPoints: number;
1276
+ /** Points → the far end of the tie strip. */
1277
+ aheadOfPoints: number;
1278
+ /** Frog → the far end. How much turnout there still is past the frog. */
1279
+ pastFrog: number;
1280
+ }
1281
+ /**
1282
+ * A part's real extent, or **null when it hasn't been measured**.
1283
+ *
1284
+ * ⚠️ This deliberately does NOT fall back to a frog-number rule, unlike
1285
+ * {@link leadInchesForSize}. Overall length is not a function of N — the #5 and
1286
+ * the #7 are BOTH 6.00″, same tie strip, different frog. Angle is geometry;
1287
+ * length is packaging, and packaging can only be looked up. A renderer that
1288
+ * gets null should draw no part boundary rather than invent one: the absence is
1289
+ * a truthful signal that the library has a gap, and inventing a length here is
1290
+ * how hand-built geometry once reached owners as if it were part data.
1291
+ *
1292
+ * Requires `pointsOffset` and `overallLength`; `pastFrog` additionally needs
1293
+ * `frogOffset`. Every dimension must be `measured` — a derived one would launder
1294
+ * a guess into a drawing that says "this is where your turnout ends".
1295
+ */
1296
+ declare function partExtent(part: TrackPart | null | undefined): PartExtent | null;
1297
+ /** The extent of the part a turnout of this frog number IS, or null when no
1298
+ * measured part matches EXACTLY. A #6 is not a #5 or a #7 — the nearest part's
1299
+ * length says nothing about it (see {@link partExtent}). */
1300
+ declare function partExtentForSize(size: number, library?: TrackPart[]): PartExtent | null;
1252
1301
  /** The closest built-in turnout for a frog number — what a bare `size` maps to
1253
1302
  * when a turnout names no part. Exact match wins; otherwise the nearest frog. */
1254
1303
  declare function turnoutPartForSize(size: number, library?: TrackPart[]): TrackPart | null;
@@ -1624,4 +1673,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
1624
1673
  heading: number;
1625
1674
  }>;
1626
1675
 
1627
- export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CODE55_RAIL_HEIGHT_INCHES, 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 EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FrogCasting, type GeometryType, type ImportedPart, 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 PartAngle, type PartDimension, type PartEnd, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, 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, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partOutlineAtFrog, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
1676
+ export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CODE55_RAIL_HEIGHT_INCHES, 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 EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FrogCasting, type GeometryType, type ImportedPart, 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 PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, 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, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partOutlineAtFrog, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
package/dist/index.js CHANGED
@@ -667,7 +667,7 @@ function buildTransition(state) {
667
667
  }
668
668
  function withPoses(endplates, overrides) {
669
669
  return endplates.map(
670
- (e) => overrides[e.id] ? { ...e, pose: overrides[e.id] } : e
670
+ (e) => overrides[e.id] ? { ...e, pose: overrides[e.id], poseAuthored: true } : e
671
671
  );
672
672
  }
673
673
  function withWidths(endplates, widths, offsets = {}) {
@@ -1239,6 +1239,24 @@ var BUILT_IN_TRACK_PARTS = [...ATLAS_CODE55_N];
1239
1239
  function trackPart(id, library = BUILT_IN_TRACK_PARTS) {
1240
1240
  return library.find((p) => p.id === id) ?? null;
1241
1241
  }
1242
+ var TIE_HALF_LENGTH_INCHES = 0.319;
1243
+ function partExtent(part) {
1244
+ const pts = part?.pointsOffset;
1245
+ const overall = part?.overallLength;
1246
+ if (!pts || !overall) return null;
1247
+ if (pts.source !== "measured" || overall.source !== "measured") return null;
1248
+ const frog = part?.frogOffset;
1249
+ const aheadOfPoints = overall.inches - pts.inches;
1250
+ return {
1251
+ behindPoints: pts.inches,
1252
+ aheadOfPoints,
1253
+ pastFrog: frog && frog.source === "measured" ? overall.inches - frog.inches : aheadOfPoints
1254
+ };
1255
+ }
1256
+ function partExtentForSize(size, library = BUILT_IN_TRACK_PARTS) {
1257
+ const part = turnoutPartForSize(size, library);
1258
+ return part && part.frogNumber === size ? partExtent(part) : null;
1259
+ }
1242
1260
  function turnoutPartForSize(size, library = BUILT_IN_TRACK_PARTS) {
1243
1261
  const turnouts = library.filter((p) => p.kind === "turnout" && p.frogNumber != null);
1244
1262
  if (!turnouts.length) return null;
@@ -2031,16 +2049,32 @@ function trackMeetsEndplateIssues(path, pose, opts) {
2031
2049
  function poseNeedsManual(geometryType) {
2032
2050
  return geometryType === "wye" || geometryType === "other";
2033
2051
  }
2052
+ function isAxialPose(p) {
2053
+ const h = norm360(p.heading);
2054
+ return Math.abs(p.y) < 1e-6 && (Math.abs(h) < 1e-6 || Math.abs(h - 180) < 1e-6);
2055
+ }
2034
2056
  function poseOverridesFromDoc(doc) {
2035
2057
  const out = {};
2036
2058
  for (const e of doc.endplates ?? []) {
2037
- if (e.id && e.pose && typeof e.pose.x === "number" && typeof e.pose.y === "number" && typeof e.pose.heading === "number") {
2059
+ if (e.id && e.pose && typeof e.pose.x === "number" && typeof e.pose.y === "number" && typeof e.pose.heading === "number" && // Only an AUTHORED pose overrides derivation (#182) — but docs written
2060
+ // before the flag existed have to keep working, so authorship is inferred
2061
+ // for the two cases that can only BE authored:
2062
+ // · a placed branch endplate (`at`) — dropping it on the board is the
2063
+ // gesture, and it has no derivable position at all;
2064
+ // · an OFF-AXIS pose on A/B — a hand-placed plate is off-axis by
2065
+ // definition (that's why it needed hand placing, e.g. a wye's B).
2066
+ // What's left is an axial A/B pose, which is exactly the shape plain
2067
+ // derivation produces — residue. Honouring it silently pins the plate so
2068
+ // it stops following the module and goes stale (FMN-0068's B sat at 48 on
2069
+ // a 47.9″ board). Anything saved from now on carries the flag, so this
2070
+ // guesswork only ever applies to old docs.
2071
+ (e.poseAuthored === true || !!e.at || !isAxialPose(e.pose))) {
2038
2072
  out[e.id] = { x: e.pose.x, y: e.pose.y, heading: e.pose.heading };
2039
2073
  }
2040
2074
  }
2041
2075
  return out;
2042
2076
  }
2043
2077
 
2044
- export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, CODE55_RAIL_HEIGHT_INCHES, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, 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, RAIL_GAUGE_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partOutlineAtFrog, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
2078
+ export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, CODE55_RAIL_HEIGHT_INCHES, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, 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, RAIL_GAUGE_INCHES, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partOutlineAtFrog, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
2045
2079
  //# sourceMappingURL=index.js.map
2046
2080
  //# sourceMappingURL=index.js.map