gtfs-to-html 2.12.3 → 2.12.4

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/app/index.js CHANGED
@@ -90,6 +90,27 @@ function calendarToDateList(calendar, startDate, endDate) {
90
90
  }
91
91
  return Array.from(dates);
92
92
  }
93
+ function combineCalendars(calendars) {
94
+ const combinedCalendar = {
95
+ monday: 0,
96
+ tuesday: 0,
97
+ wednesday: 0,
98
+ thursday: 0,
99
+ friday: 0,
100
+ saturday: 0,
101
+ sunday: 0
102
+ };
103
+ for (const calendar of calendars) {
104
+ for (const day of Object.keys(
105
+ combinedCalendar
106
+ )) {
107
+ if (calendar[day] === 1) {
108
+ combinedCalendar[day] = 1;
109
+ }
110
+ }
111
+ }
112
+ return combinedCalendar;
113
+ }
93
114
  function secondsAfterMidnight(timeString) {
94
115
  return moment.duration(timeString).asSeconds();
95
116
  }
@@ -459,7 +480,7 @@ function getAgencyGeoJSON(config2) {
459
480
  // package.json
460
481
  var package_default = {
461
482
  name: "gtfs-to-html",
462
- version: "2.12.3",
483
+ version: "2.12.4",
463
484
  private: false,
464
485
  description: "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
465
486
  keywords: [
@@ -509,26 +530,26 @@ var package_default = {
509
530
  postinstall: "node scripts/postinstall.js"
510
531
  },
511
532
  dependencies: {
512
- "@maplibre/maplibre-gl-geocoder": "^1.9.1",
513
- "@turf/helpers": "^7.3.1",
514
- "@turf/simplify": "^7.3.1",
533
+ "@maplibre/maplibre-gl-geocoder": "^1.9.4",
534
+ "@turf/helpers": "^7.3.2",
535
+ "@turf/simplify": "^7.3.2",
515
536
  anchorme: "^3.0.8",
516
537
  archiver: "^7.0.1",
517
538
  "cli-table": "^0.3.11",
518
539
  "css.escape": "^1.5.1",
519
540
  "csv-stringify": "^6.6.0",
520
541
  express: "^5.2.1",
521
- gtfs: "^4.18.2",
542
+ gtfs: "^4.18.3",
522
543
  "gtfs-realtime-pbf-js-module": "^1.0.0",
523
544
  "js-beautify": "^1.15.4",
524
- "lodash-es": "^4.17.21",
525
- "maplibre-gl": "^5.14.0",
545
+ "lodash-es": "^4.17.23",
546
+ "maplibre-gl": "^5.16.0",
526
547
  marked: "^17.0.1",
527
548
  moment: "^2.30.1",
528
549
  pbf: "^4.0.1",
529
550
  "pretty-error": "^4.0.0",
530
551
  pug: "^3.0.3",
531
- puppeteer: "^24.32.0",
552
+ puppeteer: "^24.35.0",
532
553
  "sanitize-filename": "^1.6.3",
533
554
  "sanitize-html": "^2.17.0",
534
555
  sqlstring: "^2.3.3",
@@ -544,7 +565,7 @@ var package_default = {
544
565
  "@types/js-beautify": "^1.14.3",
545
566
  "@types/lodash-es": "^4.17.12",
546
567
  "@types/morgan": "^1.9.10",
547
- "@types/node": "^24",
568
+ "@types/node": "^25",
548
569
  "@types/pug": "^2.0.10",
549
570
  "@types/sanitize-html": "^2.16.0",
550
571
  "@types/sqlstring": "^2.3.2",
@@ -552,7 +573,7 @@ var package_default = {
552
573
  "@types/yargs": "^17.0.35",
553
574
  husky: "^9.1.7",
554
575
  "lint-staged": "^16.2.7",
555
- prettier: "^3.7.4",
576
+ prettier: "^3.8.1",
556
577
  tsup: "^8.5.1",
557
578
  typescript: "^5.9.3"
558
579
  },
@@ -633,6 +654,16 @@ var deduplicateTrips = (trips) => {
633
654
  ).join("|");
634
655
  if (!uniqueTrips.has(tripSignature)) {
635
656
  uniqueTrips.set(tripSignature, trip);
657
+ } else {
658
+ const existingTrip = uniqueTrips.get(tripSignature);
659
+ if (!existingTrip) {
660
+ continue;
661
+ }
662
+ if (!existingTrip.additional_service_ids) {
663
+ existingTrip.additional_service_ids = [];
664
+ }
665
+ existingTrip.additional_service_ids.push(trip.service_id);
666
+ uniqueTrips.set(tripSignature, existingTrip);
636
667
  }
637
668
  }
638
669
  return Array.from(uniqueTrips.values());
@@ -1314,7 +1345,7 @@ var addTripContinuation = (trip, timetable) => {
1314
1345
  trip.continues_as_route = nextTrip;
1315
1346
  }
1316
1347
  };
1317
- var filterTrips = (timetable, config2) => {
1348
+ var filterTrips = (timetable, calendars, config2) => {
1318
1349
  let filteredTrips = timetable.orderedTrips;
1319
1350
  for (const trip of filteredTrips) {
1320
1351
  const combinedStoptimes = [];
@@ -1341,7 +1372,26 @@ var filterTrips = (timetable, config2) => {
1341
1372
  if (config2.showDuplicateTrips === false) {
1342
1373
  filteredTrips = deduplicateTrips(filteredTrips);
1343
1374
  }
1344
- return filteredTrips;
1375
+ const formattedTrips = filteredTrips.map((trip) => {
1376
+ const tripCalendars = calendars.filter((calendar) => {
1377
+ return [
1378
+ trip.service_id,
1379
+ ...trip.additional_service_ids || []
1380
+ ].includes(calendar.service_id);
1381
+ }) ?? [];
1382
+ trip.dayList = formatDays(combineCalendars(tripCalendars), config2);
1383
+ trip.dayListLong = formatDaysLong(trip.dayList, config2);
1384
+ if (timetable.routes.length === 1) {
1385
+ trip.route_short_name = timetable.routes[0].route_short_name;
1386
+ } else {
1387
+ const route = timetable.routes.find(
1388
+ (route2) => route2.route_id === trip.route_id
1389
+ );
1390
+ trip.route_short_name = route?.route_short_name;
1391
+ }
1392
+ return trip;
1393
+ });
1394
+ return formattedTrips;
1345
1395
  };
1346
1396
  var getTripsForTimetable = (timetable, calendars, config2) => {
1347
1397
  const tripQuery = {
@@ -1367,7 +1417,7 @@ var getTripsForTimetable = (timetable, calendars, config2) => {
1367
1417
  timetable.service_ids = uniq(trips.map((trip) => trip.service_id));
1368
1418
  const formattedTrips = [];
1369
1419
  for (const trip of trips) {
1370
- const formattedTrip = formatTrip(trip, timetable, calendars, config2);
1420
+ const formattedTrip = trip;
1371
1421
  formattedTrip.stoptimes = getStoptimes(
1372
1422
  {
1373
1423
  trip_id: formattedTrip.trip_id
@@ -1517,7 +1567,7 @@ var formatTimetables = (timetables, config2) => {
1517
1567
  timetable.trip_ids = uniq(
1518
1568
  timetable.orderedTrips.map((trip) => trip.trip_id)
1519
1569
  );
1520
- timetable.orderedTrips = filterTrips(timetable, config2);
1570
+ timetable.orderedTrips = filterTrips(timetable, calendars, config2);
1521
1571
  timetable.stops = formatStops(timetable, config2);
1522
1572
  return timetable;
1523
1573
  });
@@ -2018,22 +2068,6 @@ function formatDaysLong(dayList, config2) {
2018
2068
  const mapObject = zipObject(config2.daysShortStrings, config2.daysStrings);
2019
2069
  return replaceAll(dayList, mapObject);
2020
2070
  }
2021
- function formatTrip(trip, timetable, calendars, config2) {
2022
- trip.calendar = find2(calendars, {
2023
- service_id: trip.service_id
2024
- });
2025
- trip.dayList = formatDays(trip.calendar, config2);
2026
- trip.dayListLong = formatDaysLong(trip.dayList, config2);
2027
- if (timetable.routes.length === 1) {
2028
- trip.route_short_name = timetable.routes[0].route_short_name;
2029
- } else {
2030
- const route = timetable.routes.find(
2031
- (route2) => route2.route_id === trip.route_id
2032
- );
2033
- trip.route_short_name = route.route_short_name;
2034
- }
2035
- return trip;
2036
- }
2037
2071
  function formatFrequency(frequency, config2) {
2038
2072
  const startTime = fromGTFSTime(frequency.start_time);
2039
2073
  const endTime = fromGTFSTime(frequency.end_time);