@willcgage/module-schematic 0.20.0 → 0.22.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 +32 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +32 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -216,6 +216,7 @@ function emptyEditorState(lengthInches) {
|
|
|
216
216
|
poseOverrides: {},
|
|
217
217
|
endplateWidths: {},
|
|
218
218
|
outline: [],
|
|
219
|
+
sectionBreaks: [],
|
|
219
220
|
controlPoints: [],
|
|
220
221
|
industries: [],
|
|
221
222
|
mainPath: []
|
|
@@ -399,6 +400,7 @@ function stateToDoc(state, recordNumber) {
|
|
|
399
400
|
track: ind.track,
|
|
400
401
|
fromPos: ind.fromPos,
|
|
401
402
|
toPos: ind.toPos,
|
|
403
|
+
...ind.spots?.length ? { spots: ind.spots } : {},
|
|
402
404
|
side: ind.side,
|
|
403
405
|
...ind.labelMode && ind.labelMode !== "none" ? { labelMode: ind.labelMode } : {},
|
|
404
406
|
...ind.carTypes.length ? { carTypes: ind.carTypes } : {},
|
|
@@ -408,6 +410,8 @@ function stateToDoc(state, recordNumber) {
|
|
|
408
410
|
// Benchwork footprint outline (module-local inches); only when it's a real
|
|
409
411
|
// ring (≥ 3 vertices).
|
|
410
412
|
...state.outline.length >= 3 ? { outline: state.outline } : {},
|
|
413
|
+
// Internal section joints (inches from A), when the module has more than one.
|
|
414
|
+
...state.sectionBreaks.length ? { sectionBreaks: state.sectionBreaks } : {},
|
|
411
415
|
// Authored mainline path (module-local inches); only when it's a real path.
|
|
412
416
|
...state.mainPath.length >= 2 ? { mainPath: state.mainPath } : {}
|
|
413
417
|
};
|
|
@@ -507,6 +511,7 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
|
|
|
507
511
|
poseOverrides,
|
|
508
512
|
endplateWidths,
|
|
509
513
|
outline,
|
|
514
|
+
sectionBreaks: (d.sectionBreaks ?? []).filter((n) => Number.isFinite(n)).map((n) => sc(n)),
|
|
510
515
|
mainPath,
|
|
511
516
|
crossings: (d.crossings ?? []).map((x) => ({
|
|
512
517
|
id: x.id,
|
|
@@ -533,6 +538,12 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
|
|
|
533
538
|
track: ind.track,
|
|
534
539
|
fromPos: sc(ind.fromPos ?? 0),
|
|
535
540
|
toPos: ind.toPos != null ? sc(ind.toPos) : len,
|
|
541
|
+
spots: (ind.spots ?? []).map((s) => ({
|
|
542
|
+
track: s.track,
|
|
543
|
+
fromPos: sc(s.fromPos ?? 0),
|
|
544
|
+
toPos: s.toPos != null ? sc(s.toPos) : len,
|
|
545
|
+
...s.side ? { side: s.side } : {}
|
|
546
|
+
})),
|
|
536
547
|
side: ind.side ?? "above",
|
|
537
548
|
labelMode: ind.labelMode ?? "none",
|
|
538
549
|
carTypes: Array.isArray(ind.carTypes) ? ind.carTypes : [],
|
|
@@ -836,21 +847,27 @@ function moduleFeatures(doc) {
|
|
|
836
847
|
posFrac: clampFrac(e.at.pos),
|
|
837
848
|
side: e.at.side === "down" ? "down" : "up"
|
|
838
849
|
}));
|
|
839
|
-
const industries = (doc.industries ?? []).
|
|
840
|
-
const
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
850
|
+
const industries = (doc.industries ?? []).flatMap((ind) => {
|
|
851
|
+
const spots = [
|
|
852
|
+
{ track: ind.track, fromPos: ind.fromPos, toPos: ind.toPos, side: ind.side },
|
|
853
|
+
...ind.spots ?? []
|
|
854
|
+
];
|
|
855
|
+
return spots.map((sp, i) => {
|
|
856
|
+
const from = sp.fromPos ?? 0;
|
|
857
|
+
const to = sp.toPos ?? len;
|
|
858
|
+
return {
|
|
859
|
+
id: i === 0 ? ind.id : `${ind.id}-s${i}`,
|
|
860
|
+
name: ind.name ?? "",
|
|
861
|
+
type: ind.type ?? null,
|
|
862
|
+
fromFrac: clampFrac(Math.min(from, to)),
|
|
863
|
+
toFrac: clampFrac(Math.max(from, to)),
|
|
864
|
+
lane: trackLane.get(sp.track) ?? 0,
|
|
865
|
+
side: sp.side ?? "above",
|
|
866
|
+
labelMode: ind.labelMode ?? "none",
|
|
867
|
+
cars: carCapacity(from, to),
|
|
868
|
+
carTypes: Array.isArray(ind.carTypes) ? ind.carTypes : []
|
|
869
|
+
};
|
|
870
|
+
});
|
|
854
871
|
});
|
|
855
872
|
const allLanes = [
|
|
856
873
|
0,
|