@willcgage/module-schematic 0.23.0 → 0.25.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 +24 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -94,6 +94,10 @@ interface SchematicTurnout {
|
|
|
94
94
|
address?: string | null;
|
|
95
95
|
/** Frog number ("size") — #4, #6, #8, etc. Governs the diverging angle. */
|
|
96
96
|
size?: number | null;
|
|
97
|
+
/** A curved turnout — the diverging route bows into an arc (both routes curve
|
|
98
|
+
* the same way) instead of leaving as a straight diagonal. Physical-render
|
|
99
|
+
* only; the operations view stays topological. */
|
|
100
|
+
curved?: boolean | null;
|
|
97
101
|
}
|
|
98
102
|
interface SchematicSignal {
|
|
99
103
|
id: string;
|
|
@@ -359,6 +363,9 @@ interface EditorTurnout {
|
|
|
359
363
|
kind: TurnoutKind;
|
|
360
364
|
/** Frog number ("size") — #4, #6, #8, etc. Governs the diverging angle. */
|
|
361
365
|
size?: number;
|
|
366
|
+
/** A curved turnout — the diverging route bows into an arc rather than a
|
|
367
|
+
* straight diagonal. Physical-render only (the operations view is topological). */
|
|
368
|
+
curved?: boolean;
|
|
362
369
|
}
|
|
363
370
|
interface EditorCpSignal {
|
|
364
371
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -94,6 +94,10 @@ interface SchematicTurnout {
|
|
|
94
94
|
address?: string | null;
|
|
95
95
|
/** Frog number ("size") — #4, #6, #8, etc. Governs the diverging angle. */
|
|
96
96
|
size?: number | null;
|
|
97
|
+
/** A curved turnout — the diverging route bows into an arc (both routes curve
|
|
98
|
+
* the same way) instead of leaving as a straight diagonal. Physical-render
|
|
99
|
+
* only; the operations view stays topological. */
|
|
100
|
+
curved?: boolean | null;
|
|
97
101
|
}
|
|
98
102
|
interface SchematicSignal {
|
|
99
103
|
id: string;
|
|
@@ -359,6 +363,9 @@ interface EditorTurnout {
|
|
|
359
363
|
kind: TurnoutKind;
|
|
360
364
|
/** Frog number ("size") — #4, #6, #8, etc. Governs the diverging angle. */
|
|
361
365
|
size?: number;
|
|
366
|
+
/** A curved turnout — the diverging route bows into an arc rather than a
|
|
367
|
+
* straight diagonal. Physical-render only (the operations view is topological). */
|
|
368
|
+
curved?: boolean;
|
|
362
369
|
}
|
|
363
370
|
interface EditorCpSignal {
|
|
364
371
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -224,6 +224,21 @@ function emptyEditorState(lengthInches) {
|
|
|
224
224
|
function isTransitionTurnout(t) {
|
|
225
225
|
return t.onTrack === MAIN_TRACK_ID && t.divergeTrack === MAIN2_TRACK_ID || t.onTrack === MAIN2_TRACK_ID && t.divergeTrack === MAIN_TRACK_ID;
|
|
226
226
|
}
|
|
227
|
+
function main1Track(state) {
|
|
228
|
+
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
229
|
+
const isDouble = state.configA === "double" || state.configB === "double";
|
|
230
|
+
const sw = state.turnouts.find(isTransitionTurnout);
|
|
231
|
+
if (!isDouble || bothDouble || !sw || sw.onTrack !== MAIN2_TRACK_ID) {
|
|
232
|
+
return { id: MAIN_TRACK_ID, role: "main", lane: 0, from: "A", to: "B" };
|
|
233
|
+
}
|
|
234
|
+
return state.configA === "double" ? (
|
|
235
|
+
// Double at A: Main 1 runs from A and ends at the turnout.
|
|
236
|
+
{ id: MAIN_TRACK_ID, role: "main", lane: 0, fromPos: 0, toPos: sw.pos }
|
|
237
|
+
) : (
|
|
238
|
+
// Double at B: Main 1 begins at the turnout and runs to B.
|
|
239
|
+
{ id: MAIN_TRACK_ID, role: "main", lane: 0, fromPos: sw.pos, toPos: state.lengthInches }
|
|
240
|
+
);
|
|
241
|
+
}
|
|
227
242
|
function main2Track(state) {
|
|
228
243
|
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
229
244
|
const sw = state.turnouts.find(isTransitionTurnout);
|
|
@@ -336,7 +351,11 @@ function stateToDoc(state, recordNumber) {
|
|
|
336
351
|
state.loop ? (
|
|
337
352
|
// The main runs the lead from A and turns back at the balloon.
|
|
338
353
|
{ id: MAIN_TRACK_ID, role: "main", lane: 0, fromPos: 0, toPos: state.lengthInches }
|
|
339
|
-
) :
|
|
354
|
+
) : (
|
|
355
|
+
// Normally A→B; partial when MAIN 2 is the through main and Main 1 is
|
|
356
|
+
// the one that ends at the transition turnout (#FMN-0043).
|
|
357
|
+
main1Track(state)
|
|
358
|
+
),
|
|
340
359
|
// Double track: Main 2 is a real entity so turnouts/signals can attach.
|
|
341
360
|
// On a loop it exists only for a Main 2 directional return (the U joins
|
|
342
361
|
// the two lanes at the balloon); a same-main loop's parallel lead legs
|
|
@@ -366,7 +385,8 @@ function stateToDoc(state, recordNumber) {
|
|
|
366
385
|
divergeTrack: t.divergeTrack,
|
|
367
386
|
kind: t.kind,
|
|
368
387
|
name: t.name || void 0,
|
|
369
|
-
...t.size ? { size: t.size } : {}
|
|
388
|
+
...t.size ? { size: t.size } : {},
|
|
389
|
+
...t.curved ? { curved: true } : {}
|
|
370
390
|
})),
|
|
371
391
|
...state.crossings.length > 0 ? {
|
|
372
392
|
crossings: state.crossings.map((x) => ({
|
|
@@ -527,7 +547,8 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
|
|
|
527
547
|
onTrack: t.onTrack,
|
|
528
548
|
divergeTrack: t.divergeTrack,
|
|
529
549
|
kind: t.kind ?? "right",
|
|
530
|
-
...t.size ? { size: t.size } : {}
|
|
550
|
+
...t.size ? { size: t.size } : {},
|
|
551
|
+
...t.curved ? { curved: true } : {}
|
|
531
552
|
})),
|
|
532
553
|
controlPoints: readControlPoints(d, sc),
|
|
533
554
|
industries: (d.industries ?? []).map((ind) => ({
|