@willcgage/module-schematic 0.63.0 → 0.65.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
@@ -1315,6 +1315,26 @@ declare function turnoutPartForSize(size: number, library?: TrackPart[]): TrackP
1315
1315
  * wye is a long way out. Treat those as placeholders until a part is measured.
1316
1316
  */
1317
1317
  declare function leadInchesForSize(size: number, library?: TrackPart[]): number;
1318
+ /**
1319
+ * How far a turnout of this size keeps going PAST its frog — the rest of the
1320
+ * moulding, after which the owner's flex track begins.
1321
+ *
1322
+ * The companion to {@link leadInchesForSize}, and it follows the same rule: an
1323
+ * exact measured part wins, otherwise interpolate across the measured ones. Both
1324
+ * numbers describe *how long to draw a turnout*, which is a question that always
1325
+ * has to be answered — you cannot draw nothing — so a reasoned interpolation is
1326
+ * the honest floor, and it is a far better answer than the alternative it
1327
+ * replaced (running the diverging route until it arrived parallel with the track
1328
+ * it fed, which was 10.79″ on a 6.00″ part).
1329
+ *
1330
+ * ⚠️ Do NOT confuse this with {@link partExtent}, which returns null rather than
1331
+ * guess. The difference is what is being claimed. `partExtent` says "THIS part
1332
+ * stops HERE" — a statement about a specific product, which may only be made
1333
+ * from a measurement. This says "a turnout of about this frog number runs about
1334
+ * this far past its frog", which is a drawing approximation and is labelled as
1335
+ * one: renderers draw the part's boundary only where {@link partExtent} answers.
1336
+ */
1337
+ declare function pastFrogInchesForSize(size: number, library?: TrackPart[]): number;
1318
1338
  /** One drawn piece of a part's geometry, in the part's own local frame. */
