vehicle-path2 2.0.0 → 2.1.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.
@@ -19,3 +19,4 @@ export { buildGraph, findPath, calculateBezierArcLength, resolveFromLineOffset,
19
19
  export { initializeMovingVehicle, createInitialMovementState, initializeAllVehicles, calculateInitialAxlePositions, type InitializationResult, updateAxlePosition, calculatePositionOnLine, calculatePositionOnCurve, calculateFrontAxlePosition, getCumulativeArcLength, arcLengthToSegmentPosition, prepareCommandPath, type PreparedPath, handleArrival, type SegmentCompletionContext, type SegmentCompletionResult, type SegmentVehicleState, moveVehicle, getPositionFromOffset, getLineLength } from './algorithms/vehicleMovement';
20
20
  export { PathEngine, type PathEngineConfig, type VehiclePathState, type PathExecution } from './engine';
21
21
  export { distance, normalize, getPointOnLine, getPointOnLineByOffset, getPointOnBezier, createBezierCurve, buildArcLengthTable, distanceToT, getArcLength, calculateTangentLength, isPointNearPoint, type ArcLengthEntry, type CurveOffsetOptions } from './algorithms/math';
22
+ export { serializeScene, type SceneSnapshot } from './snapshot';
@@ -0,0 +1,39 @@
1
+ import type { Line } from './types/geometry';
2
+ export interface SceneSnapshot {
3
+ lines: Line[];
4
+ curves: Array<{
5
+ id: string;
6
+ fromLineId: string;
7
+ toLineId: string;
8
+ fromOffset: number;
9
+ toOffset: number;
10
+ }>;
11
+ vehicles: Array<{
12
+ id: string;
13
+ axles: Array<{
14
+ lineId: string;
15
+ offset: number;
16
+ }>;
17
+ axleSpacings: number[];
18
+ }>;
19
+ }
20
+ /**
21
+ * Serialize scene state to a JSON string suitable for clipboard or storage.
22
+ * Strips derived fields (bezier curves, axle positions) — only source-of-truth
23
+ * data is included.
24
+ */
25
+ export declare function serializeScene(lines: Line[], curves: Array<{
26
+ id: string;
27
+ fromLineId: string;
28
+ toLineId: string;
29
+ fromOffset: number;
30
+ toOffset: number;
31
+ }>, vehicles: Array<{
32
+ id: string;
33
+ axles: Array<{
34
+ lineId: string;
35
+ offset: number;
36
+ [key: string]: unknown;
37
+ }>;
38
+ axleSpacings: number[];
39
+ }>): string;
package/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./vehicle-path.cjs");exports.PathEngine=e.PathEngine;exports.arcLengthToSegmentPosition=e.arcLengthToSegmentPosition;exports.buildArcLengthTable=e.buildArcLengthTable;exports.buildGraph=e.buildGraph;exports.calculateBezierArcLength=e.calculateBezierArcLength;exports.calculateFrontAxlePosition=e.calculateFrontAxlePosition;exports.calculateInitialAxlePositions=e.calculateInitialAxlePositions;exports.calculatePositionOnCurve=e.calculatePositionOnCurve;exports.calculatePositionOnLine=e.calculatePositionOnLine;exports.calculateTangentLength=e.calculateTangentLength;exports.createBezierCurve=e.createBezierCurve;exports.createInitialMovementState=e.createInitialMovementState;exports.distance=e.distance;exports.distanceToT=e.distanceToT;exports.findPath=e.findPath;exports.getArcLength=e.getArcLength;exports.getCumulativeArcLength=e.getCumulativeArcLength;exports.getLineLength=e.getLineLength;exports.getPointOnBezier=e.getPointOnBezier;exports.getPointOnLine=e.getPointOnLine;exports.getPointOnLineByOffset=e.getPointOnLineByOffset;exports.getPositionFromOffset=e.getPositionFromOffset;exports.handleArrival=e.handleArrival;exports.initializeAllVehicles=e.initializeAllVehicles;exports.initializeMovingVehicle=e.initializeMovingVehicle;exports.isPointNearPoint=e.isPointNearPoint;exports.moveVehicle=e.moveVehicle;exports.normalize=e.normalize;exports.prepareCommandPath=e.prepareCommandPath;exports.resolveFromLineOffset=e.resolveFromLineOffset;exports.resolveToLineOffset=e.resolveToLineOffset;exports.updateAxlePosition=e.updateAxlePosition;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DfPg-M5u.cjs");function r(n,a,o){const l={lines:n,curves:a.map(i=>({id:i.id,fromLineId:i.fromLineId,toLineId:i.toLineId,fromOffset:i.fromOffset,toOffset:i.toOffset})),vehicles:o.map(i=>({id:i.id,axles:i.axles.map(t=>({lineId:t.lineId,offset:t.offset})),axleSpacings:i.axleSpacings}))};return JSON.stringify(l,null,2)}exports.PathEngine=e.PathEngine;exports.arcLengthToSegmentPosition=e.arcLengthToSegmentPosition;exports.buildArcLengthTable=e.buildArcLengthTable;exports.buildGraph=e.buildGraph;exports.calculateBezierArcLength=e.calculateBezierArcLength;exports.calculateFrontAxlePosition=e.calculateFrontAxlePosition;exports.calculateInitialAxlePositions=e.calculateInitialAxlePositions;exports.calculatePositionOnCurve=e.calculatePositionOnCurve;exports.calculatePositionOnLine=e.calculatePositionOnLine;exports.calculateTangentLength=e.calculateTangentLength;exports.createBezierCurve=e.createBezierCurve;exports.createInitialMovementState=e.createInitialMovementState;exports.distance=e.distance;exports.distanceToT=e.distanceToT;exports.findPath=e.findPath;exports.getArcLength=e.getArcLength;exports.getCumulativeArcLength=e.getCumulativeArcLength;exports.getLineLength=e.getLineLength;exports.getPointOnBezier=e.getPointOnBezier;exports.getPointOnLine=e.getPointOnLine;exports.getPointOnLineByOffset=e.getPointOnLineByOffset;exports.getPositionFromOffset=e.getPositionFromOffset;exports.handleArrival=e.handleArrival;exports.initializeAllVehicles=e.initializeAllVehicles;exports.initializeMovingVehicle=e.initializeMovingVehicle;exports.isPointNearPoint=e.isPointNearPoint;exports.moveVehicle=e.moveVehicle;exports.normalize=e.normalize;exports.prepareCommandPath=e.prepareCommandPath;exports.resolveFromLineOffset=e.resolveFromLineOffset;exports.resolveToLineOffset=e.resolveToLineOffset;exports.updateAxlePosition=e.updateAxlePosition;exports.serializeScene=r;
package/dist/core.js CHANGED
@@ -1,35 +1,54 @@
1
- import { PathEngine as i, arcLengthToSegmentPosition as n, buildArcLengthTable as a, buildGraph as o, calculateBezierArcLength as l, calculateFrontAxlePosition as r, calculateInitialAxlePositions as c, calculatePositionOnCurve as s, calculatePositionOnLine as g, c as h, createBezierCurve as P, createInitialMovementState as u, distance as L, distanceToT as f, findPath as m, getArcLength as v, getCumulativeArcLength as A, getLineLength as O, getPointOnBezier as d, getPointOnLine as z, getPointOnLineByOffset as T, getPositionFromOffset as p, handleArrival as x, initializeAllVehicles as B, initializeMovingVehicle as C, i as b, moveVehicle as F, normalize as V, prepareCommandPath as I, resolveFromLineOffset as M, resolveToLineOffset as S, updateAxlePosition as y } from "./vehicle-path.js";
1
+ import { P as f, a as c, b as g, c as d, d as h, e as m, f as u, g as L, h as P, i as O, j as p, k as v, l as x, m as A, n as z, o as I, p as S, q as T, r as B, s as C, t as b, u as y, v as F, w as V, x as E, y as M, z as N, A as j, B as k, C as q, D as w, E as D } from "./index-D8o0W80x.js";
2
+ function o(i, t, s) {
3
+ const n = {
4
+ lines: i,
5
+ curves: t.map((e) => ({
6
+ id: e.id,
7
+ fromLineId: e.fromLineId,
8
+ toLineId: e.toLineId,
9
+ fromOffset: e.fromOffset,
10
+ toOffset: e.toOffset
11
+ })),
12
+ vehicles: s.map((e) => ({
13
+ id: e.id,
14
+ axles: e.axles.map((a) => ({ lineId: a.lineId, offset: a.offset })),
15
+ axleSpacings: e.axleSpacings
16
+ }))
17
+ };
18
+ return JSON.stringify(n, null, 2);
19
+ }
2
20
  export {
3
- i as PathEngine,
4
- n as arcLengthToSegmentPosition,
5
- a as buildArcLengthTable,
6
- o as buildGraph,
7
- l as calculateBezierArcLength,
8
- r as calculateFrontAxlePosition,
9
- c as calculateInitialAxlePositions,
10
- s as calculatePositionOnCurve,
11
- g as calculatePositionOnLine,
12
- h as calculateTangentLength,
13
- P as createBezierCurve,
14
- u as createInitialMovementState,
15
- L as distance,
16
- f as distanceToT,
17
- m as findPath,
18
- v as getArcLength,
19
- A as getCumulativeArcLength,
20
- O as getLineLength,
21
- d as getPointOnBezier,
22
- z as getPointOnLine,
23
- T as getPointOnLineByOffset,
24
- p as getPositionFromOffset,
25
- x as handleArrival,
26
- B as initializeAllVehicles,
27
- C as initializeMovingVehicle,
28
- b as isPointNearPoint,
29
- F as moveVehicle,
30
- V as normalize,
31
- I as prepareCommandPath,
32
- M as resolveFromLineOffset,
33
- S as resolveToLineOffset,
34
- y as updateAxlePosition
21
+ f as PathEngine,
22
+ c as arcLengthToSegmentPosition,
23
+ g as buildArcLengthTable,
24
+ d as buildGraph,
25
+ h as calculateBezierArcLength,
26
+ m as calculateFrontAxlePosition,
27
+ u as calculateInitialAxlePositions,
28
+ L as calculatePositionOnCurve,
29
+ P as calculatePositionOnLine,
30
+ O as calculateTangentLength,
31
+ p as createBezierCurve,
32
+ v as createInitialMovementState,
33
+ x as distance,
34
+ A as distanceToT,
35
+ z as findPath,
36
+ I as getArcLength,
37
+ S as getCumulativeArcLength,
38
+ T as getLineLength,
39
+ B as getPointOnBezier,
40
+ C as getPointOnLine,
41
+ b as getPointOnLineByOffset,
42
+ y as getPositionFromOffset,
43
+ F as handleArrival,
44
+ V as initializeAllVehicles,
45
+ E as initializeMovingVehicle,
46
+ M as isPointNearPoint,
47
+ N as moveVehicle,
48
+ j as normalize,
49
+ k as prepareCommandPath,
50
+ q as resolveFromLineOffset,
51
+ w as resolveToLineOffset,
52
+ o as serializeScene,
53
+ D as updateAxlePosition
35
54
  };