minotor 1.0.3 → 1.0.5

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.
@@ -5,7 +5,7 @@ import { Route } from './route.js';
5
5
  import { ReachingTime, TripLeg } from './router.js';
6
6
  export declare class Result {
7
7
  private readonly query;
8
- private readonly earliestArrivals;
8
+ readonly earliestArrivals: Map<StopId, ReachingTime>;
9
9
  readonly earliestArrivalsPerRound: Map<StopId, TripLeg>[];
10
10
  private readonly stopsIndex;
11
11
  constructor(query: Query, earliestArrivals: Map<StopId, ReachingTime>, earliestArrivalsPerRound: Map<StopId, TripLeg>[], stopsIndex: StopsIndex);
@@ -1,13 +1,14 @@
1
1
  import { Stop } from '../stops/stops.js';
2
2
  import { Duration } from '../timetable/duration.js';
3
3
  import { Time } from '../timetable/time.js';
4
- import { ServiceRoute } from '../timetable/timetable.js';
4
+ import { ServiceRoute, TransferType } from '../timetable/timetable.js';
5
5
  export type BaseLeg = {
6
6
  from: Stop;
7
7
  to: Stop;
8
8
  };
9
9
  export type Transfer = BaseLeg & {
10
10
  minTransferTime?: Duration;
11
+ type: TransferType;
11
12
  };
12
13
  export type VehicleLeg = BaseLeg & {
13
14
  route: ServiceRoute;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minotor",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "A lightweight client-side transit router.",
5
5
  "keywords": [
6
6
  "minotor",
@@ -35,7 +35,7 @@
35
35
  "require": "./dist/router.cjs.js",
36
36
  "types": "./dist/router.d.ts"
37
37
  },
38
- "./parser.js": {
38
+ "./parser": {
39
39
  "import": "./dist/parser.esm.js",
40
40
  "require": "./dist/parser.cjs.js",
41
41
  "types": "./dist/parser.d.ts"
package/src/router.ts CHANGED
@@ -3,23 +3,37 @@ import { Query } from './routing/query.js';
3
3
  import { Result } from './routing/result.js';
4
4
  import { Leg, Route, Transfer, VehicleLeg } from './routing/route.js';
5
5
  import { ReachingTime, Router } from './routing/router.js';
6
- import { StopId } from './stops/stops.js';
6
+ import { LocationType, Stop, StopId } from './stops/stops.js';
7
7
  import { StopsIndex } from './stops/stopsIndex.js';
8
+ import { Duration } from './timetable/duration.js';
8
9
  import { Time } from './timetable/time.js';
9
- import { Timetable } from './timetable/timetable.js';
10
+ import {
11
+ PickUpDropOffType,
12
+ RouteType,
13
+ ServiceRoute,
14
+ Timetable,
15
+ TransferType,
16
+ } from './timetable/timetable.js';
10
17
 
11
18
  export {
19
+ Duration,
12
20
  Leg,
21
+ LocationType,
22
+ PickUpDropOffType,
13
23
  Plotter,
14
24
  Query,
15
25
  ReachingTime,
16
26
  Result,
17
27
  Route,
18
28
  Router,
29
+ RouteType,
30
+ ServiceRoute,
31
+ Stop,
19
32
  StopId,
20
33
  StopsIndex,
21
34
  Time,
22
35
  Timetable,
23
36
  Transfer,
37
+ TransferType,
24
38
  VehicleLeg,
25
39
  };
@@ -6,7 +6,7 @@ import { ReachingTime, TripLeg } from './router.js';
6
6
 
7
7
  export class Result {
8
8
  private readonly query: Query;
9
- private readonly earliestArrivals: Map<StopId, ReachingTime>;
9
+ public readonly earliestArrivals: Map<StopId, ReachingTime>;
10
10
  public readonly earliestArrivalsPerRound: Map<StopId, TripLeg>[];
11
11
  private readonly stopsIndex: StopsIndex;
12
12
 
@@ -1,7 +1,7 @@
1
1
  import { Stop } from '../stops/stops.js';
2
2
  import { Duration } from '../timetable/duration.js';
3
3
  import { Time } from '../timetable/time.js';
4
- import { ServiceRoute } from '../timetable/timetable.js';
4
+ import { ServiceRoute, TransferType } from '../timetable/timetable.js';
5
5
 
6
6
  export type BaseLeg = {
7
7
  from: Stop;
@@ -10,6 +10,7 @@ export type BaseLeg = {
10
10
 
11
11
  export type Transfer = BaseLeg & {
12
12
  minTransferTime?: Duration;
13
+ type: TransferType;
13
14
  };
14
15
 
15
16
  export type VehicleLeg = BaseLeg & {
@@ -24,9 +25,6 @@ export class Route {
24
25
  legs: Leg[];
25
26
 
26
27
  constructor(legs: Leg[]) {
27
- if (legs.length === 0) {
28
- throw new Error('There must be at least one leg in a route');
29
- }
30
28
  this.legs = legs;
31
29
  }
32
30
 
@@ -74,6 +74,7 @@ export class Router {
74
74
  from: this.stopsIndex.findStopById(stop)!,
75
75
  to: this.stopsIndex.findStopById(transfer.destination)!,
76
76
  minTransferTime: transfer.minTransferTime,
77
+ type: transfer.type,
77
78
  },
78
79
  });
79
80
  earliestArrivals.set(transfer.destination, {
@@ -201,7 +202,7 @@ export class Router {
201
202
  to: this.stopsIndex.findStopById(currentStop)!,
202
203
  departureTime: bestHopOnStopTimes.departure,
203
204
  arrivalTime: currentStopTimes.arrival,
204
- route: this.timetable.getServiceRoute(route.serviceRouteId),
205
+ route: this.timetable.getServiceRoute(route.serviceRouteId)!,
205
206
  },
206
207
  });
207
208
  earliestArrivals.set(currentStop, {