1319
1339
  type PartSegment = {
1320
1340
  kind: "straight";
@@ -1383,6 +1403,63 @@ declare function frogNumberFromName(name: string | undefined): number | undefine
1383
1403
  * land as `unverified`, because a community CAD file is not a measurement.
1384
1404
  */
1385
1405
  declare function importedPartToTrackPart(part: ImportedPart, sourceName?: string): TrackPart;
1406
+ /**
1407
+ * A part as an application stores it — one flat row, so the package needs to
1408
+ * know nothing about any particular database. Dimensions are plain numbers with
1409
+ * a `source` beside each, mirroring {@link PartDimension}.
1410
+ */
1411
+ interface StoredTrackPart {
1412
+ slug: string;
1413
+ manufacturer: string;
1414
+ line: string;
1415
+ scale?: string | null;
1416
+ name: string;
1417
+ kind?: string | null;
1418
+ partNumberLeft?: string | null;
1419
+ partNumberRight?: string | null;
1420
+ partNumberSingle?: string | null;
1421
+ frogNumber?: number | null;
1422
+ pointsOffsetInches?: number | null;
1423
+ pointsOffsetSource?: string | null;
1424
+ frogOffsetInches?: number | null;
1425
+ frogOffsetSource?: string | null;
1426
+ overallLengthInches?: number | null;
1427
+ overallLengthSource?: string | null;
1428
+ leadInches?: number | null;
1429
+ leadSource?: string | null;
1430
+ outerRadiusInches?: number | null;
1431
+ innerRadiusInches?: number | null;
1432
+ radiusSource?: string | null;
1433
+ actualAngleDeg?: number | null;
1434
+ actualAngleSource?: string | null;
1435
+ measurementNote?: string | null;
1436
+ }
1437
+ /**
1438
+ * Convert a stored row into a {@link TrackPart}.
1439
+ *
1440
+ * The LEAD is derived from the two offsets whenever both are present, rather
1441
+ * than read from its own column: they're measured from the same tie end, so
1442
+ * their difference is the lead by construction, and a separately-entered lead
1443
+ * could silently disagree with the positions it's supposed to summarise. A
1444
+ * stored `leadInches` is used only for a part whose offsets aren't known.
1445
+ */
1446
+ declare function storedPartToTrackPart(row: StoredTrackPart): TrackPart;
1447
+ /**
1448
+ * Fold an application's STORED library over the built-in one, by slug.
1449
+ *
1450
+ * ⚠️ Unlike {@link mergeImportedParts}, a stored part **replaces** a built-in
1451
+ * outright. That difference is deliberate, and the reason is who is speaking: an
1452
+ * import is a third-party file that may have been fitted in someone else's CAD
1453
+ * program, so it may only fill gaps. The stored library is seeded FROM these
1454
+ * built-ins and edited by an admin with the part in their hand — it is the same
1455
+ * library, later. Refusing their correction would mean a wrong dimension could
1456
+ * only be fixed by shipping a release, which is exactly the limitation the
1457
+ * stored library exists to remove.
1458
+ *
1459
+ * The built-ins remain the floor: a part nobody has stored still resolves, so
1460
+ * geometry keeps working with no database at all.
1461
+ */
1462
+ declare function mergeStoredParts(stored: StoredTrackPart[], library?: TrackPart[]): TrackPart[];
1386
1463
  /**
1387
1464
  * Fold imported parts into a library.
1388
1465
  *
@@ -1673,4 +1750,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
1673
1750
  heading: number;
1674
1751
  }>;
1675
1752
 
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 };
1753
+ 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, type StoredTrackPart, 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, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partOutlineAtFrog, pastFrogInchesForSize, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
package/dist/index.d.ts CHANGED
@@ -1315,6 +1315,26 @@ declare function turnoutPartForSize(size: number, library?: TrackPart[]): TrackP
1315
1315
  * wye is a long way out. Treat those as placeholders until a part is measured.
1316
1316
  */
1317
1317
  declare function leadInchesForSize(size: number, library?: TrackPart[]): number;
1318
+ /**
1319
+ * How far a turnout of this size keeps going PAST its frog — the rest of the
1320
+ * moulding, after which the owner's flex track begins.
1321
+ *
1322
+ * The companion to {@link leadInchesForSize}, and it follows the same rule: an
1323
+ * exact measured part wins, otherwise interpolate across the measured ones. Both
1324
+ * numbers describe *how long to draw a turnout*, which is a question that always
1325
+ * has to be answered — you cannot draw nothing — so a reasoned interpolation is
1326
+ * the honest floor, and it is a far better answer than the alternative it
1327
+ * replaced (running the diverging route until it arrived parallel with the track
1328
+ * it fed, which was 10.79″ on a 6.00″ part).
1329
+ *
1330
+ * ⚠️ Do NOT confuse this with {@link partExtent}, which returns null rather than
1331
+ * guess. The difference is what is being claimed. `partExtent` says "THIS part
1332
+ * stops HERE" — a statement about a specific product, which may only be made
1333
+ * from a measurement. This says "a turnout of about this frog number runs about
1334
+ * this far past its frog", which is a drawing approximation and is labelled as
1335
+ * one: renderers draw the part's boundary only where {@link partExtent} answers.
1336
+ */
1337
+ declare function pastFrogInchesForSize(size: number, library?: TrackPart[]): number;
1318
1338
  /** One drawn piece of a part's geometry, in the part's own local frame. */
1319
1339
  type PartSegment = {
1320
1340
  kind: "straight";
@@ -1383,6 +1403,63 @@ declare function frogNumberFromName(name: string | undefined): number | undefine
1383
1403
  * land as `unverified`, because a community CAD file is not a measurement.
1384
1404
  */
1385
1405
  declare function importedPartToTrackPart(part: ImportedPart, sourceName?: string): TrackPart;
1406
+ /**
1407
+ * A part as an application stores it — one flat row, so the package needs to
1408
+ * know nothing about any particular database. Dimensions are plain numbers with
1409
+ * a `source` beside each, mirroring {@link PartDimension}.
1410
+ */
1411
+ interface StoredTrackPart {
1412
+ slug: string;
1413
+ manufacturer: string;
1414
+ line: string;
1415
+ scale?: string | null;
1416
+ name: string;
1417
+ kind?: string | null;
1418
+ partNumberLeft?: string | null;
1419
+ partNumberRight?: string | null;
1420
+ partNumberSingle?: string | null;
1421
+ frogNumber?: number | null;
1422
+ pointsOffsetInches?: number | null;
1423
+ pointsOffsetSource?: string | null;
1424
+ frogOffsetInches?: number | null;
1425
+ frogOffsetSource?: string | null;
1426
+ overallLengthInches?: number | null;
1427
+ overallLengthSource?: string | null;
1428
+ leadInches?: number | null;
1429
+ leadSource?: string | null;
1430
+ outerRadiusInches?: number | null;
1431
+ innerRadiusInches?: number | null;
1432
+ radiusSource?: string | null;
1433
+ actualAngleDeg?: number | null;
1434
+ actualAngleSource?: string | null;
1435
+ measurementNote?: string | null;
1436
+ }
1437
+ /**
1438
+ * Convert a stored row into a {@link TrackPart}.
1439
+ *
1440
+ * The LEAD is derived from the two offsets whenever both are present, rather
1441
+ * than read from its own column: they're measured from the same tie end, so
1442
+ * their difference is the lead by construction, and a separately-entered lead
1443
+ * could silently disagree with the positions it's supposed to summarise. A
1444
+ * stored `leadInches` is used only for a part whose offsets aren't known.
1445
+ */
1446
+ declare function storedPartToTrackPart(row: StoredTrackPart): TrackPart;
1447
+ /**
1448
+ * Fold an application's STORED library over the built-in one, by slug.
1449
+ *
1450
+ * ⚠️ Unlike {@link mergeImportedParts}, a stored part **replaces** a built-in
1451
+ * outright. That difference is deliberate, and the reason is who is speaking: an
1452
+ * import is a third-party file that may have been fitted in someone else's CAD
1453
+ * program, so it may only fill gaps. The stored library is seeded FROM these
1454
+ * built-ins and edited by an admin with the part in their hand — it is the same
1455
+ * library, later. Refusing their correction would mean a wrong dimension could
1456
+ * only be fixed by shipping a release, which is exactly the limitation the
1457
+ * stored library exists to remove.
1458
+ *
1459
+ * The built-ins remain the floor: a part nobody has stored still resolves, so
1460
+ * geometry keeps working with no database at all.
1461
+ */
1462
+ declare function mergeStoredParts(stored: StoredTrackPart[], library?: TrackPart[]): TrackPart[];
1386
1463
  /**
1387
1464
  * Fold imported parts into a library.
1388
1465
  *
@@ -1673,4 +1750,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
1673
1750
  heading: number;
1674
1751
  }>;
1675
1752
 
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 };
1753
+ 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, type StoredTrackPart, 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, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partOutlineAtFrog, pastFrogInchesForSize, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
package/dist/index.js CHANGED
@@ -1283,6 +1283,18 @@ function leadInchesForSize(size, library = BUILT_IN_TRACK_PARTS) {
1283
1283
  const t = (size - lo.n) / (hi.n - lo.n);
1284
1284
  return lo.lead + t * (hi.lead - lo.lead);
1285
1285
  }
1286
+ function pastFrogInchesForSize(size, library = BUILT_IN_TRACK_PARTS) {
1287
+ const measured = library.filter((p) => p.kind === "turnout" && p.frogNumber != null).map((p) => ({ n: p.frogNumber, ext: partExtent(p) })).filter((p) => p.ext != null).map((p) => ({ n: p.n, past: p.ext.pastFrog })).sort((a, b) => a.n - b.n);
1288
+ if (!measured.length) return RAIL_GAUGE_INCHES * size;
1289
+ if (measured.length === 1) return measured[0].past;
1290
+ let i;
1291
+ if (size >= measured[measured.length - 1].n) i = measured.length - 2;
1292
+ else i = Math.max(0, measured.findIndex((p) => p.n >= size) - 1);
1293
+ const lo = measured[i];
1294
+ const hi = measured[i + 1];
1295
+ const t = (size - lo.n) / (hi.n - lo.n);
1296
+ return Math.max(0, lo.past + t * (hi.past - lo.past));
1297
+ }
1286
1298
  function parseXtpLibrary(text) {
1287
1299
  const parts = [];
1288
1300
  let cur = null;
@@ -1403,6 +1415,55 @@ function importedPartToTrackPart(part, sourceName = "imported .xtp") {
1403
1415
  }
1404
1416
  return out;
1405
1417
  }
1418
+ var asSource = (s) => s === "manufacturer" || s === "measured" || s === "derived" ? s : "unverified";
1419
+ function storedPartToTrackPart(row) {
1420
+ const note = row.measurementNote ?? void 0;
1421
+ const dim = (inches, source) => typeof inches === "number" && Number.isFinite(inches) ? { inches, source: asSource(source), ...note ? { note } : {} } : void 0;
1422
+ const points = dim(row.pointsOffsetInches, row.pointsOffsetSource);
1423
+ const frog = dim(row.frogOffsetInches, row.frogOffsetSource);
1424
+ const lead = points && frog ? {
1425
+ inches: frog.inches - points.inches,
1426
+ source: points.source === "measured" && frog.source === "measured" ? "measured" : "derived",
1427
+ ...note ? { note } : {}
1428
+ } : dim(row.leadInches, row.leadSource);
1429
+ const kind = row.kind;
1430
+ const part = {
1431
+ id: row.slug,
1432
+ manufacturer: row.manufacturer,
1433
+ line: row.line,
1434
+ scale: "N",
1435
+ name: row.name,
1436
+ kind: kind === "wye" || kind === "curved-turnout" || kind === "crossing" ? kind : "turnout"
1437
+ };
1438
+ const numbers = {
1439
+ ...row.partNumberLeft ? { left: row.partNumberLeft } : {},
1440
+ ...row.partNumberRight ? { right: row.partNumberRight } : {},
1441
+ ...row.partNumberSingle ? { single: row.partNumberSingle } : {}
1442
+ };
1443
+ if (Object.keys(numbers).length) part.partNumbers = numbers;
1444
+ if (typeof row.frogNumber === "number") part.frogNumber = row.frogNumber;
1445
+ if (points) part.pointsOffset = points;
1446
+ if (frog) part.frogOffset = frog;
1447
+ const overall = dim(row.overallLengthInches, row.overallLengthSource);
1448
+ if (overall) part.overallLength = overall;
1449
+ if (lead) part.lead = lead;
1450
+ const outer = dim(row.outerRadiusInches, row.radiusSource);
1451
+ const inner = dim(row.innerRadiusInches, row.radiusSource);
1452
+ if (outer) part.outerRadius = outer;
1453
+ if (inner) part.innerRadius = inner;
1454
+ if (typeof row.actualAngleDeg === "number")
1455
+ part.actualAngle = {
1456
+ deg: row.actualAngleDeg,
1457
+ source: asSource(row.actualAngleSource),
1458
+ ...note ? { note } : {}
1459
+ };
1460
+ return part;
1461
+ }
1462
+ function mergeStoredParts(stored, library = BUILT_IN_TRACK_PARTS) {
1463
+ const bySlug = new Map(library.map((p) => [p.id, p]));
1464
+ for (const row of stored) bySlug.set(row.slug, storedPartToTrackPart(row));
1465
+ return [...bySlug.values()];
1466
+ }
1406
1467
  function mergeImportedParts(imported, library = BUILT_IN_TRACK_PARTS, sourceName = "imported .xtp") {
1407
1468
  const out = library.map((p) => ({ ...p }));
1408
1469
  const numbersOf = (p) => [p.partNumbers?.left, p.partNumbers?.right, p.partNumbers?.single].filter(Boolean).map((s) => s.trim().toLowerCase());
@@ -2075,6 +2136,6 @@ function poseOverridesFromDoc(doc) {
2075
2136
  return out;
2076
2137
  }
2077
2138
 
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 };
2139
+ 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, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partOutlineAtFrog, pastFrogInchesForSize, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
2079
2140
  //# sourceMappingURL=index.js.map
2080
2141
  //# sourceMappingURL=index.js.map