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