@willcgage/module-schematic 0.62.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 +72 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +94 -1
- package/dist/index.d.ts +94 -1
- package/dist/index.js +68 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1241,6 +1241,24 @@ var BUILT_IN_TRACK_PARTS = [...ATLAS_CODE55_N];
|
|
|
1241
1241
|
function trackPart(id, library = BUILT_IN_TRACK_PARTS) {
|
|
1242
1242
|
return library.find((p) => p.id === id) ?? null;
|
|
1243
1243
|
}
|
|
1244
|
+
var TIE_HALF_LENGTH_INCHES = 0.319;
|
|
1245
|
+
function partExtent(part) {
|
|
1246
|
+
const pts = part?.pointsOffset;
|
|
1247
|
+
const overall = part?.overallLength;
|
|
1248
|
+
if (!pts || !overall) return null;
|
|
1249
|
+
if (pts.source !== "measured" || overall.source !== "measured") return null;
|
|
1250
|
+
const frog = part?.frogOffset;
|
|
1251
|
+
const aheadOfPoints = overall.inches - pts.inches;
|
|
1252
|
+
return {
|
|
1253
|
+
behindPoints: pts.inches,
|
|
1254
|
+
aheadOfPoints,
|
|
1255
|
+
pastFrog: frog && frog.source === "measured" ? overall.inches - frog.inches : aheadOfPoints
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
function partExtentForSize(size, library = BUILT_IN_TRACK_PARTS) {
|
|
1259
|
+
const part = turnoutPartForSize(size, library);
|
|
1260
|
+
return part && part.frogNumber === size ? partExtent(part) : null;
|
|
1261
|
+
}
|
|
1244
1262
|
function turnoutPartForSize(size, library = BUILT_IN_TRACK_PARTS) {
|
|
1245
1263
|
const turnouts = library.filter((p) => p.kind === "turnout" && p.frogNumber != null);
|
|
1246
1264
|
if (!turnouts.length) return null;
|
|
@@ -1387,6 +1405,55 @@ function importedPartToTrackPart(part, sourceName = "imported .xtp") {
|
|
|
1387
1405
|
}
|
|
1388
1406
|
return out;
|
|
1389
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
|
+
}
|
|
1390
1457
|
function mergeImportedParts(imported, library = BUILT_IN_TRACK_PARTS, sourceName = "imported .xtp") {
|
|
1391
1458
|
const out = library.map((p) => ({ ...p }));
|
|
1392
1459
|
const numbersOf = (p) => [p.partNumbers?.left, p.partNumbers?.right, p.partNumbers?.single].filter(Boolean).map((s) => s.trim().toLowerCase());
|
|
@@ -2073,6 +2140,7 @@ exports.MAIN_TRACK_ID = MAIN_TRACK_ID;
|
|
|
2073
2140
|
exports.N_CAR_LENGTH_INCHES = N_CAR_LENGTH_INCHES;
|
|
2074
2141
|
exports.N_SCALE_RATIO = N_SCALE_RATIO;
|
|
2075
2142
|
exports.RAIL_GAUGE_INCHES = RAIL_GAUGE_INCHES;
|
|
2143
|
+
exports.TIE_HALF_LENGTH_INCHES = TIE_HALF_LENGTH_INCHES;
|
|
2076
2144
|
exports.TURNOUT_LEAD_INCHES_PER_FROG = TURNOUT_LEAD_INCHES_PER_FROG;
|
|
2077
2145
|
exports.WHOLE_MODULE_SECTION_ID = WHOLE_MODULE_SECTION_ID;
|
|
2078
2146
|
exports.asModuleSchematic = asModuleSchematic;
|
|
@@ -2102,6 +2170,7 @@ exports.isLoopDoc = isLoopDoc;
|
|
|
2102
2170
|
exports.isTransitionTurnout = isTransitionTurnout;
|
|
2103
2171
|
exports.leadInchesForSize = leadInchesForSize;
|
|
2104
2172
|
exports.mergeImportedParts = mergeImportedParts;
|
|
2173
|
+
exports.mergeStoredParts = mergeStoredParts;
|
|
2105
2174
|
exports.moduleCenterline = moduleCenterline;
|
|
2106
2175
|
exports.moduleFeatures = moduleFeatures;
|
|
2107
2176
|
exports.moduleFootprint = moduleFootprint;
|
|
@@ -2109,6 +2178,8 @@ exports.moduleLengthFromSections = moduleLengthFromSections;
|
|
|
2109
2178
|
exports.moduleSections = moduleSections;
|
|
2110
2179
|
exports.nextId = nextId;
|
|
2111
2180
|
exports.parseXtpLibrary = parseXtpLibrary;
|
|
2181
|
+
exports.partExtent = partExtent;
|
|
2182
|
+
exports.partExtentForSize = partExtentForSize;
|
|
2112
2183
|
exports.partOutlineAtFrog = partOutlineAtFrog;
|
|
2113
2184
|
exports.pathLengthInches = pathLengthInches;
|
|
2114
2185
|
exports.poseNeedsManual = poseNeedsManual;
|
|
@@ -2131,6 +2202,7 @@ exports.sectionedCenterline = sectionedCenterline;
|
|
|
2131
2202
|
exports.sectionedEndPose = sectionedEndPose;
|
|
2132
2203
|
exports.sliceCenterline = sliceCenterline;
|
|
2133
2204
|
exports.stateToDoc = stateToDoc;
|
|
2205
|
+
exports.storedPartToTrackPart = storedPartToTrackPart;
|
|
2134
2206
|
exports.toSectionRelative = toSectionRelative;
|
|
2135
2207
|
exports.trackMeetsEndplateIssues = trackMeetsEndplateIssues;
|
|
2136
2208
|
exports.trackPart = trackPart;
|