gtfs-to-html 2.10.13 → 2.10.15

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.
@@ -112,7 +112,6 @@ import {
112
112
  flatMap as flatMap2,
113
113
  flattenDeep,
114
114
  flow,
115
- isEqual,
116
115
  groupBy,
117
116
  head,
118
117
  last,
@@ -140,7 +139,7 @@ import {
140
139
  getFrequencies,
141
140
  getTimetables,
142
141
  getTimetablePages,
143
- getAgencies,
142
+ getAgencies as getAgencies2,
144
143
  openDb
145
144
  } from "gtfs";
146
145
  import { stringify } from "csv-stringify";
@@ -158,12 +157,14 @@ import { featureCollection, round } from "@turf/helpers";
158
157
  import { clearLine, cursorTo } from "readline";
159
158
  import { noop } from "lodash-es";
160
159
  import * as colors from "yoctocolors";
161
- import { getFeedInfo } from "gtfs";
160
+ import { getAgencies, getFeedInfo } from "gtfs";
162
161
  import Table from "cli-table";
163
162
  function generateLogText(outputStats, config) {
164
163
  const feedInfo = getFeedInfo();
164
+ const agencies = getAgencies();
165
165
  const feedVersion = feedInfo.length > 0 && feedInfo[0].feed_version ? feedInfo[0].feed_version : "Unknown";
166
166
  const logText = [
167
+ `Agencies: ${agencies.map((agency) => agency.agency_name).join(", ")}`,
167
168
  `Feed Version: ${feedVersion}`,
168
169
  `GTFS-to-HTML Version: ${config.gtfsToHtmlVersion}`,
169
170
  `Date Generated: ${(/* @__PURE__ */ new Date()).toISOString()}`,
@@ -501,7 +502,7 @@ function formatTripNameForCSV(trip, timetable) {
501
502
  // package.json
502
503
  var package_default = {
503
504
  name: "gtfs-to-html",
504
- version: "2.10.13",
505
+ version: "2.10.15",
505
506
  private: false,
506
507
  description: "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
507
508
  keywords: [
@@ -552,18 +553,18 @@ var package_default = {
552
553
  anchorme: "^3.0.8",
553
554
  archiver: "^7.0.1",
554
555
  "cli-table": "^0.3.11",
555
- "csv-stringify": "^6.5.2",
556
+ "csv-stringify": "^6.6.0",
556
557
  express: "^5.1.0",
557
- gtfs: "^4.17.4",
558
+ gtfs: "^4.17.5",
558
559
  "gtfs-realtime-pbf-js-module": "^1.0.0",
559
560
  "js-beautify": "^1.15.4",
560
561
  "lodash-es": "^4.17.21",
561
- marked: "^15.0.12",
562
+ marked: "^16.1.1",
562
563
  moment: "^2.30.1",
563
564
  pbf: "^4.0.1",
564
565
  "pretty-error": "^4.0.0",
565
566
  pug: "^3.0.3",
566
- puppeteer: "^24.9.0",
567
+ puppeteer: "^24.15.0",
567
568
  "sanitize-filename": "^1.6.3",
568
569
  "sanitize-html": "^2.17.0",
569
570
  sqlstring: "^2.3.3",
@@ -575,19 +576,19 @@ var package_default = {
575
576
  },
576
577
  devDependencies: {
577
578
  "@types/archiver": "^6.0.3",
578
- "@types/express": "^5.0.2",
579
+ "@types/express": "^5.0.3",
579
580
  "@types/insane": "^1.0.0",
580
581
  "@types/js-beautify": "^1.14.3",
581
582
  "@types/lodash-es": "^4.17.12",
582
- "@types/morgan": "^1.9.9",
583
- "@types/node": "^22.15.24",
583
+ "@types/morgan": "^1.9.10",
584
+ "@types/node": "^22",
584
585
  "@types/pug": "^2.0.10",
585
586
  "@types/sanitize-html": "^2.16.0",
586
587
  "@types/timer-machine": "^1.1.3",
587
588
  "@types/yargs": "^17.0.33",
588
589
  husky: "^9.1.7",
589
- "lint-staged": "^16.1.0",
590
- prettier: "^3.5.3",
590
+ "lint-staged": "^16.1.2",
591
+ prettier: "^3.6.2",
591
592
  tsup: "^8.5.0",
592
593
  typescript: "^5.8.3"
593
594
  },
@@ -657,37 +658,20 @@ var findCommonStopId = (trips, config) => {
657
658
  });
658
659
  return commonStoptime ? commonStoptime.stop_id : null;
659
660
  };
660
- var deduplicateTrips = (trips, commonStopId) => {
661
- const deduplicatedTrips = [];
661
+ var deduplicateTrips = (trips) => {
662
+ if (trips.length <= 1) {
663
+ return trips;
664
+ }
665
+ const uniqueTrips = /* @__PURE__ */ new Map();
662
666
  for (const trip of trips) {
663
- if (deduplicatedTrips.length === 0 || trip.stoptimes.length === 0) {
664
- deduplicatedTrips.push(trip);
665
- continue;
666
- }
667
- const stoptimes = trip.stoptimes.map((stoptime) => stoptime.departure_time);
668
- const selectedStoptime = commonStopId ? find(trip.stoptimes, {
669
- stop_id: commonStopId
670
- }) : trip.stoptimes[0];
671
- const similarTrips = deduplicatedTrips.filter((trip2) => {
672
- const stoptime = find(trip2.stoptimes, {
673
- stop_id: selectedStoptime?.stop_id
674
- });
675
- if (!stoptime) {
676
- return false;
677
- }
678
- return stoptime.departure_time === selectedStoptime?.departure_time;
679
- });
680
- const tripIsUnique = every2(similarTrips, (similarTrip) => {
681
- const similarTripStoptimes = similarTrip.stoptimes.map(
682
- (stoptime) => stoptime.departure_time
683
- );
684
- return !isEqual(stoptimes, similarTripStoptimes);
685
- });
686
- if (tripIsUnique) {
687
- deduplicatedTrips.push(trip);
667
+ const tripSignature = trip.stoptimes.map(
668
+ (stoptime) => `${stoptime.stop_id}|${stoptime.departure_time}|${stoptime.arrival_time}`
669
+ ).join("|");
670
+ if (!uniqueTrips.has(tripSignature)) {
671
+ uniqueTrips.set(tripSignature, trip);
688
672
  }
689
673
  }
690
- return deduplicatedTrips;
674
+ return Array.from(uniqueTrips.values());
691
675
  };
692
676
  var sortTrips = (trips, config) => {
693
677
  let sortedTrips;
@@ -741,7 +725,10 @@ var sortTrips = (trips, config) => {
741
725
  const lastStopId = last(longestTripStoptimes).stop_id;
742
726
  sortedTrips = sortTripsByStoptimeAtStop(trips, lastStopId);
743
727
  }
744
- return deduplicateTrips(sortedTrips, commonStopId);
728
+ if (config.showDuplicateTrips === false) {
729
+ return deduplicateTrips(sortedTrips ?? []);
730
+ }
731
+ return sortedTrips ?? [];
745
732
  };
746
733
  var sortTripsByStoptimeAtStop = (trips, stopId) => sortBy(trips, (trip) => {
747
734
  const stoptime = find(trip.stoptimes, { stop_id: stopId });
@@ -1072,6 +1059,11 @@ var getStopOrder = (timetable, config) => {
1072
1059
  stopGraph.push([stopId, sortedStopIds[index + 1]]);
1073
1060
  }
1074
1061
  }
1062
+ if (stopGraph.length === 0 && config.showOnlyTimepoint === true) {
1063
+ timetable.warnings.push(
1064
+ `Timetable ${timetable.timetable_id}'s trips have stoptimes with timepoints but \`showOnlyTimepoint\` is true. Try setting \`showOnlyTimepoint\` to false.`
1065
+ );
1066
+ }
1075
1067
  const stopIds = toposort(stopGraph);
1076
1068
  return duplicateStopsForDifferentArrivalDeparture(
1077
1069
  stopIds,
@@ -1606,6 +1598,7 @@ function setDefaultConfig(initialConfig) {
1606
1598
  serviceProvidedOnText: "Service provided on",
1607
1599
  showArrivalOnDifference: 0.2,
1608
1600
  showCalendarExceptions: true,
1601
+ showDuplicateTrips: false,
1609
1602
  showMap: false,
1610
1603
  showOnlyTimepoint: false,
1611
1604
  showRouteTitle: true,
@@ -1702,7 +1695,7 @@ var generateStats = (timetablePage) => {
1702
1695
  return stats;
1703
1696
  };
1704
1697
  function generateTimetableHTML(timetablePage, config) {
1705
- const agencies = getAgencies();
1698
+ const agencies = getAgencies2();
1706
1699
  const templateVars = {
1707
1700
  timetablePage,
1708
1701
  config,
@@ -1742,7 +1735,7 @@ function generateTimetableCSV(timetable) {
1742
1735
  return stringify(lines);
1743
1736
  }
1744
1737
  function generateOverviewHTML(timetablePages, config) {
1745
- const agencies = getAgencies();
1738
+ const agencies = getAgencies2();
1746
1739
  if (agencies.length === 0) {
1747
1740
  throw new Error("No agencies found");
1748
1741
  }