@willcgage/module-schematic 0.63.0 → 0.64.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1405,6 +1405,55 @@ function importedPartToTrackPart(part, sourceName = "imported .xtp") {
1405
1405
  }
1406
1406
  return out;
1407
1407
  }
1408
+ var asSource = (s) => s === "manufacturer" || s === "measured" || s === "derived" ? s : "unverified";
1409
+ function storedPartToTrackPart(row) {
1410
+ const note = row.measurementNote ?? void 0;
1411
+ const dim = (inches, source) => typeof inches === "number" && Number.isFinite(inches) ? { inches, source: asSource(source), ...note ? { note } : {} } : void 0;
1412
+ const points = dim(row.pointsOffsetInches, row.pointsOffsetSource);
1413
+ const frog = dim(row.frogOffsetInches, row.frogOffsetSource);
1414
+ const lead = points && frog ? {
1415
+ inches: frog.inches - points.inches,
1416
+ source: points.source === "measured" && frog.source === "measured" ? "measured" : "derived",
1417
+ ...note ? { note } : {}
1418
+ } : dim(row.leadInches, row.leadSource);
1419
+ const kind = row.kind;
1420
+ const part = {
1421
+ id: row.slug,
1422
+ manufacturer: row.manufacturer,
1423
+ line: row.line,
1424
+ scale: "N",
1425
+ name: row.name,
1426
+ kind: kind === "wye" || kind === "curved-turnout" || kind === "crossing" ? kind : "turnout"
1427
+ };
1428
+ const numbers = {
1429
+ ...row.partNumberLeft ? { left: row.partNumberLeft } : {},
1430
+ ...row.partNumberRight ? { right: row.partNumberRight } : {},
1431
+ ...row.partNumberSingle ? { single: row.partNumberSingle } : {}
1432
+ };
1433
+ if (Object.keys(numbers).length) part.partNumbers = numbers;
1434
+ if (typeof row.frogNumber === "number") part.frogNumber = row.frogNumber;
1435
+ if (points) part.pointsOffset = points;
1436
+ if (frog) part.frogOffset = frog;
1437
+ const overall = dim(row.overallLengthInches, row.overallLengthSource);
1438
+ if (overall) part.overallLength = overall;
1439
+ if (lead) part.lead = lead;
1440
+ const outer = dim(row.outerRadiusInches, row.radiusSource);
1441
+ const inner = dim(row.innerRadiusInches, row.radiusSource);
1442
+ if (outer) part.outerRadius = outer;
1443
+ if (inner) part.innerRadius = inner;
1444
+ if (typeof row.actualAngleDeg === "number")
1445
+ part.actualAngle = {
1446
+ deg: row.actualAngleDeg,
1447
+ source: asSource(row.actualAngleSource),
1448
+ ...note ? { note } : {}
1449
+ };
1450
+ return part;
1451
+ }
1452
+ function mergeStoredParts(stored, library = BUILT_IN_TRACK_PARTS) {
1453
+ const bySlug = new Map(library.map((p) => [p.id, p]));
1454
+ for (const row of stored) bySlug.set(row.slug, storedPartToTrackPart(row));
1455
+ return [...bySlug.values()];
1456
+ }
1408
1457
  function mergeImportedParts(imported, library = BUILT_IN_TRACK_PARTS, sourceName = "imported .xtp") {
1409
1458
  const out = library.map((p) => ({ ...p }));
1410
1459
  const numbersOf = (p) => [p.partNumbers?.left, p.partNumbers?.right, p.partNumbers?.single].filter(Boolean).map((s) => s.trim().toLowerCase());
@@ -2121,6 +2170,7 @@ exports.isLoopDoc = isLoopDoc;
2121
2170
  exports.isTransitionTurnout = isTransitionTurnout;
2122
2171
  exports.leadInchesForSize = leadInchesForSize;
2123
2172
  exports.mergeImportedParts = mergeImportedParts;
2173
+ exports.mergeStoredParts = mergeStoredParts;
2124
2174
  exports.moduleCenterline = moduleCenterline;
2125
2175
  exports.moduleFeatures = moduleFeatures;
2126
2176
  exports.moduleFootprint = moduleFootprint;
@@ -2152,6 +2202,7 @@ exports.sectionedCenterline = sectionedCenterline;
2152
2202
  exports.sectionedEndPose = sectionedEndPose;
2153
2203
  exports.sliceCenterline = sliceCenterline;
2154
2204
  exports.stateToDoc = stateToDoc;
2205
+ exports.storedPartToTrackPart = storedPartToTrackPart;
2155
2206
  exports.toSectionRelative = toSectionRelative;
2156
2207
  exports.trackMeetsEndplateIssues = trackMeetsEndplateIssues;
2157
2208
  exports.trackPart = trackPart;