gtfs-to-html 2.9.14 → 2.10.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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- interface IConfig {
1
+ interface Config {
2
2
  agencies: {
3
3
  agencyKey: string;
4
4
  agency_key?: string;
@@ -18,7 +18,7 @@ interface IConfig {
18
18
  interpolatedStopSymbol?: string;
19
19
  interpolatedStopText?: string;
20
20
  linkStopUrls?: boolean;
21
- mapboxAccessToken?: string;
21
+ mapStyleUrl?: string;
22
22
  menuType?: 'simple' | 'jump' | 'radio';
23
23
  noDropoffSymbol?: string;
24
24
  noDropoffText?: string;
@@ -56,6 +56,6 @@ interface IConfig {
56
56
  logError?: (text: string) => void;
57
57
  }
58
58
 
59
- declare const gtfsToHtml: (initialConfig: IConfig) => Promise<string>;
59
+ declare const gtfsToHtml: (initialConfig: Config) => Promise<string>;
60
60
 
61
61
  export { gtfsToHtml as default };
package/dist/index.js CHANGED
@@ -334,7 +334,7 @@ function formatTripNameForCSV(trip, timetable) {
334
334
  }
335
335
 
336
336
  // package.json
337
- var version = "2.9.14";
337
+ var version = "2.10.0";
338
338
 
339
339
  // src/lib/utils.ts
340
340
  var isTimepoint = (stoptime) => {
@@ -388,12 +388,12 @@ var deduplicateTrips = (trips, commonStopId) => {
388
388
  }) : trip.stoptimes[0];
389
389
  const similarTrips = deduplicatedTrips.filter((trip2) => {
390
390
  const stoptime = find(trip2.stoptimes, {
391
- stop_id: selectedStoptime.stop_id
391
+ stop_id: selectedStoptime?.stop_id
392
392
  });
393
393
  if (!stoptime) {
394
394
  return false;
395
395
  }
396
- return stoptime.departure_time === selectedStoptime.departure_time;
396
+ return stoptime.departure_time === selectedStoptime?.departure_time;
397
397
  });
398
398
  const tripIsUnique = every2(similarTrips, (similarTrip) => {
399
399
  const similarTripStoptimes = similarTrip.stoptimes.map(
@@ -425,8 +425,10 @@ var sortTrips = (trips, config) => {
425
425
  if (trip.stoptimes.length === 0) {
426
426
  continue;
427
427
  }
428
- trip.firstStoptime = timeToSeconds(first(trip.stoptimes).departure_time);
429
- trip.lastStoptime = timeToSeconds(last(trip.stoptimes).departure_time);
428
+ trip.firstStoptime = timeToSeconds(trip.stoptimes[0].departure_time);
429
+ trip.lastStoptime = timeToSeconds(
430
+ trip.stoptimes[trip.stoptimes.length - 1].departure_time
431
+ );
430
432
  }
431
433
  sortedTrips = sortBy(
432
434
  trips,
@@ -438,8 +440,10 @@ var sortTrips = (trips, config) => {
438
440
  if (trip.stoptimes.length === 0) {
439
441
  continue;
440
442
  }
441
- trip.firstStoptime = timeToSeconds(first(trip.stoptimes).departure_time);
442
- trip.lastStoptime = timeToSeconds(last(trip.stoptimes).departure_time);
443
+ trip.firstStoptime = timeToSeconds(trip.stoptimes[0].departure_time);
444
+ trip.lastStoptime = timeToSeconds(
445
+ trip.stoptimes[trip.stoptimes.length - 1].departure_time
446
+ );
443
447
  }
444
448
  sortedTrips = sortBy(
445
449
  trips,
@@ -505,8 +509,8 @@ var getDaysFromCalendars = (calendars) => {
505
509
  sunday: 0
506
510
  };
507
511
  for (const calendar of calendars) {
508
- for (const [day, value] of Object.entries(days2)) {
509
- days2[day] = value | calendar[day];
512
+ for (const day of Object.keys(days2)) {
513
+ days2[day] = days2[day] | calendar[day];
510
514
  }
511
515
  }
512
516
  return days2;
@@ -781,20 +785,27 @@ var getStopOrder = (timetable, config) => {
781
785
  stopGraph.push([stopId, sortedStopIds[index + 1]]);
782
786
  }
783
787
  }
784
- const stopIds2 = toposort(stopGraph);
788
+ const stopIds = toposort(stopGraph);
785
789
  return duplicateStopsForDifferentArrivalDeparture(
786
- stopIds2,
790
+ stopIds,
787
791
  timetable,
788
792
  config
789
793
  );
790
794
  } catch {
795
+ const longestTripStoptimes = getLongestTripStoptimes(
796
+ timetable.orderedTrips,
797
+ config
798
+ );
799
+ const stopIds = longestTripStoptimes.map((stoptime) => stoptime.stop_id);
800
+ config.logWarning(
801
+ `Timetable ${timetable.timetable_id} stops are unable to be topologically sorted and has no \`timetable_stop_order.txt\`. Falling back to using the using the stop order from trip with most stoptimes, but this can result in timetables with some stops missing. Try manually specifying stops with \`timetable_stop_order.txt\`.`
802
+ );
803
+ return duplicateStopsForDifferentArrivalDeparture(
804
+ stopIds,
805
+ timetable,
806
+ config
807
+ );
791
808
  }
792
- const longestTripStoptimes = getLongestTripStoptimes(
793
- timetable.orderedTrips,
794
- config
795
- );
796
- const stopIds = longestTripStoptimes.map((stoptime) => stoptime.stop_id);
797
- return duplicateStopsForDifferentArrivalDeparture(stopIds, timetable, config);
798
809
  };
799
810
  var getStopsForTimetable = (timetable, config) => {
800
811
  if (timetable.orderedTrips.length === 0) {
@@ -1277,6 +1288,7 @@ function setDefaultConfig(initialConfig) {
1277
1288
  interpolatedStopText: "Estimated time of arrival",
1278
1289
  gtfsToHtmlVersion: version,
1279
1290
  linkStopUrls: false,
1291
+ mapStyleUrl: "https://tiles.openfreemap.org/styles/liberty",
1280
1292
  menuType: "jump",
1281
1293
  noDropoffSymbol: "\u2021",
1282
1294
  noDropoffText: "No drop off available",