@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.cjs +64 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -1
- package/dist/index.d.ts +78 -1
- package/dist/index.js +62 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1285,6 +1285,18 @@ function leadInchesForSize(size, library = BUILT_IN_TRACK_PARTS) {
|
|
|
1285
1285
|
const t = (size - lo.n) / (hi.n - lo.n);
|
|
1286
1286
|
return lo.lead + t * (hi.lead - lo.lead);
|
|
1287
1287
|
}
|
|
1288
|
+
function pastFrogInchesForSize(size, library = BUILT_IN_TRACK_PARTS) {
|
|
1289
|
+
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);
|
|
1290
|
+
if (!measured.length) return RAIL_GAUGE_INCHES * size;
|
|
1291
|
+
if (measured.length === 1) return measured[0].past;
|
|
1292
|
+
let i;
|
|
1293
|
+
if (size >= measured[measured.length - 1].n) i = measured.length - 2;
|
|
1294
|
+
else i = Math.max(0, measured.findIndex((p) => p.n >= size) - 1);
|
|
1295
|
+
const lo = measured[i];
|
|
1296
|
+
const hi = measured[i + 1];
|
|
1297
|
+
const t = (size - lo.n) / (hi.n - lo.n);
|
|
1298
|
+
return Math.max(0, lo.past + t * (hi.past - lo.past));
|
|
1299
|
+
}
|
|
1288
1300
|
function parseXtpLibrary(text) {
|
|
1289
1301
|
const parts = [];
|
|
1290
1302
|
let cur = null;
|
|
@@ -1405,6 +1417,55 @@ function importedPartToTrackPart(part, sourceName = "imported .xtp") {
|
|
|
1405
1417
|
}
|
|
1406
1418
|
return out;
|
|
1407
1419
|
}
|
|
1420
|
+
var asSource = (s) => s === "manufacturer" || s === "measured" || s === "derived" ? s : "unverified";
|
|
1421
|
+
function storedPartToTrackPart(row) {
|
|
1422
|
+
const note = row.measurementNote ?? void 0;
|
|
1423
|
+
const dim = (inches, source) => typeof inches === "number" && Number.isFinite(inches) ? { inches, source: asSource(source), ...note ? { note } : {} } : void 0;
|
|
1424
|
+
const points = dim(row.pointsOffsetInches, row.pointsOffsetSource);
|
|
1425
|
+
const frog = dim(row.frogOffsetInches, row.frogOffsetSource);
|
|
1426
|
+
const lead = points && frog ? {
|
|
1427
|
+
inches: frog.inches - points.inches,
|
|
1428
|
+
source: points.source === "measured" && frog.source === "measured" ? "measured" : "derived",
|
|
1429
|
+
...note ? { note } : {}
|
|
1430
|
+
} : dim(row.leadInches, row.leadSource);
|
|
1431
|
+
const kind = row.kind;
|
|
1432
|
+
const part = {
|
|
1433
|
+
id: row.slug,
|
|
1434
|
+
manufacturer: row.manufacturer,
|
|
1435
|
+
line: row.line,
|
|
1436
|
+
scale: "N",
|
|
1437
|
+
name: row.name,
|
|
1438
|
+
kind: kind === "wye" || kind === "curved-turnout" || kind === "crossing" ? kind : "turnout"
|
|
1439
|
+
};
|
|
1440
|
+
const numbers = {
|
|
1441
|
+
...row.partNumberLeft ? { left: row.partNumberLeft } : {},
|
|
1442
|
+
...row.partNumberRight ? { right: row.partNumberRight } : {},
|
|
1443
|
+
...row.partNumberSingle ? { single: row.partNumberSingle } : {}
|
|
1444
|
+
};
|
|
1445
|
+
if (Object.keys(numbers).length) part.partNumbers = numbers;
|
|
1446
|
+
if (typeof row.frogNumber === "number") part.frogNumber = row.frogNumber;
|
|
1447
|
+
if (points) part.pointsOffset = points;
|
|
1448
|
+
if (frog) part.frogOffset = frog;
|
|
1449
|
+
const overall = dim(row.overallLengthInches, row.overallLengthSource);
|
|
1450
|
+
if (overall) part.overallLength = overall;
|
|
1451
|
+
if (lead) part.lead = lead;
|
|
1452
|
+
const outer = dim(row.outerRadiusInches, row.radiusSource);
|
|
1453
|
+
const inner = dim(row.innerRadiusInches, row.radiusSource);
|
|
1454
|
+
if (outer) part.outerRadius = outer;
|
|
1455
|
+
if (inner) part.innerRadius = inner;
|
|
1456
|
+
if (typeof row.actualAngleDeg === "number")
|
|
1457
|
+
part.actualAngle = {
|
|
1458
|
+
deg: row.actualAngleDeg,
|
|
1459
|
+
source: asSource(row.actualAngleSource),
|
|
1460
|
+
...note ? { note } : {}
|
|
1461
|
+
};
|
|
1462
|
+
return part;
|
|
1463
|
+
}
|
|
1464
|
+
function mergeStoredParts(stored, library = BUILT_IN_TRACK_PARTS) {
|
|
1465
|
+
const bySlug = new Map(library.map((p) => [p.id, p]));
|
|
1466
|
+
for (const row of stored) bySlug.set(row.slug, storedPartToTrackPart(row));
|
|
1467
|
+
return [...bySlug.values()];
|
|
1468
|
+
}
|
|
1408
1469
|
function mergeImportedParts(imported, library = BUILT_IN_TRACK_PARTS, sourceName = "imported .xtp") {
|
|
1409
1470
|
const out = library.map((p) => ({ ...p }));
|
|
1410
1471
|
const numbersOf = (p) => [p.partNumbers?.left, p.partNumbers?.right, p.partNumbers?.single].filter(Boolean).map((s) => s.trim().toLowerCase());
|
|
@@ -2121,6 +2182,7 @@ exports.isLoopDoc = isLoopDoc;
|
|
|
2121
2182
|
exports.isTransitionTurnout = isTransitionTurnout;
|
|
2122
2183
|
exports.leadInchesForSize = leadInchesForSize;
|
|
2123
2184
|
exports.mergeImportedParts = mergeImportedParts;
|
|
2185
|
+
exports.mergeStoredParts = mergeStoredParts;
|
|
2124
2186
|
exports.moduleCenterline = moduleCenterline;
|
|
2125
2187
|
exports.moduleFeatures = moduleFeatures;
|
|
2126
2188
|
exports.moduleFootprint = moduleFootprint;
|
|
@@ -2131,6 +2193,7 @@ exports.parseXtpLibrary = parseXtpLibrary;
|
|
|
2131
2193
|
exports.partExtent = partExtent;
|
|
2132
2194
|
exports.partExtentForSize = partExtentForSize;
|
|
2133
2195
|
exports.partOutlineAtFrog = partOutlineAtFrog;
|
|
2196
|
+
exports.pastFrogInchesForSize = pastFrogInchesForSize;
|
|
2134
2197
|
exports.pathLengthInches = pathLengthInches;
|
|
2135
2198
|
exports.poseNeedsManual = poseNeedsManual;
|
|
2136
2199
|
exports.poseOverridesFromDoc = poseOverridesFromDoc;
|
|
@@ -2152,6 +2215,7 @@ exports.sectionedCenterline = sectionedCenterline;
|
|
|
2152
2215
|
exports.sectionedEndPose = sectionedEndPose;
|
|
2153
2216
|
exports.sliceCenterline = sliceCenterline;
|
|
2154
2217
|
exports.stateToDoc = stateToDoc;
|
|
2218
|
+
exports.storedPartToTrackPart = storedPartToTrackPart;
|
|
2155
2219
|
exports.toSectionRelative = toSectionRelative;
|
|
2156
2220
|
exports.trackMeetsEndplateIssues = trackMeetsEndplateIssues;
|
|
2157
2221
|
exports.trackPart = trackPart;
|